Updates to repair issues when using composer 2 resulting in the Navigation class not being loaded (https://github.com/woocommerce/woocommerce-admin/pull/5510)
Composer 2 utilizes stricter conventions, so this fix involved repairing the namespace for the Navigation class, and adding a mechanism to load features that are contained within subdirectories.
This commit is contained in:
parent
aaaa82779b
commit
8659fabca7
|
@ -5,7 +5,7 @@
|
|||
* @package Woocommerce Admin
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Features;
|
||||
namespace Automattic\WooCommerce\Admin\Features\Navigation;
|
||||
|
||||
use Automattic\WooCommerce\Admin\Loader;
|
||||
use Automattic\WooCommerce\Admin\Features\Navigation\Screen;
|
||||
|
@ -15,7 +15,7 @@ use Automattic\WooCommerce\Admin\Features\Navigation\CoreMenu;
|
|||
/**
|
||||
* Contains logic for the Navigation
|
||||
*/
|
||||
class Navigation {
|
||||
class Init {
|
||||
/**
|
||||
* Hook into WooCommerce.
|
||||
*/
|
|
@ -225,11 +225,16 @@ class Loader {
|
|||
public static function load_features() {
|
||||
$features = self::get_features();
|
||||
foreach ( $features as $feature ) {
|
||||
$feature = str_replace( '-', '', ucwords( strtolower( $feature ), '-' ) );
|
||||
$feature = 'Automattic\\WooCommerce\\Admin\\Features\\' . $feature;
|
||||
$feature = str_replace( '-', '', ucwords( strtolower( $feature ), '-' ) );
|
||||
$feature_class = 'Automattic\\WooCommerce\\Admin\\Features\\' . $feature;
|
||||
|
||||
if ( class_exists( $feature ) ) {
|
||||
new $feature();
|
||||
// Handle features contained in subdirectory.
|
||||
if ( ! class_exists( $feature_class ) && class_exists( $feature_class . '\\Init' ) ) {
|
||||
$feature_class = $feature_class . '\\Init';
|
||||
}
|
||||
|
||||
if ( class_exists( $feature_class ) ) {
|
||||
new $feature_class();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue