WC_Admin_Addons
in package
WC_Admin_Addons Class.
Table of Contents
- add_in_app_purchase_url_params() : mixed
- Add in-app-purchase URL params to link.
- fetch() : array<string|int, mixed>|WP_Error
- Make wp_safe_remote_get request to WooCommerce.com endpoint.
- fetch_featured() : array<string|int, mixed>|WP_Error
- Fetch featured products from WCCOM's the Featured 3.0 Endpoint and cache the data for a day.
- filter_admin_body_classes() : string
- We're displaying page=wc-addons and page=wc-addons§ion=helper as two separate pages.
- get_action_url() : string
- Take an action object and return the URL based on properties of the action.
- get_in_app_purchase_url_params() : mixed
- Returns in-app-purchase URL params.
- get_section() : object|bool
- Get section for the addons screen.
- get_sections() : array<string|int, mixed>
- Get sections for the addons screen
- handle_legacy_marketplace_redirects() : void
- Process requests to legacy marketplace menu and redirect to correct in-app pages.
- is_ssl_error() : bool
- Check if the error is due to an SSL error
- output_button() : mixed
- Outputs a button.
- get_locale_data_from_transient() : mixed
- Retrieves the locale data from a transient.
- set_locale_data_in_transient() : bool
- Sets the locale data in a transient.
Methods
add_in_app_purchase_url_params()
Add in-app-purchase URL params to link.
public
static add_in_app_purchase_url_params(string $url) : mixed
Adds various url parameters to a url to support a streamlined flow for obtaining and setting up WooCommerce extensons.
Parameters
- $url : string
-
Destination URL.
Return values
mixed —fetch()
Make wp_safe_remote_get request to WooCommerce.com endpoint.
public
static fetch(string $url[, array<string|int, mixed>|null $options = array() ]) : array<string|int, mixed>|WP_Error
Optionally pass user auth token, locale or country.
Parameters
- $url : string
-
URL to request.
- $options : array<string|int, mixed>|null = array()
-
Options for the request. For example, to pass auth token, locale and country, pass array( 'auth' => true, 'locale' => true, 'country' => true, ).
Return values
array<string|int, mixed>|WP_Error —fetch_featured()
Fetch featured products from WCCOM's the Featured 3.0 Endpoint and cache the data for a day.
public
static fetch_featured() : array<string|int, mixed>|WP_Error
Return values
array<string|int, mixed>|WP_Error —filter_admin_body_classes()
We're displaying page=wc-addons and page=wc-addons§ion=helper as two separate pages.
public
static filter_admin_body_classes([string $admin_body_class = '' ]) : string
When we're on those pages, add body classes to distinguishe them.
Parameters
- $admin_body_class : string = ''
-
Unfiltered body class.
Return values
string — Body class with added class for Marketplace or My Subscriptions page.get_action_url()
Take an action object and return the URL based on properties of the action.
public
static get_action_url(object $action) : string
Parameters
- $action : object
-
Action object.
Return values
string — URL.get_in_app_purchase_url_params()
Returns in-app-purchase URL params.
public
static get_in_app_purchase_url_params() : mixed
Return values
mixed —get_section()
Get section for the addons screen.
public
static get_section(string $section_id) : object|bool
Parameters
- $section_id : string
-
Required section ID.
Return values
object|bool —get_sections()
Get sections for the addons screen
public
static get_sections() : array<string|int, mixed>
Return values
array<string|int, mixed> — of objectshandle_legacy_marketplace_redirects()
Process requests to legacy marketplace menu and redirect to correct in-app pages.
public
static handle_legacy_marketplace_redirects() : void
Return values
void —is_ssl_error()
Check if the error is due to an SSL error
public
static is_ssl_error(string $error_message) : bool
Parameters
- $error_message : string
-
Error message.
Return values
bool — True if SSL error, false otherwiseoutput_button()
Outputs a button.
public
static output_button(string $url, string $text, string $style[, string $plugin = '' ]) : mixed
Parameters
- $url : string
-
Destination URL.
- $text : string
-
Button label text.
- $style : string
-
Button style class.
- $plugin : string = ''
-
The plugin the button is promoting.
Return values
mixed —get_locale_data_from_transient()
Retrieves the locale data from a transient.
private
static get_locale_data_from_transient(string $transient, string $locale) : mixed
Transient value is an array of locale data in the following format: array( 'en_US' => ..., 'fr_FR' => ..., )
If the transient does not exist, does not have a value, or has expired, then the return value will be false.
Parameters
- $transient : string
-
Transient name. Expected to not be SQL-escaped.
- $locale : string
-
Locale to retrieve.
Return values
mixed — Value of transient.set_locale_data_in_transient()
Sets the locale data in a transient.
private
static set_locale_data_in_transient(string $transient, mixed $value, string $locale, int $expiration) : bool
Transient value is an array of locale data in the following format: array( 'en_US' => ..., 'fr_FR' => ..., )
Parameters
- $transient : string
-
Transient name. Expected to not be SQL-escaped. Must be 172 characters or fewer in length.
- $value : mixed
-
Transient value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
- $locale : string
-
Locale to set.
- $expiration : int
-
Optional. Time until expiration in seconds. Default 0 (no expiration).