diff --git a/bootstrap.php b/bootstrap.php index c74529b12..f51bf731e 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -10,35 +10,35 @@ * @return void */ function nfd_wp_module_onboarding_register() { -// wp-module-onboarding + // wp-module-onboarding register( array( - 'name' => 'onboarding', - 'label' => __('Onboarding', 'wp-module-onboarding' ), - 'callback' => function ( Container $container ) { + 'name' => 'onboarding', + 'label' => __( 'Onboarding', 'wp-module-onboarding' ), + 'callback' => function ( Container $container ) { - // Set Global Constants - if ( ! defined( 'NFD_ONBOARDING_VERSION' ) ) { - define( 'NFD_ONBOARDING_VERSION', '1.0.1' ); - } - if ( ! defined( 'NFD_ONBOARDING_DIR' ) ) { - define( 'NFD_ONBOARDING_DIR', __DIR__ ); - } - if ( ! defined( 'NFD_ONBOARDING_BUILD_DIR' ) && defined('NFD_ONBOARDING_VERSION') ) { - define( 'NFD_ONBOARDING_BUILD_DIR', __DIR__ . '/build/' . NFD_ONBOARDING_VERSION ); - } - if ( ! defined( 'NFD_MODULE_DATA_EVENTS_API' ) ) { - define( 'NFD_MODULE_DATA_EVENTS_API', '/newfold-data/v1/events' ); - } - if ( ! defined( 'NFD_ONBOARDING_BUILD_URL' && defined('NFD_ONBOARDING_VERSION') ) ) { - define( 'NFD_ONBOARDING_BUILD_URL', BLUEHOST_PLUGIN_URL . '/vendor/newfold-labs/wp-module-onboarding/build/' . NFD_ONBOARDING_VERSION ); - } - // Instantiate Onboarding Module Application + // Set Global Constants + if ( ! defined( 'NFD_ONBOARDING_VERSION' ) ) { + define( 'NFD_ONBOARDING_VERSION', '1.0.1' ); + } + if ( ! defined( 'NFD_ONBOARDING_DIR' ) ) { + define( 'NFD_ONBOARDING_DIR', __DIR__ ); + } + if ( ! defined( 'NFD_ONBOARDING_BUILD_DIR' ) && defined( 'NFD_ONBOARDING_VERSION' ) ) { + define( 'NFD_ONBOARDING_BUILD_DIR', __DIR__ . '/build/' . NFD_ONBOARDING_VERSION ); + } + if ( ! defined( 'NFD_MODULE_DATA_EVENTS_API' ) ) { + define( 'NFD_MODULE_DATA_EVENTS_API', '/newfold-data/v1/events' ); + } + if ( ! defined( 'NFD_ONBOARDING_BUILD_URL' && defined( 'NFD_ONBOARDING_VERSION' ) ) ) { + define( 'NFD_ONBOARDING_BUILD_URL', BLUEHOST_PLUGIN_URL . '/vendor/newfold-labs/wp-module-onboarding/build/' . NFD_ONBOARDING_VERSION ); + } + // Instantiate Onboarding Module Application new Application( $container ); }, - - 'isActive' => true, - 'isHidden' => true, + + 'isActive' => true, + 'isHidden' => true, ) ); } diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index af78fd395..fbad16d7d 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -10,96 +10,96 @@ public static function get_brands() { return array( 'bluehost' => array( - 'brand' => 'bluehost', - 'name' => 'Bluehost', - 'url' => 'https://bluehost.com', - 'knowledgeBaseUrl' => 'https://www.bluehost.com/help/results/wordpress', - 'helpUrl' => 'https://www.bluehost.com/help', - 'blogUrl' => 'https://www.bluehost.com/blog/', - 'facebookUrl' => 'https://www.facebook.com/bluehost', - 'twitterName' => '@bluehost', - 'twitterUrl' => 'https://twitter.com/bluehost', - 'youtubeUrl' => 'https://www.youtube.com/user/bluehost', - 'linkedinUrl' => 'https://www.linkedin.com/company/bluehost-com', - 'accountUrl' => 'https://my.bluehost.com', - 'domainsUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/domains', - 'emailUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/email-office', - 'hireExpertsInfo' => array( - 'defaultLink' => 'admin.php?', - 'fragment' => '#/marketplace/services/blue-sky', - 'queryParameters' => array( - 'page' => 'bluehost', - 'utm_source' => 'onboarding', - 'utm_medium' => 'wp_admin', - 'utm_campaign' => 'wp-setup' + 'brand' => 'bluehost', + 'name' => 'Bluehost', + 'url' => 'https://bluehost.com', + 'knowledgeBaseUrl' => 'https://www.bluehost.com/help/results/wordpress', + 'helpUrl' => 'https://www.bluehost.com/help', + 'blogUrl' => 'https://www.bluehost.com/blog/', + 'facebookUrl' => 'https://www.facebook.com/bluehost', + 'twitterName' => '@bluehost', + 'twitterUrl' => 'https://twitter.com/bluehost', + 'youtubeUrl' => 'https://www.youtube.com/user/bluehost', + 'linkedinUrl' => 'https://www.linkedin.com/company/bluehost-com', + 'accountUrl' => 'https://my.bluehost.com', + 'domainsUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/domains', + 'emailUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/email-office', + 'hireExpertsInfo' => array( + 'defaultLink' => 'admin.php?', + 'fragment' => '#/marketplace/services/blue-sky', + 'queryParameters' => array( + 'page' => 'bluehost', + 'utm_source' => 'onboarding', + 'utm_medium' => 'wp_admin', + 'utm_campaign' => 'wp-setup', ), ), - 'expertsInfo' => array( - 'defaultLink' => 'https://my.bluehost.com/cgi/app/#/marketplace/product/i/bluesky', - 'queryParams' => array( - 'utm_source' => 'wp-onboarding', - 'utm_medium' => 'brand-plugin', + 'expertsInfo' => array( + 'defaultLink' => 'https://my.bluehost.com/cgi/app/#/marketplace/product/i/bluesky', + 'queryParams' => array( + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', ), ), 'fullServiceCreativeTeamInfo' => array( - 'defaultLink' => 'https://www.bluehost.com/solutions/full-service', - 'fragment' => '#full-service', - 'queryParams' => array( - 'utm_source' => 'wp-onboarding', - 'utm_medium' => 'brand-plugin', + 'defaultLink' => 'https://www.bluehost.com/solutions/full-service', + 'fragment' => '#full-service', + 'queryParams' => array( + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', ), ), - 'techSupportInfo' => array( - 'defaultLink' => 'https://helpchat.bluehost.com/', - 'queryParams' => array( - 'utm_source' => 'wp-onboarding', - 'utm_medium' => 'brand-plugin', + 'techSupportInfo' => array( + 'defaultLink' => 'https://helpchat.bluehost.com/', + 'queryParams' => array( + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', ), ), ), 'bluehost-india' => array( - 'brand' => 'bluehost-india', - 'name' => 'Bluehost', - 'url' => 'https://bluehost.in', - 'knowledgeBaseUrl' => 'https://www.bluehost.in/hosting/help/results/wordpress', - 'helpUrl' => 'https://www.bluehost.in/hosting/help', - 'blogUrl' => 'https://www.bluehost.in/tutorials', - 'facebookUrl' => 'https://www.facebook.com/BlueHostIndia', - 'twitterName' => '@BluehostIndia', - 'twitterUrl' => 'https://twitter.com/bluehostindia', - 'youtubeUrl' => null, - 'linkedinUrl' => null, - 'accountUrl' => 'https://my.bluehost.in', - 'domainsUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/domains', - 'emailUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/email-office', - 'hireExpertsInfo' => array( - 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', - 'utmParameters' => array( - 'utm_source' => 'blog', - 'utm_medium' => 'socialmedia', - 'utm_campaign' => 'blogpost' - ) + 'brand' => 'bluehost-india', + 'name' => 'Bluehost', + 'url' => 'https://bluehost.in', + 'knowledgeBaseUrl' => 'https://www.bluehost.in/hosting/help/results/wordpress', + 'helpUrl' => 'https://www.bluehost.in/hosting/help', + 'blogUrl' => 'https://www.bluehost.in/tutorials', + 'facebookUrl' => 'https://www.facebook.com/BlueHostIndia', + 'twitterName' => '@BluehostIndia', + 'twitterUrl' => 'https://twitter.com/bluehostindia', + 'youtubeUrl' => null, + 'linkedinUrl' => null, + 'accountUrl' => 'https://my.bluehost.in', + 'domainsUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/domains', + 'emailUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/email-office', + 'hireExpertsInfo' => array( + 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', + 'utmParameters' => array( + 'utm_source' => 'blog', + 'utm_medium' => 'socialmedia', + 'utm_campaign' => 'blogpost', + ), ), - 'expertsInfo' => array( - 'defaultLink' => 'https://my.bluehost.in/cgi/app/#/marketplace/product/i/bluesky', - 'queryParams' => array( - 'utm_source' => 'wp-onboarding', - 'utm_medium' => 'brand-plugin', + 'expertsInfo' => array( + 'defaultLink' => 'https://my.bluehost.in/cgi/app/#/marketplace/product/i/bluesky', + 'queryParams' => array( + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', ), ), 'fullServiceCreativeTeamInfo' => array( - 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', - 'fragment' => '#full-service', - 'queryParams' => array( - 'utm_source' => 'wp-onboarding', - 'utm_medium' => 'brand-plugin', + 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', + 'fragment' => '#full-service', + 'queryParams' => array( + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', ), ), - 'techSupportInfo' => array( - 'defaultLink' => 'https://helpchat.bluehost.in/', - 'queryParams' => array( - 'utm_source' => 'wp-onboarding', - 'utm_medium' => 'brand-plugin', + 'techSupportInfo' => array( + 'defaultLink' => 'https://helpchat.bluehost.in/', + 'queryParams' => array( + 'utm_source' => 'wp-onboarding', + 'utm_medium' => 'brand-plugin', ), ), ), diff --git a/includes/Data/Events.php b/includes/Data/Events.php index e9e92c6af..0b0a2b5d5 100644 --- a/includes/Data/Events.php +++ b/includes/Data/Events.php @@ -1,21 +1,20 @@ array( - 'category' => 'Admin', - 'action' => 'pageview', + // Contains a list of events with the key being the event slug. + protected static $events = array( + 'nfd-module-onboarding-event-pageview' => array( + 'category' => 'Admin', + 'action' => 'pageview', ), - ); + ); - public static function get_event( $event_slug ) { - return self::$events[ $event_slug ] ? self::$events[ $event_slug ] : false; - } + public static function get_event( $event_slug ) { + return self::$events[ $event_slug ] ? self::$events[ $event_slug ] : false; + } } diff --git a/includes/Data/Patterns.php b/includes/Data/Patterns.php index 86df2abca..caa6f5e1b 100644 --- a/includes/Data/Patterns.php +++ b/includes/Data/Patterns.php @@ -96,7 +96,7 @@ protected static function get_theme_step_patterns() { 'shown' => true, ), ), - 'site-features' => SiteFeatures::get_site_features()[Data::current_flow()] + 'site-features' => SiteFeatures::get_site_features()[ Data::current_flow() ], ), ); } diff --git a/includes/Data/Plugins.php b/includes/Data/Plugins.php index 711c1a4eb..c6c6a0e8b 100644 --- a/includes/Data/Plugins.php +++ b/includes/Data/Plugins.php @@ -13,35 +13,35 @@ final class Plugins { */ protected static $wp_slugs = array( - 'jetpack' => array( + 'jetpack' => array( 'approved' => true, 'path' => 'jetpack/jetpack.php', ), - 'woocommerce' => array( + 'woocommerce' => array( 'approved' => true, 'path' => 'woocommerce/woocommerce.php', ), - 'wordpress-seo' => array( + 'wordpress-seo' => array( 'approved' => true, 'path' => 'wordpress-seo/wp-seo.php', ), - 'wpforms-lite' => array( + 'wpforms-lite' => array( 'approved' => true, 'path' => 'wpforms-lite/wpforms.php', ), - 'google-analytics-for-wordpress' => array( + 'google-analytics-for-wordpress' => array( 'approved' => true, 'path' => 'google-analytics-for-wordpress/googleanalytics.php', ), - 'optinmonster' => array( + 'optinmonster' => array( 'approved' => true, 'path' => 'optinmonster/optin-monster-wp-api.php', ), - 'yith-woocommerce-ajax-search' => array( + 'yith-woocommerce-ajax-search' => array( 'approved' => true, 'path' => 'yith-woocommerce-ajax-search/init.php', ), - 'creative-mail-by-constant-contact' => array( + 'creative-mail-by-constant-contact' => array( 'approved' => true, 'path' => 'creative-mail-by-constant-contact/creative-mail-plugin.php', ), @@ -240,8 +240,8 @@ public static function get() { */ public static function get_squashed() { return array_merge( - array_filter( self::$wp_slugs, array( __CLASS__, 'check_approved' ) ) , - array_filter( self::$nfd_slugs, array( __CLASS__, 'check_approved' ) ) , + array_filter( self::$wp_slugs, array( __CLASS__, 'check_approved' ) ), + array_filter( self::$nfd_slugs, array( __CLASS__, 'check_approved' ) ), ); } diff --git a/includes/Data/SiteFeatures.php b/includes/Data/SiteFeatures.php index a0e9afddf..dbe4c1725 100644 --- a/includes/Data/SiteFeatures.php +++ b/includes/Data/SiteFeatures.php @@ -1,15 +1,15 @@ array(), + 'wp-setup' => array(), 'ecommerce' => array( 'jetpack' => array( 'slug' => 'jetpack', diff --git a/includes/Data/Themes.php b/includes/Data/Themes.php index 5a8638b28..05508bb08 100644 --- a/includes/Data/Themes.php +++ b/includes/Data/Themes.php @@ -23,8 +23,8 @@ final class Themes { // This is temporary, as we implement theme selections we can remove this. protected static $flow_default_theme_slugs = array( - 'wp-setup' => 'twentytwentythree', - 'ecommerce' => 'yith-wonder', + 'wp-setup' => 'twentytwentythree', + 'ecommerce' => 'yith-wonder', ); /** diff --git a/includes/ModuleController.php b/includes/ModuleController.php index 23be63dc5..ee4d4cb31 100644 --- a/includes/ModuleController.php +++ b/includes/ModuleController.php @@ -10,11 +10,10 @@ /** * Class ModuleController - * */ class ModuleController { - /** + /** * Initialize the Module Controller functionality. */ public static function init() { @@ -22,44 +21,43 @@ public static function init() { add_action( 'after_setup_theme', array( __CLASS__, 'module_switcher' ), 10, 0 ); } - /** + /** * Check if the user is a valid Ecommerce and subsequently enable/disable modules */ public static function module_switcher() { - $module_name = 'onboarding'; - $customer_data = Data::customer_data(); + $module_name = 'onboarding'; + $customer_data = Data::customer_data(); // Sample data for Testing - // $customer_data['plan_subtype'] = 'wc_standard'; - // $customer_data['signup_date'] = '2022-08-18T15:30:00.000Z'; + // $customer_data['plan_subtype'] = 'wc_standard'; + // $customer_data['signup_date'] = '2022-08-18T15:30:00.000Z'; // Check if he is a Non-Ecom Cust and Disable Redirect and Module - if( !self::is_ecom_customer( $customer_data ) ){ + if ( ! self::is_ecom_customer( $customer_data ) ) { // Check if the Module Does Exist - if( ModuleRegistry::get( $module_name ) ){ + if ( ModuleRegistry::get( $module_name ) ) { // Disable the Redirect for Onboarding SPA - LoginRedirect::disable_redirect(); + LoginRedirect::disable_redirect(); // Deactivate the Module deactivate( $module_name ); } - } - else { + } else { // Check if the Module Does Exist - if( ModuleRegistry::get( $module_name ) ){ - + if ( ModuleRegistry::get( $module_name ) ) { + // Enable the Redirect for Onboarding SPA - LoginRedirect::enable_redirect(); + LoginRedirect::enable_redirect(); // Activate the Module activate( $module_name ); } } - + } /** @@ -68,26 +66,26 @@ public static function module_switcher() { * @return bool */ public static function is_ecom_customer( $customer_data ) { - + if ( isset( $_GET['flow'] ) && 'ecommerce' === \sanitize_text_field( $_GET['flow'] ) ) { - return true; + return true; } // August 18 - $new_cust_date = date("Y-m-d H:i:s", strtotime('2022-08-18T15:30:00.000Z')); - + $new_cust_date = date( 'Y-m-d H:i:s', strtotime( '2022-08-18T15:30:00.000Z' ) ); + if ( isset( $customer_data['plan_subtype'] ) && isset( $customer_data['signup_date'] ) ) { - + // Convert the Customer Signup Date to a Php known format - $cust_signup_date = date("Y-m-d H:i:s", strtotime( $customer_data['signup_date'] )); + $cust_signup_date = date( 'Y-m-d H:i:s', strtotime( $customer_data['signup_date'] ) ); // Check if the Customer is a new Customer $is_new_cust = $cust_signup_date >= $new_cust_date; - + // Check if the Customer has an Ecom Plan - $has_ecom_plan = Flows::get_flow_from_plan_subtype( $customer_data['plan_subtype'] ) === "ecommerce"; + $has_ecom_plan = Flows::get_flow_from_plan_subtype( $customer_data['plan_subtype'] ) === 'ecommerce'; - if( $has_ecom_plan && $is_new_cust ){ + if ( $has_ecom_plan && $is_new_cust ) { return true; } } @@ -95,4 +93,4 @@ public static function is_ecom_customer( $customer_data ) { // If the Customer is not a Ecommerce Customer or is an Old Customer return false; } -} \ No newline at end of file +} diff --git a/includes/Mustache/Mustache.php b/includes/Mustache/Mustache.php index 8cdab9a7e..d1d03dd01 100644 --- a/includes/Mustache/Mustache.php +++ b/includes/Mustache/Mustache.php @@ -18,11 +18,11 @@ function __construct() { /** * @param string $template_name - * @param array $data - * + * @param array $data + * * @return string */ public function render_template( $template_name, $data ) { - return $this->mustache_engine->loadTemplate( $template_name )->render( $data ); + return $this->mustache_engine->loadTemplate( $template_name )->render( $data ); } } diff --git a/includes/Permissions.php b/includes/Permissions.php index 1ffa275a0..a11b94157 100644 --- a/includes/Permissions.php +++ b/includes/Permissions.php @@ -27,7 +27,7 @@ public static function rest_verify_plugin_install_hash( $hash ) { * @return boolean */ public static function rest_is_authorized_admin() { - return \is_user_logged_in() && \current_user_can( Permissions::ADMIN ); + return \is_user_logged_in() && \current_user_can( self::ADMIN ); } /** @@ -41,8 +41,8 @@ public static function is_authorized_admin() { public static function rest_can_manage_themes() { return \is_user_logged_in() && - \current_user_can( Permissions::INSTALL_THEMES ) && - \current_user_can( Permissions::EDIT_THEMES ); + \current_user_can( self::INSTALL_THEMES ) && + \current_user_can( self::EDIT_THEMES ); } /** @@ -51,7 +51,7 @@ public static function rest_can_manage_themes() { * @return boolean */ public static function custom_post_authorized_admin() { - return \current_user_can('edit_posts') && \current_user_can(Permissions::ADMIN); + return \current_user_can( 'edit_posts' ) && \current_user_can( self::ADMIN ); } } // END \NewfoldLabs\WP\Module\Onboarding\Permissions() diff --git a/includes/RestApi/EventsController.php b/includes/RestApi/EventsController.php index f55537bbd..2331e5e34 100644 --- a/includes/RestApi/EventsController.php +++ b/includes/RestApi/EventsController.php @@ -9,90 +9,90 @@ */ class EventsController extends \WP_REST_Controller { - /** - * @var string - */ - protected $namespace = 'newfold-onboarding/v1'; + /** + * @var string + */ + protected $namespace = 'newfold-onboarding/v1'; - /** - * @var string - */ - protected $rest_base = '/events'; + /** + * @var string + */ + protected $rest_base = '/events'; - /** - * Register REST routes for EventsController class. - * - * @return void - */ - public function register_routes() { - \register_rest_route( - $this->namespace, - $this->rest_base, - array( - array( - 'methods' => \WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'send_event' ), - 'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ), - 'args' => $this->get_send_event_args(), - ), - ) - ); - } + /** + * Register REST routes for EventsController class. + * + * @return void + */ + public function register_routes() { + \register_rest_route( + $this->namespace, + $this->rest_base, + array( + array( + 'methods' => \WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'send_event' ), + 'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ), + 'args' => $this->get_send_event_args(), + ), + ) + ); + } - /** - * Get args for the send_event endpoint. - * - * @return array - */ - public function get_send_event_args() { - return array( - 'slug' => array( - 'required' => true, - 'type' => 'string', - 'sanitize_callback' => 'sanitize_text_field', - ), - 'data' => array( - 'type' => 'object', - ), - ); - } + /** + * Get args for the send_event endpoint. + * + * @return array + */ + public function get_send_event_args() { + return array( + 'slug' => array( + 'required' => true, + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ), + 'data' => array( + 'type' => 'object', + ), + ); + } - /** - * Send events to the data module events API. - * - * @param \WP_REST_Request $request - * - * @return \WP_REST_Response|\WP_Error - */ - public function send_event( \WP_REST_Request $request ) { - $event = Events::get_event( $request->get_param( 'slug' ) ); + /** + * Send events to the data module events API. + * + * @param \WP_REST_Request $request + * + * @return \WP_REST_Response|\WP_Error + */ + public function send_event( \WP_REST_Request $request ) { + $event = Events::get_event( $request->get_param( 'slug' ) ); if ( ! $event ) { - return new \WP_Error( - 'event-error', - 'No such event found', - array( 'status' => 404 ) - ); - } + return new \WP_Error( + 'event-error', + 'No such event found', + array( 'status' => 404 ) + ); + } - $event['data'] = $request->get_param( 'data' ); + $event['data'] = $request->get_param( 'data' ); - if ( ! empty( $event['data'] ) && ! empty( $event['data']['stepID'] ) ) { - $event['data']['page'] = \admin_url( '/index.php?page=nfd-onboarding#' . $event['data']['stepID'] ); - } + if ( ! empty( $event['data'] ) && ! empty( $event['data']['stepID'] ) ) { + $event['data']['page'] = \admin_url( '/index.php?page=nfd-onboarding#' . $event['data']['stepID'] ); + } - $event_data_request = new \WP_REST_Request( - \WP_REST_Server::CREATABLE, - NFD_MODULE_DATA_EVENTS_API - ); - $event_data_request->set_body_params( $event ); - $response = \rest_do_request( $event_data_request ); - if ( $response->is_error() ) { - return $response->as_error(); - } + $event_data_request = new \WP_REST_Request( + \WP_REST_Server::CREATABLE, + NFD_MODULE_DATA_EVENTS_API + ); + $event_data_request->set_body_params( $event ); + $response = \rest_do_request( $event_data_request ); + if ( $response->is_error() ) { + return $response->as_error(); + } - return new \WP_REST_Response( - $response, - $response->status - ); - } + return new \WP_REST_Response( + $response, + $response->status + ); + } } diff --git a/includes/RestApi/RestApi.php b/includes/RestApi/RestApi.php index 905be7048..7342d8e67 100644 --- a/includes/RestApi/RestApi.php +++ b/includes/RestApi/RestApi.php @@ -20,7 +20,7 @@ final class RestApi { 'NewfoldLabs\\WP\\Module\\Onboarding\\RestApi\\SitePagesController', 'NewfoldLabs\WP\\Module\\Onboarding\\RestApi\\Themes\\ThemeInstallerController', 'NewfoldLabs\WP\\Module\\Onboarding\\RestApi\\Themes\\ThemeFontsController', - 'NewfoldLabs\WP\\Module\\Onboarding\\RestApi\\Themes\\ThemeColorsController' + 'NewfoldLabs\WP\\Module\\Onboarding\\RestApi\\Themes\\ThemeColorsController', ); public function __construct() { diff --git a/includes/RestApi/SettingsController.php b/includes/RestApi/SettingsController.php index 1663dbd4f..f26c3dcab 100644 --- a/includes/RestApi/SettingsController.php +++ b/includes/RestApi/SettingsController.php @@ -143,18 +143,18 @@ public function update_item( \WP_REST_Request $request ) { foreach ( $params as $param_key => $param_value ) { if ( ! array_key_exists( $param_key, $this->defaults ) ) { $this->invalid_urls[] = $param_key; - unset($params[$param_key]); + unset( $params[ $param_key ] ); continue; } // check for proper url if ( in_array( $param_key, $this->social_urls_to_validate ) ) { - switch($param_key) { + switch ( $param_key ) { case 'twitter_site': - if( !empty($params['twitter_site'])) { - if( ( $twitter_id = $this->validate_twitter_id($params['twitter_site']) ) === false ) { + if ( ! empty( $params['twitter_site'] ) ) { + if ( ( $twitter_id = $this->validate_twitter_id( $params['twitter_site'] ) ) === false ) { $this->invalid_urls[] = 'twitter_site'; - unset($params['twitter_site']); + unset( $params['twitter_site'] ); } else { $params['twitter_site'] = $twitter_id; } @@ -162,10 +162,10 @@ public function update_item( \WP_REST_Request $request ) { break; case 'other_social_urls': foreach ( $param_value as $param_key_osu => $param_url ) { - $param_value[ $param_key_osu ] = \sanitize_text_field( $param_url ); + $param_value[ $param_key_osu ] = \sanitize_text_field( $param_url ); if ( ! empty( $param_url ) && ! \wp_http_validate_url( $param_url ) ) { $this->invalid_urls[] = $param_key_osu; - unset($params[$param_key_osu]); + unset( $params[ $param_key_osu ] ); continue; } } @@ -174,7 +174,7 @@ public function update_item( \WP_REST_Request $request ) { $param[ $param_key ] = \sanitize_text_field( $param_value ); if ( ! empty( $param_value ) && ! \wp_http_validate_url( $param_value ) ) { $this->invalid_urls[] = $param_key; - unset($params[$param_key]); + unset( $params[ $param_key ] ); } break; } @@ -184,8 +184,8 @@ public function update_item( \WP_REST_Request $request ) { \update_option( $this->yoast_wp_options_key, $settings ); - if(!empty($this->invalid_urls)) { - $error_keys = implode( ", ", $this->invalid_urls ); + if ( ! empty( $this->invalid_urls ) ) { + $error_keys = implode( ', ', $this->invalid_urls ); return new \WP_Error( 'invalid_urls', "Invalid url(s) provided for {$error_keys}.", @@ -212,8 +212,8 @@ public function get_current_settings() { \add_option( $this->yoast_wp_options_key, $social_data ); } // add the full url for twitter cause only the handle is saved in the database - if( (!empty($social_data['twitter_site'])) && - ($twitter_handle = $this->validate_twitter_id($social_data['twitter_site'])) !== false ) { + if ( ( ! empty( $social_data['twitter_site'] ) ) && + ( $twitter_handle = $this->validate_twitter_id( $social_data['twitter_site'] ) ) !== false ) { $social_data['twitter_site'] = 'https://www.twitter.com/' . $twitter_handle; } diff --git a/includes/RestApi/Themes/ThemeInstallerController.php b/includes/RestApi/Themes/ThemeInstallerController.php index 89734e3cb..3a24ae8f8 100644 --- a/includes/RestApi/Themes/ThemeInstallerController.php +++ b/includes/RestApi/Themes/ThemeInstallerController.php @@ -31,8 +31,8 @@ public function register_routes() { $this->rest_base . '/initialize', array( array( - 'methods' => \WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'initialize' ), + 'methods' => \WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'initialize' ), 'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ), ), ) @@ -56,9 +56,9 @@ public function register_routes() { $this->rest_base . '/status', array( array( - 'methods' => \WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_status' ), - 'args' => $this->get_status_args(), + 'methods' => \WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_status' ), + 'args' => $this->get_status_args(), 'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ), ), ) diff --git a/includes/TaskManagers/PluginUninstallTaskManager.php b/includes/TaskManagers/PluginUninstallTaskManager.php index 666dfd381..1d0299b82 100644 --- a/includes/TaskManagers/PluginUninstallTaskManager.php +++ b/includes/TaskManagers/PluginUninstallTaskManager.php @@ -116,7 +116,7 @@ public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task PluginInstallTaskManager::remove_from_queue( $plugin_uninstall_task->get_slug(), ); - + return true; } @@ -124,8 +124,9 @@ public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task // Gets the specified path for the Plugin from the predefined list $plugin_path = $plugin_list[ $plugin_uninstall_task->get_slug() ]['path']; - if (!PluginUninstaller::is_plugin_installed($plugin_path)) + if ( ! PluginUninstaller::is_plugin_installed( $plugin_path ) ) { return true; + } $queue = new PriorityQueue(); foreach ( $plugins as $queued_plugin ) { diff --git a/includes/WP_Admin.php b/includes/WP_Admin.php index 62946b791..ca949a767 100644 --- a/includes/WP_Admin.php +++ b/includes/WP_Admin.php @@ -100,10 +100,10 @@ public static function register_assets() { $asset['version'] ); - wp_add_inline_script( - 'wp-blocks', - 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' - ); + wp_add_inline_script( + 'wp-blocks', + 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' + ); \wp_enqueue_script( self::$slug ); \wp_enqueue_style( self::$slug ); diff --git a/includes/WP_CLI.php b/includes/WP_CLI.php index 6213122f7..37f67fafd 100644 --- a/includes/WP_CLI.php +++ b/includes/WP_CLI.php @@ -5,11 +5,10 @@ * Register Commands with WP-CLI */ final class WP_CLI { - /** - * Tap WordPress Hooks - */ - public function __construct() - { - - } -} // END \NewfoldLabs\WP\Module\Onboarding\CLI() \ No newline at end of file + /** + * Tap WordPress Hooks + */ + public function __construct() { + + } +} // END \NewfoldLabs\WP\Module\Onboarding\CLI()