WooCommerce Code Reference

PluginUtil
in package
Uses AccessiblePrivateMethods

A class of utilities for dealing with plugins.

Table of Contents

$proxy  : LegacyProxy
The LegacyProxy instance to use.
$woocommerce_aware_active_plugins  : null|array<string|int, mixed>
The cached list of enabled WooCommerce aware plugin ids.
$woocommerce_aware_plugins  : null|array<string|int, mixed>
The cached list of WooCommerce aware plugin ids.
__construct()  : mixed
Creates a new instance of the class.
generate_incompatible_plugin_feature_warning()  : string
Util function to generate warning string for incompatible features based on active plugins.
get_plugin_name()  : string
Get the printable name of a plugin.
get_woocommerce_aware_plugins()  : array<string|int, string>
Get a list with the names of the WordPress plugins that are WooCommerce aware (they have a "WC tested up to" header).
get_wp_plugin_id()  : string|false
Match plugin identifier passed as a parameter with the output from `get_plugins()`.
is_woocommerce_aware_plugin()  : bool
Check if a plugin is WooCommerce aware.
handle_plugin_de_activation()  : void
Handle plugin activation and deactivation by clearing the WooCommerce aware plugin ids cache.

Properties

$woocommerce_aware_active_plugins

The cached list of enabled WooCommerce aware plugin ids.

private null|array<string|int, mixed> $woocommerce_aware_active_plugins = null

$woocommerce_aware_plugins

The cached list of WooCommerce aware plugin ids.

private null|array<string|int, mixed> $woocommerce_aware_plugins = null

Methods

generate_incompatible_plugin_feature_warning()

Util function to generate warning string for incompatible features based on active plugins.

public generate_incompatible_plugin_feature_warning(string $feature_id, array<string|int, mixed> $plugin_feature_info) : string
Parameters
$feature_id : string

Feature id.

$plugin_feature_info : array<string|int, mixed>

Array of plugin feature info. See FeaturesControllers->get_compatible_plugins_for_feature() for details.

Return values
stringWarning string.

get_plugin_name()

Get the printable name of a plugin.

public get_plugin_name(string $plugin_id) : string
Parameters
$plugin_id : string

Plugin id (path/file.php).

Return values
stringPrintable plugin name, or the plugin id itself if printable name is not available.

get_woocommerce_aware_plugins()

Get a list with the names of the WordPress plugins that are WooCommerce aware (they have a "WC tested up to" header).

public get_woocommerce_aware_plugins([bool $active_only = false ]) : array<string|int, string>
Parameters
$active_only : bool = false

True to return only active plugins, false to return all the active plugins.

Return values
array<string|int, string>A list of plugin ids (path/file.php).

get_wp_plugin_id()

Match plugin identifier passed as a parameter with the output from `get_plugins()`.

public get_wp_plugin_id(string $plugin_file) : string|false
Parameters
$plugin_file : string

Plugin identifier, either 'my-plugin/my-plugin.php', or output from FILE.

Return values
string|falseKey from the array returned by `get_plugins` if matched. False if no match.

is_woocommerce_aware_plugin()

Check if a plugin is WooCommerce aware.

public is_woocommerce_aware_plugin(string|array<string|int, mixed> $plugin_file_or_data) : bool
Parameters
$plugin_file_or_data : string|array<string|int, mixed>

Plugin id (path/file.php) or plugin data (as returned by get_plugins).

Tags
throws
Exception

The input is neither a string nor an array.

Return values
boolTrue if the plugin exists and is WooCommerce aware.

handle_plugin_de_activation()

Handle plugin activation and deactivation by clearing the WooCommerce aware plugin ids cache.

private handle_plugin_de_activation() : void
Return values
void