Cherry-pick PR#50881 into trunk (#50897)
* Revert "PluginUtil: Add method to get active valid plugins (#48709)"
This reverts commit 4d68cd486e
.
* Reintroduce get_all_active_valid_plugins public function after revert (#50885)
Retroduce get_all_active_valid_plugins public function after revert
---------
Co-authored-by: Naman Malhotra <naman03malhotra@gmail.com>
This commit is contained in:
parent
06f441fde6
commit
ae6c278e53
|
@ -17,7 +17,7 @@ use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Synchro
|
||||||
use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
|
use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
|
||||||
use Automattic\WooCommerce\Internal\WCCom\ConnectionHelper as WCConnectionHelper;
|
use Automattic\WooCommerce\Internal\WCCom\ConnectionHelper as WCConnectionHelper;
|
||||||
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
|
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
|
||||||
use Automattic\WooCommerce\Utilities\{ OrderUtil, PluginUtil };
|
use Automattic\WooCommerce\Utilities\OrderUtil;
|
||||||
use Automattic\WooCommerce\Internal\Utilities\PluginInstaller;
|
use Automattic\WooCommerce\Internal\Utilities\PluginInstaller;
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
@ -1283,8 +1283,7 @@ class WC_Install {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$active_valid_plugins = wc_get_container()->get( PluginUtil::class )->get_all_active_valid_plugins();
|
if ( in_array( $legacy_api_plugin, wp_get_active_and_valid_plugins(), true ) ) {
|
||||||
if ( in_array( $legacy_api_plugin, $active_valid_plugins, true ) ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ defined( 'ABSPATH' ) || exit;
|
||||||
use Automattic\WooCommerce\Internal\WCCom\ConnectionHelper;
|
use Automattic\WooCommerce\Internal\WCCom\ConnectionHelper;
|
||||||
use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Register as Download_Directories;
|
use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Register as Download_Directories;
|
||||||
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer as Order_DataSynchronizer;
|
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer as Order_DataSynchronizer;
|
||||||
use Automattic\WooCommerce\Utilities\{ LoggingUtil, OrderUtil, PluginUtil };
|
use Automattic\WooCommerce\Utilities\{ LoggingUtil, OrderUtil };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System status controller class.
|
* System status controller class.
|
||||||
|
@ -1044,11 +1044,16 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$active_valid_plugins = wc_get_container()->get( PluginUtil::class )->get_all_active_valid_plugins();
|
$active_plugins = (array) get_option( 'active_plugins', array() );
|
||||||
|
if ( is_multisite() ) {
|
||||||
|
$network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
|
||||||
|
$active_plugins = array_merge( $active_plugins, $network_activated_plugins );
|
||||||
|
}
|
||||||
|
|
||||||
$active_plugins_data = array();
|
$active_plugins_data = array();
|
||||||
|
|
||||||
foreach ( $active_valid_plugins as $plugin ) {
|
foreach ( $active_plugins as $plugin ) {
|
||||||
$data = get_plugin_data( $plugin );
|
$data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
||||||
$active_plugins_data[] = $this->format_plugin_data( $plugin, $data );
|
$active_plugins_data[] = $this->format_plugin_data( $plugin, $data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace Automattic\WooCommerce\Internal\Utilities;
|
||||||
|
|
||||||
use Automattic\WooCommerce\Internal\RegisterHooksInterface;
|
use Automattic\WooCommerce\Internal\RegisterHooksInterface;
|
||||||
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
|
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
|
||||||
use Automattic\WooCommerce\Utilities\{ PluginUtil, StringUtil };
|
use Automattic\WooCommerce\Utilities\StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class allows installing a plugin programmatically.
|
* This class allows installing a plugin programmatically.
|
||||||
|
@ -206,14 +206,7 @@ class PluginInstaller implements RegisterHooksInterface {
|
||||||
* @return bool True if WooCommerce is installed and active in the current blog, false otherwise.
|
* @return bool True if WooCommerce is installed and active in the current blog, false otherwise.
|
||||||
*/
|
*/
|
||||||
private static function woocommerce_is_active_in_current_site(): bool {
|
private static function woocommerce_is_active_in_current_site(): bool {
|
||||||
$active_valid_plugins = wc_get_container()->get( PluginUtil::class )->get_all_active_valid_plugins();
|
return ! empty( array_filter( wp_get_active_and_valid_plugins(), fn( $plugin ) => substr_compare( $plugin, '/woocommerce.php', -strlen( '/woocommerce.php' ) ) === 0 ) );
|
||||||
|
|
||||||
return ! empty(
|
|
||||||
array_filter(
|
|
||||||
$active_valid_plugins,
|
|
||||||
fn( $plugin ) => substr_compare( $plugin, '/woocommerce.php', -strlen( '/woocommerce.php' ) ) === 0
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue