WooCommerce Code Reference

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_translations_update_data()  : array
Get translations updates informations.
get_update_data()  : array
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
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
since
4.1.0
Return values
false|WP_ErrorFalse to proceed with the update as normal, anything else to be returned instead of updating.

get_translations_update_data()

Get translations updates informations.

public static get_translations_update_data() : array

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
arrayUpdate data {product_id => data}

get_update_data()

Get update data for all extensions.

public static get_update_data() : array

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
arrayUpdate data {product_id => data}

get_updates_count_html()

Return the updates count markup.

public static get_updates_count_html() : string
Return values
stringUpdates count markup, empty string if no updates avairable.

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
objectThe 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
objectThe same or a modified version of the transient.

_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
boolTrue if active subscription found.

_update_check()

Run an update check API call.

private static _update_check(array $payload) : array

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

Information about the plugin to update.

Return values
arrayUpdate data for each requested product.