WooCommerce Code Reference

WC_Helper
in package

WC_Helper Class

The main entry-point for all things related to the Helper.

Table of Contents

$log  : mixed
A log object returned by wc_get_logger().
_flush_authentication_cache()  : mixed
Flush auth cache.
_flush_subscriptions_cache()  : mixed
Flush subscriptions cache.
_sort_by_name()  : int
Sort subscriptions by the Name.
_sort_by_product_name()  : int
Sort subscriptions by the product_name.
activated_plugin()  : mixed
Runs when any plugin is activated.
admin_enqueue_scripts()  : mixed
Enqueue admin scripts and styles.
admin_notices()  : mixed
Various Helper-related admin notices.
current_screen()  : mixed
Various early-phase actions with possible redirects.
deactivated_plugin()  : mixed
Runs when any plugin is deactivated.
get_current_filter()  : string
Get current filter.
get_filters()  : array
Get available subscriptions filters.
get_filters_counts()  : array
Get counts data for the filters array.
get_local_woo_plugins()  : mixed
Obtain a list of data about locally installed Woo extensions.
get_local_woo_themes()  : mixed
Get locally installed Woo themes.
get_subscriptions()  : array
Get the connected user's subscriptions.
get_view_filename()  : string
Get an absolute path to the requested helper view.
has_product_subscription()  : bool
Checks whether current site has product subscription of a given ID.
load()  : mixed
Loads the helper class, runs on init.
log()  : mixed
Log a helper event.
render_helper_output()  : mixed
Render the helper section content based on context.
includes()  : mixed
Include supporting helper classes.
_filter()  : mixed
Filter an array of subscriptions by $filter.
_flush_updates_cache()  : mixed
Flush updates cache.
_get_extensions_update_notice()  : string|null
Get an update notice if one or more Woo extensions has an update available.
_get_local_from_product_id()  : array|bool
Get a local plugin/theme entry from product_id.
_get_return_notices()  : array
Various success/error notices.
_get_subscriptions_from_product_id()  : array|bool
Get a subscription entry from product_id. If multiple subscriptions are found with the same product id and $single is set to true, will return the first one in the list, so you can use this method to get things like extension name, version, etc.
_helper_auth_connect()  : mixed
Initiate a new OAuth connection.
_helper_auth_disconnect()  : mixed
Disconnect from WooCommerce.com, clear OAuth tokens.
_helper_auth_refresh()  : mixed
User hit the Refresh button, clear all caches.
_helper_auth_return()  : mixed
Return from WooCommerce.com OAuth flow.
_helper_plugin_deactivate()  : mixed
Deactivate a plugin.
_helper_subscription_activate()  : mixed
Active a product subscription.
_helper_subscription_deactivate()  : mixed
Deactivate a product subscription.
_woo_core_update_available()  : bool
Whether WooCommerce has an update available.

Properties

Methods

_sort_by_name()

Sort subscriptions by the Name.

public static _sort_by_name(array $a, array $b) : int
Parameters
$a : array

Product array.

$b : array

Product array.

Return values
int

_sort_by_product_name()

Sort subscriptions by the product_name.

public static _sort_by_product_name(array $a, array $b) : int
Parameters
$a : array

Subscription array.

$b : array

Subscription array.

Return values
int

activated_plugin()

Runs when any plugin is activated.

public static activated_plugin(string $filename) : mixed

Depending on the activated plugin attempts to look through available subscriptions and auto-activate one if possible, so the user does not need to visit the Helper UI at all after installing a new extension.

Parameters
$filename : string

The filename of the activated plugin.

Return values
mixed

current_screen()

Various early-phase actions with possible redirects.

public static current_screen(object $screen) : mixed
Parameters
$screen : object

WP screen object.

Return values
mixed

deactivated_plugin()

Runs when any plugin is deactivated.

public static deactivated_plugin(string $filename) : mixed

When a user deactivates a plugin, attempt to deactivate any subscriptions associated with the extension.

Parameters
$filename : string

The filename of the deactivated plugin.

Return values
mixed

get_filters_counts()

Get counts data for the filters array.

public static get_filters_counts([array $subscriptions = null ]) : array
Parameters
$subscriptions : array = null

The array of all available subscriptions.

Return values
arrayFilter counts (filter => count).

get_view_filename()

Get an absolute path to the requested helper view.

public static get_view_filename(string $view) : string
Parameters
$view : string

The requested view file.

Return values
stringThe absolute path to the view file.

has_product_subscription()

Checks whether current site has product subscription of a given ID.

public static has_product_subscription(int $product_id) : bool
Parameters
$product_id : int

The product id.

Tags
since
3.7.0
Return values
boolReturns true if product subscription exists, false otherwise.

log()

Log a helper event.

public static log(string $message[, string $level = 'info' ]) : mixed
Parameters
$message : string

Log message.

$level : string = 'info'

Optional, defaults to info, valid levels: emergency|alert|critical|error|warning|notice|info|debug.

Return values
mixed

_filter()

Filter an array of subscriptions by $filter.

private static _filter(array &$subscriptions, string $filter) : mixed
Parameters
$subscriptions : array

The subscriptions array, passed by ref.

$filter : string

The filter.

Return values
mixed

_get_extensions_update_notice()

Get an update notice if one or more Woo extensions has an update available.

private static _get_extensions_update_notice() : string|null
Return values
string|nullThe update notice or null if everything is up to date.

_get_local_from_product_id()

Get a local plugin/theme entry from product_id.

private static _get_local_from_product_id(int $product_id) : array|bool
Parameters
$product_id : int

The product id.

Return values
array|boolThe array containing the local plugin/theme data or false.

_get_return_notices()

Various success/error notices.

private static _get_return_notices() : array

Runs during admin page render, so no headers/redirects here.

Return values
arrayArray pairs of message/type strings with notices.

_get_subscriptions_from_product_id()

Get a subscription entry from product_id. If multiple subscriptions are found with the same product id and $single is set to true, will return the first one in the list, so you can use this method to get things like extension name, version, etc.

private static _get_subscriptions_from_product_id(int $product_id[, bool $single = true ]) : array|bool
Parameters
$product_id : int

The product id.

$single : bool = true

Whether to return a single subscription or all matching a product id.

Return values
array|boolThe array containing sub data or false.

_woo_core_update_available()

Whether WooCommerce has an update available.

private static _woo_core_update_available() : bool
Return values
boolTrue if a Woo core update is available.