WooCommerce Code Reference

PluginsHelper
in package

Class PluginsHelper

Table of Contents

DISMISS_EXPIRED_SUBS_NOTICE  = 'woo_subscription_expired_notice_dismiss'
Meta key for dismissing expired subscription notices.
DISMISS_EXPIRING_SUBS_NOTICE  = 'woo_subscription_expiring_notice_dismiss'
Meta key for dismissing expiring subscription notices
WOO_SUBSCRIPTION_PAGE_URL  = 'https://woocommerce.com/my-account/my-subscriptions/'
The URL for the WooCommerce subscription page.
$can_show_expiring_subs_notice  : bool
Indicates whether the expiration notice for subscriptions can be displayed.
activate_plugins()  : WP_Error|array<string|int, mixed>
Activate the requested plugins.
get_action_data()  : array<string|int, mixed>
Gets the plugin data for the first action.
get_activation_status()  : array<string|int, mixed>
Activation status.
get_active_plugin_slugs()  : array<string|int, mixed>
Get an array of active plugin slugs.
get_expired_subscription_notice()  : array<string|int, mixed>
Get formatted notice information for expired subscription.
get_expiring_subscription_notice()  : array<string|int, mixed>
Get formatted notice information for expiring subscription.
get_installation_status()  : array<string|int, mixed>
Installation status.
get_installed_plugin_slugs()  : array<string|int, mixed>
Get an array of installed plugin slugs.
get_installed_plugins_paths()  : array<string|int, mixed>
Get an array of installed plugins with their file paths as a key value pair.
get_plugin_data()  : array<string|int, mixed>|false
Get plugin data.
get_plugin_path_from_slug()  : string|false
Get the path to the plugin file relative to the plugins directory from the plugin slug.
get_subscriptions_notice_data()  : array<string|int, mixed>
Construct the subscritpion notice data based on user subscriptions data.
init()  : mixed
Initialize hooks.
install_and_activate_plugins_async_callback()  : bool
Callback regsitered by OnboardingPlugins::install_and_activate_async.
install_plugins()  : array<string|int, mixed>
Install an array of plugins.
is_plugin_active()  : bool
Checks if a plugin is active.
is_plugin_installed()  : bool
Checks if a plugin is installed.
maybe_enqueue_scripts_for_connect_notice()  : void
Enqueue scripts for connect notice in WooCommerce settings page.
maybe_enqueue_scripts_for_notices_in_plugins()  : void
Enqueue scripts for notices in plugin list page.
maybe_enqueue_scripts_for_subscription_notice()  : void
Enqueue scripts for woo subscription notice.
maybe_show_connect_notice_in_plugin_list()  : void
Show notices to connect to woocommerce.com for unconnected store in the plugin list.
maybe_show_expired_subscriptions_notice()  : void
Show notice about to expired subscription on WC settings page.
maybe_show_expiring_subscriptions_notice()  : void
Show notice about to expiring subscription on WC settings page.
schedule_activate_plugins()  : string
Schedule plugin activation.
schedule_install_plugins()  : string
Schedule plugin installation.
should_show_notice()  : bool
Determine whether a specific notice should be shown to the current user.

Constants

DISMISS_EXPIRED_SUBS_NOTICE

Meta key for dismissing expired subscription notices.

public mixed DISMISS_EXPIRED_SUBS_NOTICE = 'woo_subscription_expired_notice_dismiss'

DISMISS_EXPIRING_SUBS_NOTICE

Meta key for dismissing expiring subscription notices

public mixed DISMISS_EXPIRING_SUBS_NOTICE = 'woo_subscription_expiring_notice_dismiss'

WOO_SUBSCRIPTION_PAGE_URL

The URL for the WooCommerce subscription page.

public mixed WOO_SUBSCRIPTION_PAGE_URL = 'https://woocommerce.com/my-account/my-subscriptions/'

Properties

$can_show_expiring_subs_notice

Indicates whether the expiration notice for subscriptions can be displayed.

public static bool $can_show_expiring_subs_notice = true

Methods

activate_plugins()

Activate the requested plugins.

public static activate_plugins(array<string|int, mixed> $plugins[, PluginsInstallLogger|null $logger = null ]) : WP_Error|array<string|int, mixed>
Parameters
$plugins : array<string|int, mixed>

Plugins.

$logger : PluginsInstallLogger|null = null

Logger.

Return values
WP_Error|array<string|int, mixed>Plugin Status

get_action_data()

Gets the plugin data for the first action.

public static get_action_data(array<string|int, mixed> $actions) : array<string|int, mixed>
Parameters
$actions : array<string|int, mixed>

Array of AS actions.

Return values
array<string|int, mixed>Array of action data.

get_activation_status()

Activation status.

public static get_activation_status([int $job_id = null ]) : array<string|int, mixed>
Parameters
$job_id : int = null

Job ID.

Return values
array<string|int, mixed>Array of action data.

get_active_plugin_slugs()

Get an array of active plugin slugs.

public static get_active_plugin_slugs() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_expired_subscription_notice()

Get formatted notice information for expired subscription.

public static get_expired_subscription_notice([bool $allowed_link = true ]) : array<string|int, mixed>
Parameters
$allowed_link : bool = true

