WC_Helper_Updater
in package
WC_Helper_Updater Class
Contains the logic to fetch available updates and hook into Core's update routines to serve WooCommerce.com-provided packages.
Table of Contents
- block_expired_updates() : false|WP_Error
- Hooked into the upgrader_pre_download filter in order to better handle error messaging around expired plugin updates. Initially we were using an empty string, but the error message that no_package results in does not fit the cause.
- flush_updates_cache() : mixed
- Flushes cached update data.
- get_available_extensions_downloads_data() : array<string|int, mixed>
- Get update data for all plugins.
- get_translations_update_data() : array<string|int, mixed>
- Get translations updates information.
- get_update_data() : array<string|int, mixed>
- Get update data for all extensions.
- get_updates_count() : int
- Get the number of products that have updates.
- get_updates_count_html() : string
- Return the updates count markup.
- load() : mixed
- Loads the class, runs on init.
- transient_update_plugins() : object
- Runs in a cron thread, or in a visitor thread if triggered by _maybe_update_plugins(), or in an auto-update thread.
- transient_update_themes() : object
- Runs on pre_set_site_transient_update_themes, provides custom packages for WooCommerce.com-hosted extensions.
- upgrader_process_complete() : mixed
- Fires when a user successfully updated a theme or a plugin.
- _has_active_subscription() : bool
- Check for an active subscription.
- _update_check() : array<string|int, mixed>
- Run an update check API call.
Methods
block_expired_updates()
Hooked into the upgrader_pre_download filter in order to better handle error messaging around expired plugin updates. Initially we were using an empty string, but the error message that no_package results in does not fit the cause.
public
static block_expired_updates(bool $reply, string $package) : false|WP_Error
Parameters
- $reply : bool
-
Holds the current filtered response.
- $package : string
-
The path to the package file for the update.
Tags
Return values
false|WP_Error — False to proceed with the update as normal, anything else to be returned instead of updating.flush_updates_cache()
Flushes cached update data.
public
static flush_updates_cache() : mixed
Return values
mixed —get_available_extensions_downloads_data()
Get update data for all plugins.
public
static get_available_extensions_downloads_data() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> — Update data {product_id => data}get_translations_update_data()
Get translations updates information.
public
static get_translations_update_data() : array<string|int, mixed>
Scans through all subscriptions for the connected user, as well as all Woo extensions without a subscription, and obtains update data for each product.
Return values
array<string|int, mixed> — Update data {product_id => data}get_update_data()
Get update data for all extensions.
public
static get_update_data() : array<string|int, mixed>
Scans through all subscriptions for the connected user, as well as all Woo extensions without a subscription, and obtains update data for each product.
Return values
array<string|int, mixed> — Update data {product_id => data}get_updates_count()
Get the number of products that have updates.
public
static get_updates_count() : int
Return values
int — The number of products with updates.get_updates_count_html()
Return the updates count markup.
public
static get_updates_count_html() : string
Return values
string — Updates count markup, empty string if no updates avairable.load()
Loads the class, runs on init.
public
static load() : mixed
Return values
mixed —transient_update_plugins()
Runs in a cron thread, or in a visitor thread if triggered by _maybe_update_plugins(), or in an auto-update thread.
public
static transient_update_plugins(object $transient) : object
Parameters
- $transient : object
-
The update_plugins transient object.
Return values
object — The same or a modified version of the transient.transient_update_themes()
Runs on pre_set_site_transient_update_themes, provides custom packages for WooCommerce.com-hosted extensions.
public
static transient_update_themes(object $transient) : object
Parameters
- $transient : object
-
The update_themes transient object.
Return values
object — The same or a modified version of the transient.upgrader_process_complete()
Fires when a user successfully updated a theme or a plugin.
public
static upgrader_process_complete() : mixed
Return values
mixed —_has_active_subscription()
Check for an active subscription.
private
static _has_active_subscription(int $product_id) : bool
Checks a given product id against all subscriptions on the current site. Returns true if at least one active subscription is found.
Parameters
- $product_id : int
-
The product id to look for.
Return values
bool — True if active subscription found._update_check()
Run an update check API call.
private
static _update_check(array<string|int, mixed> $payload) : array<string|int, mixed>
The call is cached based on the payload (product ids, file ids). If the payload changes, the cache is going to miss.
Parameters
- $payload : array<string|int, mixed>
-
Information about the plugin to update.