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

add_connect_woocom_plugin_message()  : void
Runs on in_plugin_update_message-{file-name}, show a message to connect to woocommerce.com for unconnected stores
add_hook_for_modifying_update_notices()  : mixed
Add the hook for modifying default WPCore update notices on the plugins management page.
add_install_marketplace_plugin_message()  : void
Runs on in_plugin_update_message-{file-name}, show a message to install the Woo Marketplace plugin, on plugin update notification, if the Woo Marketplace plugin isn't already installed.
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.
display_notice_for_expired_and_expiring_subscriptions()  : void
Runs on in_plugin_update_message-{file-name}, show a message if plugins subscription expired or expiring soon.
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_based_on_site_status()  : int
Get the update count to based on the status of the site.
get_updates_count_html()  : string
Return the updates count markup.
get_woo_connect_notice_type()  : string
Get the type of woo connect notice to be shown in the WC Settings and Marketplace pages.
load()  : mixed
Loads the class, runs on init.
setup_message_for_expired_and_expiring_subscriptions()  : mixed
Add the hook for modifying default WPCore update notices on the plugins management page.
setup_update_plugins_messages()  : void
Runs on load-plugins.php, adds a hook to show a custom plugin update message for WooCommerce.com hosted plugins.
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.
_update_check()  : array<string|int, mixed>
Run an update check API call.

Methods

add_connect_woocom_plugin_message()

Runs on in_plugin_update_message-{file-name}, show a message to connect to woocommerce.com for unconnected stores

public static add_connect_woocom_plugin_message() : void
Return values
void

add_hook_for_modifying_update_notices()

Add the hook for modifying default WPCore update notices on the plugins management page.

public static add_hook_for_modifying_update_notices() : mixed
Return values
mixed

add_install_marketplace_plugin_message()

Runs on in_plugin_update_message-{file-name}, show a message to install the Woo Marketplace plugin, on plugin update notification, if the Woo Marketplace plugin isn't already installed.

public static add_install_marketplace_plugin_message(object $plugin_data, object $response) : void
Parameters
$plugin_data : object

TAn array of plugin metadata.

$response : object

An object of metadata about the available plugin update.

Return values
void

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.

display_notice_for_expired_and_expiring_subscriptions()

Runs on in_plugin_update_message-{file-name}, show a message if plugins subscription expired or expiring soon.

public static display_notice_for_expired_and_expiring_subscriptions(object $plugin_data, object $response) : void
Parameters
$plugin_data : object

An array of plugin metadata.

$response : object

An object of metadata about the available plugin update.

Return values
void

get_available_extensions_downloads_data()

Get update data for all plugins.

public static get_available_extensions_downloads_data() : array<string|int, mixed>
Tags
see
get_update_data
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_html()

Return the updates count markup.

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

get_woo_connect_notice_type()

Get the type of woo connect notice to be shown in the WC Settings and Marketplace pages.

public static get_woo_connect_notice_type() : string
  • If a store is connected to woocommerce.com or has no installed woo plugins, return 'none'.
  • If a store has installed woo plugins but no updates, return 'short'.
  • If a store has an installed woo plugin with update, return 'long'.
Return values
stringThe notice type, 'none', 'short', or 'long'.

setup_message_for_expired_and_expiring_subscriptions()

Add the hook for modifying default WPCore update notices on the plugins management page.

public static setup_message_for_expired_and_expiring_subscriptions() : mixed
Return values
mixed

setup_update_plugins_messages()

Runs on load-plugins.php, adds a hook to show a custom plugin update message for WooCommerce.com hosted plugins.

public static setup_update_plugins_messages() : void
Return values
void

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.

_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.

Return values
array<string|int, mixed>Update data for each requested product.