PluginUtil
in package
Uses
AccessiblePrivateMethods
A class of utilities for dealing with plugins.
Table of Contents
- $plugins_excluded_from_compatibility_ui : array<string|int, string>
- List of plugins excluded from feature compatibility warnings in UI.
- $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
- Utility method to generate warning string for incompatible features based on active plugins.
- get_plugin_name() : string
- Get the printable name of a plugin.
- get_plugins_excluded_from_compatibility_ui() : array<string|int, string>
- Get the names of the plugins that are excluded from the feature compatibility UI.
- 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
$plugins_excluded_from_compatibility_ui
List of plugins excluded from feature compatibility warnings in UI.
private
array<string|int, string>
$plugins_excluded_from_compatibility_ui
$proxy
The LegacyProxy instance to use.
private
LegacyProxy
$proxy
$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
__construct()
Creates a new instance of the class.
public
__construct() : mixed
Return values
mixed —generate_incompatible_plugin_feature_warning()
Utility method 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
Additionally, this method will manually print a warning message on the HPOS feature if both the Legacy REST API and HPOS are active.
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
string — Warning 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
string — Printable plugin name, or the plugin id itself if printable name is not available.get_plugins_excluded_from_compatibility_ui()
Get the names of the plugins that are excluded from the feature compatibility UI.
public
get_plugins_excluded_from_compatibility_ui() : array<string|int, string>
These plugins won't be considered as incompatible with any existing feature for the purposes of displaying compatibility warning in UI, even if they declare incompatibilities explicitly.
Return values
array<string|int, string> — Plugin names relative to the root plugins directory.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|false — Key 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
Return values
bool — True 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