Automattic\WooCommerce\Utilities

PluginUtil::get_all_active_valid_plugins()publicWC 1.0

Wrapper for WP's private wp_get_active_and_valid_plugins and wp_get_active_network_plugins functions.

This combines the results of the two functions to get a list of all plugins that are active within a site. It's more useful than just retrieving the option values because it also validates that the plugin files exist. This wrapper is also a hedge against backward-incompatible changes since both of the WP methods are marked as being "@access private", so if need be we can update our methods here to preserve functionality.

Note that the doc block for wp_get_active_and_valid_plugins says it returns "Array of paths to plugin files relative to the plugins directory", but it actually returns absolute paths.

Method of the class: PluginUtil{}

No Hooks.

Return

String[]. Array of absolute paths to plugin files.

Usage

$PluginUtil = new PluginUtil();
$PluginUtil->get_all_active_valid_plugins();

PluginUtil::get_all_active_valid_plugins() code WC 9.3.3

public function get_all_active_valid_plugins() {
	$local = wp_get_active_and_valid_plugins();

	if ( is_multisite() ) {
		require_once ABSPATH . WPINC . '/ms-load.php';
		$network = wp_get_active_network_plugins();
	} else {
		$network = array();
	}

	$all = array_merge( $local, $network );

	return array_unique( $all );
}