whether the notice description should include a link.

Return values
array<string|int, mixed>notice information.

get_expiring_subscription_notice()

Get formatted notice information for expiring subscription.

public static get_expiring_subscription_notice([bool $allowed_link = true ]) : array<string|int, mixed>
Parameters
$allowed_link : bool = true

whether the notice description should include a link.

Return values
array<string|int, mixed>notice information.

get_installation_status()

Installation status.

public static get_installation_status([int $job_id = null ]) : array<string|int, mixed>
Parameters
$job_id : int = null

Job ID.

Return values
array<string|int, mixed>Job data.

get_installed_plugin_slugs()

Get an array of installed plugin slugs.

public static get_installed_plugin_slugs() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_installed_plugins_paths()

Get an array of installed plugins with their file paths as a key value pair.

public static get_installed_plugins_paths() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_plugin_data()

Get plugin data.

public static get_plugin_data(string $plugin) : array<string|int, mixed>|false
Parameters
$plugin : string

Path to the plugin file relative to the plugins directory or the plugin directory name.

Return values
array<string|int, mixed>|false

get_plugin_path_from_slug()

Get the path to the plugin file relative to the plugins directory from the plugin slug.

public static get_plugin_path_from_slug(string $slug) : string|false

E.g. 'woocommerce' returns 'woocommerce/woocommerce.php'

Parameters
$slug : string

Plugin slug to get path for.

Return values
string|false

get_subscriptions_notice_data()

Construct the subscritpion notice data based on user subscriptions data.

public static get_subscriptions_notice_data(array<string|int, mixed> $all_subs, array<string|int, mixed> $subs_to_show, int $total, array<string|int, mixed> $messages, string $type) : array<string|int, mixed>
Parameters
$all_subs : array<string|int, mixed>

all subscription data.

$subs_to_show : array<string|int, mixed>

filtered subscriptions as condition.

$total : int

total subscription count.

$messages : array<string|int, mixed>

message.

$type : string

type of notice, whether it is for expiring or expired subscription.

Return values
array<string|int, mixed>notice data to return. Contains type, parsed_message and product_id.

install_and_activate_plugins_async_callback()

Callback regsitered by OnboardingPlugins::install_and_activate_async.

public static install_and_activate_plugins_async_callback(array<string|int, mixed> $plugins, string $job_id) : bool

It is used to call install_plugins and activate_plugins with a custom logger.

Parameters
$plugins : array<string|int, mixed>

A list of plugins to install.

$job_id : string

An unique job I.D.

Return values
bool

install_plugins()

Install an array of plugins.

public static install_plugins(array<string|int, mixed> $plugins[, PluginsInstallLogger|null $logger = null ]) : array<string|int, mixed>
Parameters
$plugins : array<string|int, mixed>

Plugins to install.

$logger : PluginsInstallLogger|null = null

an optional logger.

Return values
array<string|int, mixed>

is_plugin_active()

Checks if a plugin is active.

public static is_plugin_active(string $plugin) : bool
Parameters
$plugin : string

Path to the plugin file relative to the plugins directory or the plugin directory name.

Return values
bool

is_plugin_installed()

Checks if a plugin is installed.

public static is_plugin_installed(string $plugin) : bool
Parameters
$plugin : string

Path to the plugin file relative to the plugins directory or the plugin directory name.

Return values
bool

maybe_enqueue_scripts_for_connect_notice()

Enqueue scripts for connect notice in WooCommerce settings page.

public static maybe_enqueue_scripts_for_connect_notice() : void
Return values
void

maybe_enqueue_scripts_for_notices_in_plugins()

Enqueue scripts for notices in plugin list page.

public static maybe_enqueue_scripts_for_notices_in_plugins() : void
Return values
void

maybe_enqueue_scripts_for_subscription_notice()

Enqueue scripts for woo subscription notice.

public static maybe_enqueue_scripts_for_subscription_notice() : void
Return values
void

maybe_show_connect_notice_in_plugin_list()

Show notices to connect to woocommerce.com for unconnected store in the plugin list.

public static maybe_show_connect_notice_in_plugin_list() : void
Return values
void

maybe_show_expired_subscriptions_notice()

Show notice about to expired subscription on WC settings page.

public static maybe_show_expired_subscriptions_notice() : void
Return values
void

maybe_show_expiring_subscriptions_notice()

Show notice about to expiring subscription on WC settings page.

public static maybe_show_expiring_subscriptions_notice() : void
Return values
void

schedule_activate_plugins()

Schedule plugin activation.

public static schedule_activate_plugins(array<string|int, mixed> $plugins) : string
Parameters
$plugins : array<string|int, mixed>

Plugins to activate.

Return values
stringJob ID.

schedule_install_plugins()

Schedule plugin installation.

public static schedule_install_plugins(array<string|int, mixed> $plugins) : string
Parameters
$plugins : array<string|int, mixed>

Plugins to install.

Return values
stringJob ID.

should_show_notice()

Determine whether a specific notice should be shown to the current user.

public static should_show_notice(string $dismiss_notice_meta) : bool
Parameters
$dismiss_notice_meta : string

User meta that includes the timestamp when a store notice was dismissed.

Return values
boolTrue if the notice should be shown, false otherwise.