PSR-4ify the feature loading classes.

This commit is contained in:
Jeff Stieler 2019-08-01 12:17:08 -06:00
parent ce7267b198
commit 55400474ee
7 changed files with 18 additions and 6 deletions

View File

@ -9,6 +9,8 @@
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\Features\WC_Admin_Onboarding;
/**
* Onboarding Profile controller.
*

View File

@ -130,7 +130,7 @@ class WC_Admin_Loader {
$features = self::get_features();
foreach ( $features as $feature ) {
$feature = strtolower( str_replace( '-', '_', $feature ) );
$feature = 'WC_Admin_' . ucwords( $feature, '_' );
$feature = 'Automattic\WooCommerce\Admin\Features\WC_Admin_' . ucwords( $feature, '_' );
if ( class_exists( $feature ) ) {
new $feature;

View File

@ -6,6 +6,8 @@
* @package Woocommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Features;
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes;
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Settings_Notes;

View File

@ -6,6 +6,8 @@
* @package Woocommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Features;
/**
* Contains backend logic for the Analytics feature.
*/

View File

@ -6,6 +6,8 @@
* @package Woocommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Features;
/**
* Contains backend logic for the dashboard feature.
*/

View File

@ -6,6 +6,8 @@
* @package Woocommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Features;
/**
* Contains backend logic for the onboarding profile and checklist feature.
*/
@ -228,9 +230,9 @@ class WC_Admin_Onboarding {
}
foreach ( $themes as $theme ) {
$directory = new RecursiveDirectoryIterator( $theme->theme_root . '/' . $theme->stylesheet );
$iterator = new RecursiveIteratorIterator( $directory );
$files = new RegexIterator( $iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH );
$directory = new \RecursiveDirectoryIterator( $theme->theme_root . '/' . $theme->stylesheet );
$iterator = new \RecursiveIteratorIterator( $directory );
$files = new \RegexIterator( $iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH );
foreach ( $files as $file ) {
$content = file_get_contents( $file[0] );
@ -361,14 +363,14 @@ class WC_Admin_Onboarding {
*/
public static function reset_onboarding() {
if (
! WC_Admin_Loader::is_admin_page() ||
! \WC_Admin_Loader::is_admin_page() ||
! isset( $_GET['reset_onboarding'] ) || // WPCS: CSRF ok.
1 !== absint( $_GET['reset_onboarding'] ) // WPCS: CSRF ok.
) {
return;
}
$request = new WP_REST_Request( 'POST', '/wc-admin/v1/onboarding/profile' );
$request = new \WP_REST_Request( 'POST', '/wc-admin/v1/onboarding/profile' );
$request->set_headers( array( 'content-type' => 'application/json' ) );
$request->set_body(
wp_json_encode(

View File

@ -6,6 +6,8 @@
* @package Woocommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Features;
/**
* Contains the logic for completing onboarding tasks.
*/