From 21a1df390d69dd5cea67f3babef692c31604448d Mon Sep 17 00:00:00 2001 From: Yashita Date: Thu, 11 May 2023 21:44:59 +0530 Subject: [PATCH 01/10] PHP Lint fixes --- includes/Data/Brands.php | 8 +- includes/Data/Events.php | 29 ++-- includes/Data/Preview.php | 24 +++ includes/Data/Themes/Colors.php | 4 +- includes/Data/Themes/Fonts.php | 3 + includes/Mustache/Mustache.php | 6 +- includes/Permissions.php | 9 +- includes/RestApi/EventsController.php | 154 +++++++++--------- includes/RestApi/PluginsController.php | 1 - includes/Services/PluginInstaller.php | 45 +++-- includes/Services/PluginUninstaller.php | 12 +- includes/Services/ThemeInstaller.php | 39 +++-- .../PluginUninstallTaskManager.php | 3 +- includes/WP_CLI.php | 14 +- 14 files changed, 209 insertions(+), 142 deletions(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index d6518789a..ddc68b223 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -13,10 +13,10 @@ final class Brands { */ public static function get_default_brand() { $default_brand_data = array( - 'brand' => 'wordpress', - 'name' => __( 'your web host', 'wp-module-onboarding' ), - 'pluginDashboardPage' => \admin_url(), - 'hireExpertsInfo' => array( + 'brand' => 'wordpress', + 'name' => __( 'your web host', 'wp-module-onboarding' ), + 'pluginDashboardPage' => \admin_url(), + 'hireExpertsInfo' => array( 'defaultLink' => 'https://www.bluehost.com/wp-live', 'queryParameters' => array( 'page' => 'bluehost', diff --git a/includes/Data/Events.php b/includes/Data/Events.php index e9e92c6af..7dbdd3d4d 100644 --- a/includes/Data/Events.php +++ b/includes/Data/Events.php @@ -1,21 +1,30 @@ array( - 'category' => 'Admin', - 'action' => 'pageview', + /** + * Contains a list of events with the key being the event slug. + * + * @var array + */ + 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; - } + /** + * Retrieves the active theme color variations. + * + * @param array $event Event data. + * @return array|boolean + */ + public static function get_event( $event_slug ) { + return self::$events[ $event_slug ] ? self::$events[ $event_slug ] : false; + } } diff --git a/includes/Data/Preview.php b/includes/Data/Preview.php index c4f7930b8..3630cb463 100644 --- a/includes/Data/Preview.php +++ b/includes/Data/Preview.php @@ -4,12 +4,26 @@ use NewfoldLabs\WP\Module\Onboarding\Services\PluginInstaller; use NewfoldLabs\WP\Module\Onboarding\Services\ThemeInstaller; +/** + * Class Preview. + */ final class Preview { + /** + * Sets theme status. + * + * @param boolean $boolean Theme Active Status. + * @return string + */ private static function boolean_to_status( $boolean ) { return $boolean ? 'activated' : 'init'; } + /** + * Preview Pre-requisites Data. + * + * @return array + */ private static function pre_requisites() { $theme_map = Themes::get(); return array( @@ -30,11 +44,21 @@ private static function pre_requisites() { ); } + /** + * Retrieve Pre-requisites. + * + * @return string|array + */ public static function get_pre_requisites() { $pre_requisites = self::pre_requisites(); return isset( $pre_requisites[ Data::current_flow() ] ) ? $pre_requisites[ Data::current_flow() ] : array(); } + /** + * Retrieve Settings. + * + * @return array + */ public static function get_settings() { $block_editor_context = new \WP_Block_Editor_Context( array( 'name' => 'core/edit-site' ) ); $custom_settings = array( diff --git a/includes/Data/Themes/Colors.php b/includes/Data/Themes/Colors.php index a00054c74..620f6e1cc 100644 --- a/includes/Data/Themes/Colors.php +++ b/includes/Data/Themes/Colors.php @@ -14,7 +14,7 @@ final class Colors { */ protected static $theme_colors = array( 'yith-wonder' => array( - 'tailored' => array( + 'tailored' => array( 'calm' => array( 'header-background' => '#1A4733', 'header-foreground' => '#FFFFFF', @@ -137,7 +137,7 @@ final class Colors { 'base' => '#FFFFFF', ), ), - 'custom-picker-grouping' => array( + 'custom-picker-grouping' => array( 'base' => array( 'header-foreground', 'header-titles', diff --git a/includes/Data/Themes/Fonts.php b/includes/Data/Themes/Fonts.php index 9eba3bcba..92d5a51b1 100644 --- a/includes/Data/Themes/Fonts.php +++ b/includes/Data/Themes/Fonts.php @@ -2,6 +2,9 @@ namespace NewfoldLabs\WP\Module\Onboarding\Data\Themes; +/** + * Contains custom font palettes for a given theme. + */ final class Fonts { /** 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..1faec781a 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,8 +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/PluginsController.php b/includes/RestApi/PluginsController.php index 8d75bb95d..750f5ae91 100644 --- a/includes/RestApi/PluginsController.php +++ b/includes/RestApi/PluginsController.php @@ -360,4 +360,3 @@ public function set_site_features( \WP_REST_Request $request ) { ); } } - diff --git a/includes/Services/PluginInstaller.php b/includes/Services/PluginInstaller.php index 5dc155e39..58729cfbc 100644 --- a/includes/Services/PluginInstaller.php +++ b/includes/Services/PluginInstaller.php @@ -4,8 +4,18 @@ use NewfoldLabs\WP\Module\Onboarding\Data\Plugins; use NewfoldLabs\WP\Module\Onboarding\Data\Options; +/** + * Class PluginInstaller. + */ class PluginInstaller { + /** + * Install Plugins. + * + * @param string $plugin Plugin URL. + * @param boolean $activate Activate Status. + * @return \WP_REST_Response|\WP_Error + */ public static function install( $plugin, $activate ) { $plugins_list = Plugins::get(); @@ -93,8 +103,10 @@ public static function install( $plugin, $activate ) { } /** - * @param string $slug Representing the wordpress.org slug. - * + * Install plugins from WordPress + * + * @param string $plugin Representing the wordpress.org slug. + * @param boolean $activate Activate Status. * @return \WP_REST_Response|\WP_Error */ public static function install_from_wordpress( $plugin, $activate ) { @@ -133,8 +145,10 @@ public static function install_from_wordpress( $plugin, $activate ) { } /** + * Install plugins from zip + * * @param string $url URL to the zip for the plugin. - * + * @param boolean $activate Activate Status. * @return \WP_REST_Response|\WP_Error */ public static function install_from_zip( $url, $activate ) { @@ -207,10 +221,9 @@ public static function install_from_zip( $url, $activate ) { } /** - * @param string $plugin Slug of the plugin. - * * Checks if a given slug is a valid nfd_slug. Ref: includes/Data/Plugins.php for nfd_slug. * + * @param string $plugin Slug of the plugin. * @return boolean */ public static function is_nfd_slug( $plugin ) { @@ -222,10 +235,9 @@ public static function is_nfd_slug( $plugin ) { } /** - * @param string $plugin_path Path to the plugin's header file. - * * Determines if a plugin has already been installed. * + * @param string $plugin_path Path to the plugin's header file. * @return boolean */ public static function is_plugin_installed( $plugin_path ) { @@ -241,8 +253,9 @@ public static function is_plugin_installed( $plugin_path ) { } /** - * @param string $plugin - * + * Retrieve the type of plugin. + * + * @param string $plugin Plugin Name * @return string Type of plugin. Ref: includes/Data/Plugins.php for the different types. */ public static function get_plugin_type( $plugin ) { @@ -256,10 +269,11 @@ public static function get_plugin_type( $plugin ) { } /** - * @param string $plugin - * @param string $plugin_type - * - * @return string Path to the Plugin's header file. + * Path to the Plugin's header file. + * + * @param string $plugin Plugin Name + * @param string $plugin_type Plugin Type + * @return string */ public static function get_plugin_path( $plugin, $plugin_type ) { $plugin_list = Plugins::get(); @@ -267,11 +281,10 @@ public static function get_plugin_path( $plugin, $plugin_type ) { } /** - * @param string $plugin - * @param string $activate - * * Checks if a plugin with the given slug and activation criteria already exists. * + * @param string $plugin Plugin Name + * @param string $activate Acticate Status * @return boolean */ public static function exists( $plugin, $activate ) { diff --git a/includes/Services/PluginUninstaller.php b/includes/Services/PluginUninstaller.php index 08d668376..23d2448ab 100644 --- a/includes/Services/PluginUninstaller.php +++ b/includes/Services/PluginUninstaller.php @@ -11,6 +11,12 @@ class PluginUninstaller { + /** + * Uninstall Plugins. + * + * @param string $plugin Plugin URL. + * @return \WP_REST_Response|\WP_Error + */ public static function uninstall( $plugin ) { $plugin_list = Plugins::get_squashed(); @@ -35,10 +41,9 @@ public static function uninstall( $plugin ) { } /** - * @param string $plugin - * * Checks if a plugin with the given slug exists. * + * @param string $plugin Plugin * @return boolean */ public static function exists( $plugin ) { @@ -53,10 +58,9 @@ public static function exists( $plugin ) { } /** - * @param string $plugin_path Path to the plugin's header file. - * * Determines if a plugin has already been installed. * + * @param string $plugin_path Path to the plugin's header file. * @return boolean */ public static function is_plugin_installed( $plugin_path ) { diff --git a/includes/Services/ThemeInstaller.php b/includes/Services/ThemeInstaller.php index e99ac470a..c3660af27 100644 --- a/includes/Services/ThemeInstaller.php +++ b/includes/Services/ThemeInstaller.php @@ -3,7 +3,18 @@ use NewfoldLabs\WP\Module\Onboarding\Data\Themes; +/** + * Class ThemeInstaller. + */ class ThemeInstaller { + + /** + * Install Themes. + * + * @param string $theme Theme URL. + * @param boolean $activate Activate Status. + * @return \WP_REST_Response|\WP_Error + */ public static function install( $theme, $activate ) { $theme_list = Themes::get(); @@ -40,6 +51,14 @@ public static function install( $theme, $activate ) { ); } + /** + * Install Theme from zip + * + * @param string $url URL to the zip for the plugin. + * @param boolean $activate Activate Status. + * @param string $stylesheet Theme Stylesheet Name. + * @return \WP_REST_Response|\WP_Error + */ public static function install_from_zip( $url, $activate, $stylesheet ) { require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/misc.php'; @@ -97,10 +116,9 @@ public static function install_from_zip( $url, $activate, $stylesheet ) { } /** - * @param string $theme Slug of the theme. - * * Checks if a given slug is a valid nfd_slug. Ref: includes/Data/Themes.php for nfd_slug. * + * @param string $theme Slug of the theme. * @return boolean */ public static function is_nfd_slug( $theme ) { @@ -112,9 +130,10 @@ public static function is_nfd_slug( $theme ) { } /** + * Retrieve Theme Stylesheet + * * @param mixed $theme Slug of the theme present under includes/Data/Themes.php. * @param mixed $theme_type Type of theme Ref: includes/Data/Themes.php for types of theme slugs. - * * @return string The theme stylesheet name. */ public static function get_theme_stylesheet( $theme, $theme_type ) { @@ -123,8 +142,9 @@ public static function get_theme_stylesheet( $theme, $theme_type ) { } /** - * @param string $theme + * Retrieve Theme Type * + * @param string $theme Theme name * @return string Type of theme. Ref: includes/Data/Themes.php for the different types. */ public static function get_theme_type( $theme ) { @@ -135,10 +155,9 @@ public static function get_theme_type( $theme ) { } /** - * @param string $stylesheet The stylesheet of the theme. - * * Determines if a theme has already been installed. * + * @param string $stylesheet The stylesheet of the theme. * @return boolean */ public static function is_theme_installed( $stylesheet ) { @@ -146,10 +165,9 @@ public static function is_theme_installed( $stylesheet ) { } /** - * @param string $stylesheet The stylesheet of the theme. - * * Determines if a theme is already active. * + * @param string $stylesheet The stylesheet of the theme. * @return boolean */ public static function is_theme_active( $stylesheet ) { @@ -157,11 +175,10 @@ public static function is_theme_active( $stylesheet ) { } /** - * @param string $theme - * @param string $activate - * * Checks if a theme with the given slug and activation criteria already exists. * + * @param string $theme + * @param string $activate * @return boolean */ public static function exists( $theme, $activate ) { diff --git a/includes/TaskManagers/PluginUninstallTaskManager.php b/includes/TaskManagers/PluginUninstallTaskManager.php index d4af9a7e1..814247e26 100644 --- a/includes/TaskManagers/PluginUninstallTaskManager.php +++ b/includes/TaskManagers/PluginUninstallTaskManager.php @@ -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_CLI.php b/includes/WP_CLI.php index 6213122f7..83dcd3726 100644 --- a/includes/WP_CLI.php +++ b/includes/WP_CLI.php @@ -5,11 +5,9 @@ * 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() From fc9f698b83412a2a8d8d8a8bce1138cc3b831916 Mon Sep 17 00:00:00 2001 From: Yashita Date: Fri, 12 May 2023 23:21:19 +0530 Subject: [PATCH 02/10] lint fixes to additional files --- includes/Data/Events.php | 10 ++--- includes/Data/Options.php | 2 - includes/Models/PriorityQueue.php | 5 +-- includes/Models/Theme.php | 27 +++++++++---- includes/Mustache/Mustache.php | 13 +++++- includes/Permissions.php | 18 ++++++++- includes/RestApi/BaseHiiveController.php | 10 ++++- includes/RestApi/EventsController.php | 12 ++++-- includes/RestApi/SiteImagesController.php | 6 +++ .../RestApi/Themes/PatternsController.php | 3 +- .../Themes/ThemeVariationsController.php | 26 +++++++++++- includes/Services/PluginInstaller.php | 20 +++++----- includes/Services/PluginUninstaller.php | 2 +- includes/Services/ThemeInstaller.php | 16 ++++---- .../TaskManagers/PluginInstallTaskManager.php | 40 ++++++++++++++++++- .../PluginUninstallTaskManager.php | 31 ++++++++++++-- includes/TaskManagers/TaskManager.php | 11 +++++ .../TaskManagers/ThemeInstallTaskManager.php | 33 ++++++++++++++- includes/Tasks/PluginInstallTask.php | 1 - 19 files changed, 230 insertions(+), 56 deletions(-) diff --git a/includes/Data/Events.php b/includes/Data/Events.php index 7dbdd3d4d..62a457d1c 100644 --- a/includes/Data/Events.php +++ b/includes/Data/Events.php @@ -7,10 +7,10 @@ final class Events { /** - * Contains a list of events with the key being the event slug. - * - * @var array - */ + * Contains a list of events with the key being the event slug. + * + * @var array + */ protected static $events = array( 'nfd-module-onboarding-event-pageview' => array( 'category' => 'Admin', @@ -21,7 +21,7 @@ final class Events { /** * Retrieves the active theme color variations. * - * @param array $event Event data. + * @param array $event_slug Event data. * @return array|boolean */ public static function get_event( $event_slug ) { diff --git a/includes/Data/Options.php b/includes/Data/Options.php index 7ce77ce63..085debc80 100644 --- a/includes/Data/Options.php +++ b/includes/Data/Options.php @@ -10,7 +10,6 @@ final class Options { * * @var string */ - protected static $prefix = 'nfd_module_onboarding_'; /** @@ -18,7 +17,6 @@ final class Options { * * @var array */ - protected static $options = array( 'redirect' => 'redirect', 'redirect_param' => 'redirect_param', diff --git a/includes/Models/PriorityQueue.php b/includes/Models/PriorityQueue.php index da37798b9..7955751f1 100644 --- a/includes/Models/PriorityQueue.php +++ b/includes/Models/PriorityQueue.php @@ -7,11 +7,10 @@ class PriorityQueue extends \SplPriorityQueue { /** - * @param mixed $priority1 - * @param mixed $priority2 - * * Defines the logic to use when comparing two priorities. * + * @param mixed $priority1 + * @param mixed $priority2 * @return int */ public function compare( $priority1, $priority2 ) { diff --git a/includes/Models/Theme.php b/includes/Models/Theme.php index 039fb9fdd..c7fb23125 100644 --- a/includes/Models/Theme.php +++ b/includes/Models/Theme.php @@ -12,6 +12,8 @@ class Theme implements \JsonSerializable { private $is_newfold_theme; /** + * Theme constructor + * * @param string $theme_name */ public function __construct( $theme_name ) { @@ -20,8 +22,9 @@ public function __construct( $theme_name ) { } /** - * @param string $theme_name + * Sets the Theme Name * + * @param string $theme_name Theme Name * @return void */ public function set_theme_name( $theme_name ) { @@ -29,15 +32,18 @@ public function set_theme_name( $theme_name ) { } /** - * @return string $theme_name + * Retrieve the Theme Name + * + * @return string */ public function get_theme_name() { return $this->theme_name; } /** - * @param string $theme_image Path to theme screenshot image. + * Sets the Theme image path * + * @param string $theme_image Path to theme screenshot image. * @return void */ public function set_theme_image( $theme_image ) { @@ -45,15 +51,18 @@ public function set_theme_image( $theme_image ) { } /** - * @return $theme_image Path to theme screenshot image. + * Retrieve the path to theme screenshot image + * + * @return string */ public function get_theme_image() { return $this->theme_image; } /** - * @param boolean $is_newfold_theme + * Sets a theme as newfold theme * + * @param boolean $is_newfold_theme Determines if there is a newfold theme * @return void */ public function set_is_newfold_theme( $is_newfold_theme ) { @@ -61,14 +70,18 @@ public function set_is_newfold_theme( $is_newfold_theme ) { } /** - * @return boolean $is_newfold_theme true if the theme author is Newfold Digital. + * Retrieve is_newfold_theme status -true if the theme author is Newfold Digital. + * + * @return boolean */ public function get_is_newfold_theme() { return $this->is_newfold_theme; } /** - * @return array JSON Serialize the data + * To JSON Serialise the data + * + * @return array */ public function jsonSerialize() { return array( diff --git a/includes/Mustache/Mustache.php b/includes/Mustache/Mustache.php index d1d03dd01..6e9e7419a 100644 --- a/includes/Mustache/Mustache.php +++ b/includes/Mustache/Mustache.php @@ -6,8 +6,16 @@ */ class Mustache { + /** + * Mustache Engine. + * + * @var array + */ protected $mustache_engine; + /** + * Setup mustache engine. + */ function __construct() { $this->mustache_engine = new \Mustache_Engine( array( @@ -17,9 +25,10 @@ function __construct() { } /** - * @param string $template_name - * @param array $data + * Render respective template data. * + * @param string $template_name Template Name + * @param array $data Data * @return string */ public function render_template( $template_name, $data ) { diff --git a/includes/Permissions.php b/includes/Permissions.php index 1faec781a..e014b657c 100644 --- a/includes/Permissions.php +++ b/includes/Permissions.php @@ -13,12 +13,23 @@ final class Permissions { const INSTALL_THEMES = 'install_themes'; const EDIT_THEMES = 'edit_themes'; + /** + * Retrieve Plugin Install Hash Value. + * + * @return string + */ public static function rest_get_plugin_install_hash() { return 'NFD_ONBOARDING_' . hash( 'sha256', NFD_ONBOARDING_VERSION . wp_salt( 'nonce' ) . site_url() ); } + /** + * Verify Plugin Install Hash Value. + * + * @param string $hash Hash Value. + * @return boolean + */ public static function rest_verify_plugin_install_hash( $hash ) { - return $hash === self::rest_get_plugin_install_hash(); + return self::rest_get_plugin_install_hash() === $hash; } /** @@ -39,6 +50,11 @@ public static function is_authorized_admin() { return \is_admin() && self::rest_is_authorized_admin(); } + /** + * Confirm logged-in user can manage themes. + * + * @return boolean + */ public static function rest_can_manage_themes() { return \is_user_logged_in() && \current_user_can( self::INSTALL_THEMES ) && diff --git a/includes/RestApi/BaseHiiveController.php b/includes/RestApi/BaseHiiveController.php index 7a9195e3b..32d60dd0f 100644 --- a/includes/RestApi/BaseHiiveController.php +++ b/includes/RestApi/BaseHiiveController.php @@ -7,10 +7,15 @@ abstract class BaseHiiveController extends \WP_REST_Controller { /** + * Hiive Base URL + * * @var string */ protected $url; + /** + * BaseHiiveControlle constructor. + */ public function __construct() { if ( ! defined( 'NFD_HIIVE_BASE_URL' ) ) { @@ -21,10 +26,11 @@ public function __construct() { } /** + * Get data containing the Hiive response. + * * @param string $endpoint * @param array $args - * - * @return \WP_Error|string containing the Hiive response. + * @return \WP_Error|string */ protected function get( $endpoint, $args = array() ) { $request = $this->url . $endpoint . '?' . http_build_query( $args ); diff --git a/includes/RestApi/EventsController.php b/includes/RestApi/EventsController.php index 2331e5e34..03b31752f 100644 --- a/includes/RestApi/EventsController.php +++ b/includes/RestApi/EventsController.php @@ -9,12 +9,16 @@ */ class EventsController extends \WP_REST_Controller { - /** - * @var string - */ + /** + * This is the REST API namespace that will be used for our custom API + * + * @var string + */ protected $namespace = 'newfold-onboarding/v1'; /** + * This is the REST endpoint + * * @var string */ protected $rest_base = '/events'; @@ -60,7 +64,7 @@ public function get_send_event_args() { /** * Send events to the data module events API. * - * @param \WP_REST_Request $request + * @param \WP_REST_Request $request Request model. * * @return \WP_REST_Response|\WP_Error */ diff --git a/includes/RestApi/SiteImagesController.php b/includes/RestApi/SiteImagesController.php index 16bef0bba..a09c3da7a 100644 --- a/includes/RestApi/SiteImagesController.php +++ b/includes/RestApi/SiteImagesController.php @@ -9,16 +9,22 @@ class SiteImagesController extends BaseHiiveController { /** + * The namespace of this controller's route. + * * @var string */ protected $namespace = 'newfold-onboarding/v1'; /** + * This is the REST endpoint + * * @var string */ protected $rest_base = '/site-images'; /** + * Results per page + * * @var int */ protected $results_per_page = 25; diff --git a/includes/RestApi/Themes/PatternsController.php b/includes/RestApi/Themes/PatternsController.php index 5aac5f85c..87133a572 100644 --- a/includes/RestApi/Themes/PatternsController.php +++ b/includes/RestApi/Themes/PatternsController.php @@ -45,8 +45,9 @@ public function register_routes() { } /** - * * Checks the type of the patterns. + * + * @return array */ public function get_pattern_args() { return array( diff --git a/includes/RestApi/Themes/ThemeVariationsController.php b/includes/RestApi/Themes/ThemeVariationsController.php index 11e03cc86..9d5aaab1b 100644 --- a/includes/RestApi/Themes/ThemeVariationsController.php +++ b/includes/RestApi/Themes/ThemeVariationsController.php @@ -56,6 +56,11 @@ public function register_routes() { ); } + /** + * Get the arguments with type of the patterns. + * + * @return array + */ public function get_pattern_args() { // These variable return the orginal numerous variations if true // Else sends the recently saved theme settings in db @@ -67,6 +72,11 @@ public function get_pattern_args() { ); } + /** + * Set the pattern arguments. + * + * @return array + */ public function set_pattern_args() { // This is the latest modified Global Style to be saved in the db return array( @@ -81,12 +91,24 @@ public function set_pattern_args() { ); } + /** + * Translate decoded json file. + * + * @param string $theme_json Theme content. + * @param string $domain Domain type. + * @return string + */ private static function translate( $theme_json, $domain = 'default' ) { $i18n_schema = wp_json_file_decode( __DIR__ . '/theme-i18n.json' ); return translate_settings_using_i18n_schema( $i18n_schema, $theme_json, $domain ); } + /** + * Retrieve Style Variations. + * + * @return array + */ private static function get_style_variations() { $variations = array(); $base_directory = get_stylesheet_directory() . '/styles'; @@ -112,7 +134,8 @@ private static function get_style_variations() { /** * Retrieves the active themes variations. * - * @return \array|\WP_Error + * @param \WP_REST_Request $request Request model. + * @return array|\WP_Error */ public function get_theme_variations( \WP_REST_Request $request ) { @@ -143,6 +166,7 @@ public function get_theme_variations( \WP_REST_Request $request ) { /** * Saves the custom active theme variations. * + * @param \WP_REST_Request $request Request model. * @return \WP_REST_Response|\WP_Error */ public function set_theme_variation( \WP_REST_Request $request ) { diff --git a/includes/Services/PluginInstaller.php b/includes/Services/PluginInstaller.php index 58729cfbc..3ede9e620 100644 --- a/includes/Services/PluginInstaller.php +++ b/includes/Services/PluginInstaller.php @@ -12,7 +12,7 @@ class PluginInstaller { /** * Install Plugins. * - * @param string $plugin Plugin URL. + * @param string $plugin Plugin URL. * @param boolean $activate Activate Status. * @return \WP_REST_Response|\WP_Error */ @@ -47,7 +47,7 @@ public static function install( $plugin, $activate ) { $plugin = \sanitize_text_field( $plugin ); if ( self::is_nfd_slug( $plugin ) ) { // [TODO] Better handle mu-plugins and direct file downloads. - if ( $plugin === 'nfd_slug_endurance_page_cache' ) { + if ( 'nfd_slug_endurance_page_cache' === $plugin ) { return self::install_endurance_page_cache(); } $plugin_path = $plugins_list['nfd_slugs'][ $plugin ]['path']; @@ -104,8 +104,8 @@ public static function install( $plugin, $activate ) { /** * Install plugins from WordPress - * - * @param string $plugin Representing the wordpress.org slug. + * + * @param string $plugin Representing the wordpress.org slug. * @param boolean $activate Activate Status. * @return \WP_REST_Response|\WP_Error */ @@ -146,8 +146,8 @@ public static function install_from_wordpress( $plugin, $activate ) { /** * Install plugins from zip - * - * @param string $url URL to the zip for the plugin. + * + * @param string $url URL to the zip for the plugin. * @param boolean $activate Activate Status. * @return \WP_REST_Response|\WP_Error */ @@ -254,7 +254,7 @@ public static function is_plugin_installed( $plugin_path ) { /** * Retrieve the type of plugin. - * + * * @param string $plugin Plugin Name * @return string Type of plugin. Ref: includes/Data/Plugins.php for the different types. */ @@ -270,10 +270,10 @@ public static function get_plugin_type( $plugin ) { /** * Path to the Plugin's header file. - * + * * @param string $plugin Plugin Name * @param string $plugin_type Plugin Type - * @return string + * @return string */ public static function get_plugin_path( $plugin, $plugin_type ) { $plugin_list = Plugins::get(); @@ -356,7 +356,7 @@ protected static function connect_to_filesystem() { // We want to ensure that the user has direct access to the filesystem. $access_type = \get_filesystem_method(); - if ( $access_type !== 'direct' ) { + if ( 'direct' !== $access_type ) { return false; } diff --git a/includes/Services/PluginUninstaller.php b/includes/Services/PluginUninstaller.php index 23d2448ab..21a273edd 100644 --- a/includes/Services/PluginUninstaller.php +++ b/includes/Services/PluginUninstaller.php @@ -105,7 +105,7 @@ protected static function connect_to_filesystem() { // We want to ensure that the user has direct access to the filesystem. $access_type = \get_filesystem_method(); - if ( $access_type !== 'direct' ) { + if ( 'direct' !== $access_type ) { return false; } diff --git a/includes/Services/ThemeInstaller.php b/includes/Services/ThemeInstaller.php index c3660af27..4bd285db1 100644 --- a/includes/Services/ThemeInstaller.php +++ b/includes/Services/ThemeInstaller.php @@ -11,7 +11,7 @@ class ThemeInstaller { /** * Install Themes. * - * @param string $theme Theme URL. + * @param string $theme Theme URL. * @param boolean $activate Activate Status. * @return \WP_REST_Response|\WP_Error */ @@ -53,10 +53,10 @@ public static function install( $theme, $activate ) { /** * Install Theme from zip - * - * @param string $url URL to the zip for the plugin. + * + * @param string $url URL to the zip for the plugin. * @param boolean $activate Activate Status. - * @param string $stylesheet Theme Stylesheet Name. + * @param string $stylesheet Theme Stylesheet Name. * @return \WP_REST_Response|\WP_Error */ public static function install_from_zip( $url, $activate, $stylesheet ) { @@ -131,7 +131,7 @@ public static function is_nfd_slug( $theme ) { /** * Retrieve Theme Stylesheet - * + * * @param mixed $theme Slug of the theme present under includes/Data/Themes.php. * @param mixed $theme_type Type of theme Ref: includes/Data/Themes.php for types of theme slugs. * @return string The theme stylesheet name. @@ -142,7 +142,7 @@ public static function get_theme_stylesheet( $theme, $theme_type ) { } /** - * Retrieve Theme Type + * Retrieve Theme Type * * @param string $theme Theme name * @return string Type of theme. Ref: includes/Data/Themes.php for the different types. @@ -177,8 +177,8 @@ public static function is_theme_active( $stylesheet ) { /** * Checks if a theme with the given slug and activation criteria already exists. * - * @param string $theme - * @param string $activate + * @param string $theme Theme name + * @param string $activate Activation Criteria * @return boolean */ public static function exists( $theme, $activate ) { diff --git a/includes/TaskManagers/PluginInstallTaskManager.php b/includes/TaskManagers/PluginInstallTaskManager.php index c03014281..6ad8ea41d 100644 --- a/includes/TaskManagers/PluginInstallTaskManager.php +++ b/includes/TaskManagers/PluginInstallTaskManager.php @@ -19,8 +19,16 @@ class PluginInstallTaskManager { */ private static $retry_limit = 1; + /** + * Name of the PluginInstallTask Queue. + * + * @var string + */ private static $queue_name = 'plugin_install_queue'; + /** + * PluginInstallTaskManager constructor. + */ function __construct() { // Ensure there is a thirty second option in the cron schedules add_filter( 'cron_schedules', array( $this, 'add_thirty_seconds_schedule' ) ); @@ -34,10 +42,21 @@ function __construct() { } } + /** + * Retrieve the Queue Name. + * + * @return string + */ public static function get_queue_name() { return self::$queue_name; } + /** + * Adds thirty second option in the cron schedule. + * + * @param array $schedules Cron Schedule duration + * @return array + */ public function add_thirty_seconds_schedule( $schedules ) { if ( ! array_key_exists( 'thirty_seconds', $schedules ) || 30 !== $schedules['thirty_seconds']['interval'] ) { $schedules['thirty_seconds'] = array( @@ -49,6 +68,11 @@ public function add_thirty_seconds_schedule( $schedules ) { return $schedules; } + /** + * Retrieve status of init_list of plugins being queued. + * + * @return boolean + */ public static function queue_initial_installs() { // Checks if the init_list of plugins have already been queued. @@ -139,11 +163,10 @@ public function install() { } /** - * @param PluginInstallTask $plugin_install_task - * * Adds a new PluginInstallTask to the Plugin Install queue. * The Task will be inserted at an appropriate position in the queue based on it's priority. * + * @param PluginInstallTask $plugin_install_task Plugin Task Details * @return array|false */ public static function add_to_queue( PluginInstallTask $plugin_install_task ) { @@ -174,6 +197,13 @@ public static function add_to_queue( PluginInstallTask $plugin_install_task ) { return \update_option( Options::get_option_name( self::$queue_name ), $queue->to_array() ); } + /** + * Remove a non-matching PluginInstallTask from the Plugin Install queue. + * The Task will be removed from an appropriate position in the queue and requeued in the end. + * + * @param string $plugin Plugin Slug + * @return array|false + */ public static function remove_from_queue( $plugin ) { /* Get the plugins queued up to be installed, the PluginInstall task gets @@ -192,6 +222,12 @@ public static function remove_from_queue( $plugin ) { return \update_option( Options::get_option_name( self::$queue_name ), $queue->to_array() ); } + /** + * Returns the status of given plugin slug. + * + * @param string $plugin Plugin Slug + * @return string|false + */ public static function status( $plugin ) { $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); return array_search( $plugin, array_column( $plugins, 'slug' ) ); diff --git a/includes/TaskManagers/PluginUninstallTaskManager.php b/includes/TaskManagers/PluginUninstallTaskManager.php index 814247e26..dadd63fe2 100644 --- a/includes/TaskManagers/PluginUninstallTaskManager.php +++ b/includes/TaskManagers/PluginUninstallTaskManager.php @@ -19,8 +19,16 @@ class PluginUninstallTaskManager { */ private static $retry_limit = 2; + /** + * Name of the PluginUninstallTask Queue. + * + * @var string + */ private static $queue_name = 'plugin_uninstall_queue'; + /** + * PluginUninstallTaskManager constructor. + */ function __construct() { // Ensure there is a Ten second option in the cron schedules add_filter( 'cron_schedules', array( $this, 'add_ten_seconds_schedule' ) ); @@ -34,10 +42,21 @@ function __construct() { } } + /** + * Retrieve the Queue Name. + * + * @return string + */ public static function get_queue_name() { return self::$queue_name; } + /** + * Adds ten seconds option in the cron schedule. + * + * @param array $schedules Cron Schedule duration + * @return array + */ public function add_ten_seconds_schedule( $schedules ) { if ( ! array_key_exists( 'ten_seconds', $schedules ) || 10 !== $schedules['ten_seconds']['interval'] ) { $schedules['ten_seconds'] = array( @@ -50,7 +69,6 @@ public function add_ten_seconds_schedule( $schedules ) { } /** - * Queue out a PluginUninstallTask with the highest priority in the plugin uninstall queue and execute it. * * @return array|false @@ -98,11 +116,10 @@ public function uninstall() { } /** - * @param PluginUninstallTask $plugin_uninstall_task - * * Adds a new PluginUninstallTask to the Plugin Uninstall queue. * The Task will be inserted at an appropriate position in the queue based on it's priority. * + * @param PluginUninstallTask $plugin_uninstall_task Plugin Task Details * @return array|false */ public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task ) { @@ -112,7 +129,7 @@ public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); $position_in_queue = PluginInstallTaskManager::status( $plugin_uninstall_task->get_slug() ); - if ( $position_in_queue !== false && $position_in_queue !== 0 ) { + if ( false !== $position_in_queue && 0 !== $position_in_queue ) { PluginInstallTaskManager::remove_from_queue( $plugin_uninstall_task->get_slug() ); @@ -149,6 +166,12 @@ public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task return \update_option( Options::get_option_name( self::$queue_name ), $queue->to_array() ); } + /** + * Returns the status of given plugin slug. + * + * @param string $plugin Plugin Slug + * @return string|false + */ public static function status( $plugin ) { $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); return array_search( $plugin, array_column( $plugins, 'slug' ) ); diff --git a/includes/TaskManagers/TaskManager.php b/includes/TaskManagers/TaskManager.php index e4b816b6c..f9b67b7c8 100644 --- a/includes/TaskManagers/TaskManager.php +++ b/includes/TaskManagers/TaskManager.php @@ -3,14 +3,25 @@ use NewfoldLabs\WP\Module\Onboarding\Data\Options; +/** + * class TaskManager + */ final class TaskManager { + /** + * List of Task Managers. + * + * @var array + */ protected $task_managers = array( 'NewfoldLabs\\WP\Module\\Onboarding\\TaskManagers\\PluginInstallTaskManager', 'NewfoldLabs\\WP\Module\\Onboarding\\TaskManagers\\PluginUninstallTaskManager', 'NewfoldLabs\\WP\Module\\Onboarding\\TaskManagers\\ThemeInstallTaskManager', ); + /** + * TaskManager constructor. + */ function __construct() { foreach ( $this->task_managers as $task_manager ) { if ( ! empty( get_option( Options::get_option_name( $task_manager::get_queue_name() ), array() ) ) ) { diff --git a/includes/TaskManagers/ThemeInstallTaskManager.php b/includes/TaskManagers/ThemeInstallTaskManager.php index 86758ea0d..5ded468d2 100644 --- a/includes/TaskManagers/ThemeInstallTaskManager.php +++ b/includes/TaskManagers/ThemeInstallTaskManager.php @@ -19,8 +19,16 @@ class ThemeInstallTaskManager { */ private static $retry_limit = 1; + /** + * Name of the ThemeInstallTaskManager Queue. + * + * @var string + */ private static $queue_name = 'theme_install_queue'; + /** + * ThemeInstallTaskManager constructor. + */ function __construct() { // Ensure there is a ten second option in the cron schedules add_filter( 'cron_schedules', array( $this, 'add_ten_seconds_schedule' ) ); @@ -34,10 +42,21 @@ function __construct() { } } + /** + * Retrieve the Queue Name. + * + * @return string + */ public static function get_queue_name() { return self::$queue_name; } + /** + * Adds ten seconds option in the cron schedule. + * + * @param array $schedules Cron Schedule duration + * @return array + */ public function add_ten_seconds_schedule( $schedules ) { if ( ! array_key_exists( 'ten_seconds', $schedules ) || 10 !== $schedules['ten_seconds']['interval'] ) { $schedules['ten_seconds'] = array( @@ -49,6 +68,11 @@ public function add_ten_seconds_schedule( $schedules ) { return $schedules; } + /** + * Retrieve status of init_list of plugins being queued. + * + * @return boolean + */ public static function queue_initial_installs() { // Checks if the init_list of themes have already been queued. if ( \get_option( Options::get_option_name( 'theme_init_status' ), 'init' ) !== 'init' ) { @@ -129,11 +153,10 @@ public function install() { } /** - * @param ThemeInstallTask $theme_install_task - * * Adds a new ThemeInstallTask to the Theme Install queue. * The Task will be inserted at an appropriate position in the queue based on it's priority. * + * @param ThemeInstallTask $theme_install_task * @return array|false */ public static function add_to_queue( ThemeInstallTask $theme_install_task ) { @@ -164,6 +187,12 @@ public static function add_to_queue( ThemeInstallTask $theme_install_task ) { return \update_option( Options::get_option_name( self::$queue_name ), $queue->to_array() ); } + /** + * Returns the status of given plugin slug. + * + * @param string $theme Theme Slug + * @return string|false + */ public static function status( $theme ) { $themes = \get_option( Options::get_option_name( self::$queue_name ), array() ); return array_search( $theme, array_column( $themes, 'slug' ) ); diff --git a/includes/Tasks/PluginInstallTask.php b/includes/Tasks/PluginInstallTask.php index f8cd72f51..080cc9f83 100644 --- a/includes/Tasks/PluginInstallTask.php +++ b/includes/Tasks/PluginInstallTask.php @@ -65,5 +65,4 @@ public function to_array() { 'retries' => $this->retries, ); } - } From 1d33a79de23964f70569fe3dfd9cf8c0c7bdc3be Mon Sep 17 00:00:00 2001 From: Yashita Date: Sat, 13 May 2023 12:54:08 +0530 Subject: [PATCH 03/10] added doc comments --- includes/Models/PriorityQueue.php | 4 +-- includes/Models/Theme.php | 19 +++++++++++++- includes/Mustache/Mustache.php | 2 +- includes/RestApi/BaseHiiveController.php | 4 +-- includes/Services/PluginUninstaller.php | 1 - .../TaskManagers/PluginInstallTaskManager.php | 26 ++++++++++++------- .../PluginUninstallTaskManager.php | 20 ++++++++------ includes/TaskManagers/TaskManager.php | 4 +-- .../TaskManagers/ThemeInstallTaskManager.php | 19 ++++++++------ 9 files changed, 64 insertions(+), 35 deletions(-) diff --git a/includes/Models/PriorityQueue.php b/includes/Models/PriorityQueue.php index 7955751f1..c0fc47d08 100644 --- a/includes/Models/PriorityQueue.php +++ b/includes/Models/PriorityQueue.php @@ -9,8 +9,8 @@ class PriorityQueue extends \SplPriorityQueue { /** * Defines the logic to use when comparing two priorities. * - * @param mixed $priority1 - * @param mixed $priority2 + * @param mixed $priority1 First Priority Queue + * @param mixed $priority2 Second Priority Queue * @return int */ public function compare( $priority1, $priority2 ) { diff --git a/includes/Models/Theme.php b/includes/Models/Theme.php index c7fb23125..d1187509c 100644 --- a/includes/Models/Theme.php +++ b/includes/Models/Theme.php @@ -7,14 +7,31 @@ */ class Theme implements \JsonSerializable { + /** + * Flow data blueprint. + * + * @var string + */ private $theme_name; + + /** + * Theme image Path. + * + * @var string + */ private $theme_image; + + /** + * Status of a theme being a Newfold Theme. + * + * @var boolean + */ private $is_newfold_theme; /** * Theme constructor * - * @param string $theme_name + * @param string $theme_name Theme Name */ public function __construct( $theme_name ) { $this->theme_name = $theme_name; diff --git a/includes/Mustache/Mustache.php b/includes/Mustache/Mustache.php index 6e9e7419a..4c8dc9f00 100644 --- a/includes/Mustache/Mustache.php +++ b/includes/Mustache/Mustache.php @@ -16,7 +16,7 @@ class Mustache { /** * Setup mustache engine. */ - function __construct() { + public function __construct() { $this->mustache_engine = new \Mustache_Engine( array( 'loader' => new \Mustache_Loader_FilesystemLoader( dirname( __FILE__ ) . '/Templates' ), diff --git a/includes/RestApi/BaseHiiveController.php b/includes/RestApi/BaseHiiveController.php index 32d60dd0f..32f8bc6d7 100644 --- a/includes/RestApi/BaseHiiveController.php +++ b/includes/RestApi/BaseHiiveController.php @@ -28,8 +28,8 @@ public function __construct() { /** * Get data containing the Hiive response. * - * @param string $endpoint - * @param array $args + * @param string $endpoint Endpoint request to get specific response + * @param array $args Arguments determining response * @return \WP_Error|string */ protected function get( $endpoint, $args = array() ) { diff --git a/includes/Services/PluginUninstaller.php b/includes/Services/PluginUninstaller.php index 21a273edd..6918cbc79 100644 --- a/includes/Services/PluginUninstaller.php +++ b/includes/Services/PluginUninstaller.php @@ -8,7 +8,6 @@ * Class PluginUninstaller * This class is responsible to Uninstall a specified plugin */ - class PluginUninstaller { /** diff --git a/includes/TaskManagers/PluginInstallTaskManager.php b/includes/TaskManagers/PluginInstallTaskManager.php index 6ad8ea41d..f189acd4e 100644 --- a/includes/TaskManagers/PluginInstallTaskManager.php +++ b/includes/TaskManagers/PluginInstallTaskManager.php @@ -29,7 +29,7 @@ class PluginInstallTaskManager { /** * PluginInstallTaskManager constructor. */ - function __construct() { + public function __construct() { // Ensure there is a thirty second option in the cron schedules add_filter( 'cron_schedules', array( $this, 'add_thirty_seconds_schedule' ) ); @@ -111,12 +111,14 @@ public static function queue_initial_installs() { public function install() { /* Get the plugins queued up to be installed, the PluginInstall task gets - converted to an associative array before storing it in the option. */ + converted to an associative array before storing it in the option. + */ $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); /* Conversion of the max heap to an array will always place the PluginInstallTask with the highest - priority at the beginning of the array */ + priority at the beginning of the array + */ $plugin_to_install = array_shift( $plugins ); // Update the plugin install queue. @@ -143,9 +145,10 @@ public function install() { // Get Latest Value of the install queue $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); - /* + /* If the number of retries have not exceeded the limit - then re-queue the task at the end of the queue to be retried. */ + then re-queue the task at the end of the queue to be retried. + */ if ( $plugin_install_task->get_retries() <= self::$retry_limit ) { array_push( $plugins, $plugin_install_task->to_array() ); @@ -172,15 +175,16 @@ public function install() { public static function add_to_queue( PluginInstallTask $plugin_install_task ) { /* Get the plugins queued up to be installed, the PluginInstall task gets - converted to an associative array before storing it in the option. */ + converted to an associative array before storing it in the option. + */ $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); $queue = new PriorityQueue(); foreach ( $plugins as $queued_plugin ) { - /* Check if there is an already existing PluginInstallTask in the queue - for a given slug and activation criteria. */ + for a given slug and activation criteria. + */ if ( $queued_plugin['slug'] === $plugin_install_task->get_slug() && $queued_plugin['activate'] === $plugin_install_task->get_activate() ) { return false; @@ -207,13 +211,15 @@ public static function add_to_queue( PluginInstallTask $plugin_install_task ) { public static function remove_from_queue( $plugin ) { /* Get the plugins queued up to be installed, the PluginInstall task gets - converted to an associative array before storing it in the option. */ + converted to an associative array before storing it in the option. + */ $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); $queue = new PriorityQueue(); foreach ( $plugins as $queued_plugin ) { /* - If the Plugin slug does not match add it back to the queue. */ + If the Plugin slug does not match add it back to the queue. + */ if ( $queued_plugin['slug'] !== $plugin ) { $queue->insert( $queued_plugin, $queued_plugin['priority'] ); } diff --git a/includes/TaskManagers/PluginUninstallTaskManager.php b/includes/TaskManagers/PluginUninstallTaskManager.php index dadd63fe2..f76787905 100644 --- a/includes/TaskManagers/PluginUninstallTaskManager.php +++ b/includes/TaskManagers/PluginUninstallTaskManager.php @@ -29,7 +29,7 @@ class PluginUninstallTaskManager { /** * PluginUninstallTaskManager constructor. */ - function __construct() { + public function __construct() { // Ensure there is a Ten second option in the cron schedules add_filter( 'cron_schedules', array( $this, 'add_ten_seconds_schedule' ) ); @@ -76,12 +76,14 @@ public function add_ten_seconds_schedule( $schedules ) { public function uninstall() { /* Get the plugins queued up to be uninstalled, the PluginUninstall task gets - converted to an associative array before storing it in the option. */ + converted to an associative array before storing it in the option. + */ $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); /* Conversion of the max heap to an array will always place the PluginUninstallTask with the highest - priority at the beginning of the array */ + priority at the beginning of the array + */ $plugin_to_uninstall = array_shift( $plugins ); // Update the plugin uninstall queue. @@ -101,9 +103,10 @@ public function uninstall() { // If there is an error, then increase the retry count for the task. $plugin_uninstall_task->increment_retries(); - /* + /* If the number of retries have not exceeded the limit - then re-queue the task at the end of the queue to be retried. */ + then re-queue the task at the end of the queue to be retried. + */ if ( $plugin_uninstall_task->get_retries() <= self::$retry_limit ) { array_push( $plugins, $plugin_uninstall_task->to_array() ); @@ -125,7 +128,8 @@ public function uninstall() { public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task ) { /* Get the plugins queued up to be uninstalled, the PluginUninstall task gets - converted to an associative array before storing it in the option. */ + converted to an associative array before storing it in the option. + */ $plugins = \get_option( Options::get_option_name( self::$queue_name ), array() ); $position_in_queue = PluginInstallTaskManager::status( $plugin_uninstall_task->get_slug() ); @@ -147,10 +151,10 @@ public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task $queue = new PriorityQueue(); foreach ( $plugins as $queued_plugin ) { - /* Check if there is an already existing PluginUninstallTask in the queue - for a given slug. */ + for a given slug. + */ if ( $queued_plugin['slug'] === $plugin_uninstall_task->get_slug() ) { return false; } diff --git a/includes/TaskManagers/TaskManager.php b/includes/TaskManagers/TaskManager.php index f9b67b7c8..5642b8203 100644 --- a/includes/TaskManagers/TaskManager.php +++ b/includes/TaskManagers/TaskManager.php @@ -4,7 +4,7 @@ use NewfoldLabs\WP\Module\Onboarding\Data\Options; /** - * class TaskManager + * Class TaskManager */ final class TaskManager { @@ -22,7 +22,7 @@ final class TaskManager { /** * TaskManager constructor. */ - function __construct() { + public function __construct() { foreach ( $this->task_managers as $task_manager ) { if ( ! empty( get_option( Options::get_option_name( $task_manager::get_queue_name() ), array() ) ) ) { new $task_manager(); diff --git a/includes/TaskManagers/ThemeInstallTaskManager.php b/includes/TaskManagers/ThemeInstallTaskManager.php index 5ded468d2..89c3b01ff 100644 --- a/includes/TaskManagers/ThemeInstallTaskManager.php +++ b/includes/TaskManagers/ThemeInstallTaskManager.php @@ -29,7 +29,7 @@ class ThemeInstallTaskManager { /** * ThemeInstallTaskManager constructor. */ - function __construct() { + public function __construct() { // Ensure there is a ten second option in the cron schedules add_filter( 'cron_schedules', array( $this, 'add_ten_seconds_schedule' ) ); @@ -109,12 +109,14 @@ public static function queue_initial_installs() { public function install() { /* Get the theme install tasks queued up to be installed, the ThemeInstallTask gets - converted to an associative array before storing it in the option. */ + converted to an associative array before storing it in the option. + */ $themes = \get_option( Options::get_option_name( self::$queue_name ), array() ); /* Conversion of the max heap to an array will always place the ThemeInstallTask with the highest - priority at the beginning of the array */ + priority at the beginning of the array + */ $theme_to_install = array_shift( $themes ); // Recreate the ThemeInstallTask from the associative array. @@ -135,9 +137,10 @@ public function install() { // If there is an error, then increase the retry count for the task. $theme_install_task->increment_retries(); - /* + /* If the number of retries have not exceeded the limit - then re-queue the task at the end of the queue to be retried. */ + then re-queue the task at the end of the queue to be retried. + */ if ( $theme_install_task->get_retries() <= self::$retry_limit ) { array_push( $themes, $theme_install_task->to_array() ); } @@ -156,7 +159,7 @@ public function install() { * Adds a new ThemeInstallTask to the Theme Install queue. * The Task will be inserted at an appropriate position in the queue based on it's priority. * - * @param ThemeInstallTask $theme_install_task + * @param ThemeInstallTask $theme_install_task Theme Intsall Task to add to the queue * @return array|false */ public static function add_to_queue( ThemeInstallTask $theme_install_task ) { @@ -167,10 +170,10 @@ public static function add_to_queue( ThemeInstallTask $theme_install_task ) { $queue = new PriorityQueue(); foreach ( $themes as $queued_theme ) { - /* Check if there is an already existing ThemeInstallTask in the queue - for a given slug and activation criteria. */ + for a given slug and activation criteria. + */ if ( $queued_theme['slug'] === $theme_install_task->get_slug() && $queued_theme['activate'] === $theme_install_task->get_activate() ) { return false; From 81fd7983f14acf253645d765f5b7b3d9ef9b5f14 Mon Sep 17 00:00:00 2001 From: Yashita Date: Sat, 13 May 2023 12:54:42 +0530 Subject: [PATCH 04/10] added doc comments to variables and functions --- includes/Tasks/PluginInstallTask.php | 57 ++++++++++++++++++++++++- includes/Tasks/PluginUninstallTask.php | 45 +++++++++++++++++++- includes/Tasks/ThemeInstallTask.php | 58 +++++++++++++++++++++++++- includes/WP_Config.php | 2 +- 4 files changed, 155 insertions(+), 7 deletions(-) diff --git a/includes/Tasks/PluginInstallTask.php b/includes/Tasks/PluginInstallTask.php index 080cc9f83..b1911dfa0 100644 --- a/includes/Tasks/PluginInstallTask.php +++ b/includes/Tasks/PluginInstallTask.php @@ -8,37 +8,90 @@ */ class PluginInstallTask extends Task { - private $slug, $activate, $priority, $retries; + /** + * Plugin Slug. + * + * @var string + */ + private $slug; + + /** + * Plugin Activation Status. + * + * @var boolean + */ + private $activate; + + /** + * Task Priority. + * + * @var int + */ + private $priority; + + /** + * Task Installation Retries Count. + * + * @var int + */ + private $retries; /** + * PluginInstallTask constructor + * * @param string $slug The slug for the Plugin. Ref: includes/Data/Plugins.php for the slugs. * @param boolean $activate A value of true activates the plugin. * @param int $priority Priority of the task, higher the number higher the priority. * @param int $retries The number of times the Task has been retried */ - function __construct( $slug, $activate, $priority = 0, $retries = 0 ) { + public function __construct( $slug, $activate, $priority = 0, $retries = 0 ) { $this->slug = $slug; $this->activate = $activate; $this->priority = $priority; $this->retries = $retries; } + /** + * Retrieves Slug for the Plugin. + * + * @return string + */ public function get_slug() { return $this->slug; } + /** + * Retrieves Plugin Activation Status. + * + * @return boolean + */ public function get_activate() { return $this->activate; } + /** + * Retrieves Task Priority. + * + * @return int + */ public function get_priority() { return $this->priority; } + /** + * Retrieves Task Installation retry count. + * + * @return string + */ public function get_retries() { return $this->retries; } + /** + * Increments retry count. + * + * @return void + */ public function increment_retries() { $this->retries++; } diff --git a/includes/Tasks/PluginUninstallTask.php b/includes/Tasks/PluginUninstallTask.php index a0780cdfb..a59ce38fa 100644 --- a/includes/Tasks/PluginUninstallTask.php +++ b/includes/Tasks/PluginUninstallTask.php @@ -8,31 +8,72 @@ */ class PluginUninstallTask extends Task { - private $slug, $priority, $retries; + /** + * Plugin Slug. + * + * @var string + */ + private $slug; + + /** + * Task Priority. + * + * @var int + */ + private $priority; + + /** + * Task Retries Count. + * + * @var int + */ + private $retries; /** + * PluginUninstallTask constructor + * * @param string $slug The slug for the Plugin. Ref: includes/Data/Plugins.php for the slugs. * @param int $priority Priority of the task, higher the number higher the priority. * @param int $retries The number of times the Task has been retried */ - function __construct( $slug, $priority = 0, $retries = 0 ) { + public function __construct( $slug, $priority = 0, $retries = 0 ) { $this->slug = $slug; $this->priority = $priority; $this->retries = $retries; } + /** + * Retrieves Slug for the Plugin. + * + * @return string + */ public function get_slug() { return $this->slug; } + /** + * Retrieves Task Priority. + * + * @return int + */ public function get_priority() { return $this->priority; } + /** + * Retrieves Task Installation retry count. + * + * @return string + */ public function get_retries() { return $this->retries; } + /** + * Increments retry count. + * + * @return void + */ public function increment_retries() { $this->retries++; } diff --git a/includes/Tasks/ThemeInstallTask.php b/includes/Tasks/ThemeInstallTask.php index a3f980799..70bd1f409 100644 --- a/includes/Tasks/ThemeInstallTask.php +++ b/includes/Tasks/ThemeInstallTask.php @@ -7,37 +7,91 @@ * Task for installing a Theme. */ class ThemeInstallTask extends Task { - private $slug, $activate, $priority, $retries; + + /** + * Theme Slug. + * + * @var string + */ + private $slug; + + /** + * Theme Activation Status. + * + * @var boolean + */ + private $activate; + + /** + * Task Priority. + * + * @var int + */ + private $priority; + + /** + * Task Installation Retries Count. + * + * @var int + */ + private $retries; /** + * ThemeInstallTask constructor + * * @param string $slug The slug for the Theme. Ref: includes/Data/Themes.php for the slugs. * @param boolean $activate A value of true activates the theme. * @param int $priority Priority of the task, higher the number higher the priority. * @param int $retries The number of times the Task has been retried */ - function __construct( $slug, $activate, $priority = 0, $retries = 0 ) { + public function __construct( $slug, $activate, $priority = 0, $retries = 0 ) { $this->slug = $slug; $this->activate = $activate; $this->priority = $priority; $this->retries = $retries; } + /** + * Retrieves Slug for the Theme. + * + * @return string + */ public function get_slug() { return $this->slug; } + /** + * Retrieves Theme Activation Status. + * + * @return boolean + */ public function get_activate() { return $this->activate; } + /** + * Retrieves Task Priority. + * + * @return int + */ public function get_priority() { return $this->priority; } + /** + * Retrieves Task Installation retry count. + * + * @return string + */ public function get_retries() { return $this->retries; } + /** + * Increments retry count. + * + * @return void + */ public function increment_retries() { $this->retries++; } diff --git a/includes/WP_Config.php b/includes/WP_Config.php index 1ff861ffa..24441e596 100644 --- a/includes/WP_Config.php +++ b/includes/WP_Config.php @@ -11,7 +11,7 @@ class WP_Config { */ protected $wp_config; - function __construct() { + public function __construct() { $this->wp_config = new \WPConfigTransformer( ABSPATH . 'wp-config.php' ); } From 3351661804818cac50d9a0039cabdc77219ec8ae Mon Sep 17 00:00:00 2001 From: Yashita Date: Sat, 13 May 2023 12:59:41 +0530 Subject: [PATCH 05/10] Update WP_Config.php --- includes/WP_Config.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/WP_Config.php b/includes/WP_Config.php index 24441e596..c12aa39d6 100644 --- a/includes/WP_Config.php +++ b/includes/WP_Config.php @@ -7,10 +7,15 @@ class WP_Config { /** + * WordPress Configuration + * * @var \WPConfigTransformer */ protected $wp_config; + /** + * WP_Config constructor. + */ public function __construct() { $this->wp_config = new \WPConfigTransformer( ABSPATH . 'wp-config.php' ); } From bdb52143b932f318f08263db5e49da40daabd146 Mon Sep 17 00:00:00 2001 From: Yashita Date: Sat, 13 May 2023 13:02:18 +0530 Subject: [PATCH 06/10] Update ThemeInstallTaskManager.php --- includes/TaskManagers/ThemeInstallTaskManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/TaskManagers/ThemeInstallTaskManager.php b/includes/TaskManagers/ThemeInstallTaskManager.php index 89c3b01ff..255bfe16f 100644 --- a/includes/TaskManagers/ThemeInstallTaskManager.php +++ b/includes/TaskManagers/ThemeInstallTaskManager.php @@ -165,7 +165,8 @@ public function install() { public static function add_to_queue( ThemeInstallTask $theme_install_task ) { /* Get the ThemeInstallTasks queued up to be installed, the ThemeInstallTask gets - converted to an associative array before storing it in the option. */ + converted to an associative array before storing it in the option. + */ $themes = \get_option( Options::get_option_name( self::$queue_name ), array() ); $queue = new PriorityQueue(); From 48a2dd1820f1072867351ee87515c8301580a058 Mon Sep 17 00:00:00 2001 From: Yashita Date: Sat, 13 May 2023 13:03:55 +0530 Subject: [PATCH 07/10] Update ThemeInstallTaskManager.php --- includes/TaskManagers/ThemeInstallTaskManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/TaskManagers/ThemeInstallTaskManager.php b/includes/TaskManagers/ThemeInstallTaskManager.php index 255bfe16f..74ac16333 100644 --- a/includes/TaskManagers/ThemeInstallTaskManager.php +++ b/includes/TaskManagers/ThemeInstallTaskManager.php @@ -165,7 +165,7 @@ public function install() { public static function add_to_queue( ThemeInstallTask $theme_install_task ) { /* Get the ThemeInstallTasks queued up to be installed, the ThemeInstallTask gets - converted to an associative array before storing it in the option. + converted to an associative array before storing it in the option. */ $themes = \get_option( Options::get_option_name( self::$queue_name ), array() ); From adb6ead3326118c62bfed9a9169de2419b1c4bb6 Mon Sep 17 00:00:00 2001 From: Yashita Date: Thu, 18 May 2023 19:17:12 +0530 Subject: [PATCH 08/10] added brief descriptions to methods --- includes/Data/Preview.php | 6 +++--- includes/Models/Theme.php | 12 ++++++------ includes/RestApi/BaseHiiveController.php | 4 ++-- .../RestApi/Themes/ThemeVariationsController.php | 10 ++++------ includes/Services/PluginInstaller.php | 12 ++++++------ includes/Services/PluginUninstaller.php | 2 +- includes/Services/ThemeInstaller.php | 10 +++++----- includes/TaskManagers/PluginInstallTaskManager.php | 4 ++-- includes/TaskManagers/PluginUninstallTaskManager.php | 4 ++-- includes/TaskManagers/ThemeInstallTaskManager.php | 4 ++-- 10 files changed, 33 insertions(+), 35 deletions(-) diff --git a/includes/Data/Preview.php b/includes/Data/Preview.php index 3630cb463..4aeba32ec 100644 --- a/includes/Data/Preview.php +++ b/includes/Data/Preview.php @@ -20,7 +20,7 @@ private static function boolean_to_status( $boolean ) { } /** - * Preview Pre-requisites Data. + * Get Pre-requisites Plugin and Theme Data based on the flow type. * * @return array */ @@ -45,7 +45,7 @@ private static function pre_requisites() { } /** - * Retrieve Pre-requisites. + * Retrieve Pre-requisites for the respective flow type. * * @return string|array */ @@ -55,7 +55,7 @@ public static function get_pre_requisites() { } /** - * Retrieve Settings. + * Retrieve Settings, GlobalStyles and Pre-requisites for thw flow type. * * @return array */ diff --git a/includes/Models/Theme.php b/includes/Models/Theme.php index d1187509c..721eabc08 100644 --- a/includes/Models/Theme.php +++ b/includes/Models/Theme.php @@ -8,7 +8,7 @@ class Theme implements \JsonSerializable { /** - * Flow data blueprint. + * Name of the Theme. * * @var string */ @@ -29,9 +29,9 @@ class Theme implements \JsonSerializable { private $is_newfold_theme; /** - * Theme constructor + * Theme constructor. * - * @param string $theme_name Theme Name + * @param string $theme_name Theme Name. */ public function __construct( $theme_name ) { $this->theme_name = $theme_name; @@ -77,7 +77,7 @@ public function get_theme_image() { } /** - * Sets a theme as newfold theme + * Sets the status of a theme as a newfold theme. * * @param boolean $is_newfold_theme Determines if there is a newfold theme * @return void @@ -87,7 +87,7 @@ public function set_is_newfold_theme( $is_newfold_theme ) { } /** - * Retrieve is_newfold_theme status -true if the theme author is Newfold Digital. + * Retrieve is_newfold_theme status - true if the theme author is Newfold Digital. * * @return boolean */ @@ -96,7 +96,7 @@ public function get_is_newfold_theme() { } /** - * To JSON Serialise the data + * To JSON Serialise the Theme data * * @return array */ diff --git a/includes/RestApi/BaseHiiveController.php b/includes/RestApi/BaseHiiveController.php index 32f8bc6d7..c6e9f692c 100644 --- a/includes/RestApi/BaseHiiveController.php +++ b/includes/RestApi/BaseHiiveController.php @@ -14,7 +14,7 @@ abstract class BaseHiiveController extends \WP_REST_Controller { protected $url; /** - * BaseHiiveControlle constructor. + * BaseHiiveController constructor. */ public function __construct() { @@ -26,7 +26,7 @@ public function __construct() { } /** - * Get data containing the Hiive response. + * Get data from the endpoint containing the specific Hiive response. * * @param string $endpoint Endpoint request to get specific response * @param array $args Arguments determining response diff --git a/includes/RestApi/Themes/ThemeVariationsController.php b/includes/RestApi/Themes/ThemeVariationsController.php index 9d5aaab1b..8dbd6d654 100644 --- a/includes/RestApi/Themes/ThemeVariationsController.php +++ b/includes/RestApi/Themes/ThemeVariationsController.php @@ -57,13 +57,12 @@ public function register_routes() { } /** - * Get the arguments with type of the patterns. + * Get the patterns arguments. + * Retrieves the orginal numerous variations if true, else sends the recently saved theme settings in the DB. * * @return array */ public function get_pattern_args() { - // These variable return the orginal numerous variations if true - // Else sends the recently saved theme settings in db return array( 'variations' => array( 'type' => 'boolean', @@ -73,12 +72,11 @@ public function get_pattern_args() { } /** - * Set the pattern arguments. + * Set the pattern arguments to the latest modified Global Style that is to be saved in the DB. * * @return array */ public function set_pattern_args() { - // This is the latest modified Global Style to be saved in the db return array( 'title' => array( 'type' => 'string', @@ -105,7 +103,7 @@ private static function translate( $theme_json, $domain = 'default' ) { } /** - * Retrieve Style Variations. + * Translate the json decoded HTML Files and retrieve all the Theme Style Variations. * * @return array */ diff --git a/includes/Services/PluginInstaller.php b/includes/Services/PluginInstaller.php index 3ede9e620..c174c7981 100644 --- a/includes/Services/PluginInstaller.php +++ b/includes/Services/PluginInstaller.php @@ -10,7 +10,7 @@ class PluginInstaller { /** - * Install Plugins. + * Install valid accessible Plugins based on the activation status. * * @param string $plugin Plugin URL. * @param boolean $activate Activate Status. @@ -103,10 +103,10 @@ public static function install( $plugin, $activate ) { } /** - * Install plugins from WordPress + * Install valid and accessible plugins from WordPress if not already installed. * * @param string $plugin Representing the wordpress.org slug. - * @param boolean $activate Activate Status. + * @param boolean $activate Plugin Activation Status. * @return \WP_REST_Response|\WP_Error */ public static function install_from_wordpress( $plugin, $activate ) { @@ -145,7 +145,7 @@ public static function install_from_wordpress( $plugin, $activate ) { } /** - * Install plugins from zip + * Install plugins from an approved zip url if not already installed. * * @param string $url URL to the zip for the plugin. * @param boolean $activate Activate Status. @@ -253,7 +253,7 @@ public static function is_plugin_installed( $plugin_path ) { } /** - * Retrieve the type of plugin. + * Retrieve the type of plugin - a valid URL/approved NFD Slug/WP Slug. * * @param string $plugin Plugin Name * @return string Type of plugin. Ref: includes/Data/Plugins.php for the different types. @@ -281,7 +281,7 @@ public static function get_plugin_path( $plugin, $plugin_type ) { } /** - * Checks if a plugin with the given slug and activation criteria already exists. + * Checks if a plugin exists with the given slug and activation criteria already exists. * * @param string $plugin Plugin Name * @param string $activate Acticate Status diff --git a/includes/Services/PluginUninstaller.php b/includes/Services/PluginUninstaller.php index 6918cbc79..f24ffe623 100644 --- a/includes/Services/PluginUninstaller.php +++ b/includes/Services/PluginUninstaller.php @@ -11,7 +11,7 @@ class PluginUninstaller { /** - * Uninstall Plugins. + * Deactivate a plugin if active and then Uninstall the specific plugin. * * @param string $plugin Plugin URL. * @return \WP_REST_Response|\WP_Error diff --git a/includes/Services/ThemeInstaller.php b/includes/Services/ThemeInstaller.php index 4bd285db1..7c2b5c433 100644 --- a/includes/Services/ThemeInstaller.php +++ b/includes/Services/ThemeInstaller.php @@ -9,7 +9,7 @@ class ThemeInstaller { /** - * Install Themes. + * Install valid and accesible Themes based on the activation status. * * @param string $theme Theme URL. * @param boolean $activate Activate Status. @@ -52,7 +52,7 @@ public static function install( $theme, $activate ) { } /** - * Install Theme from zip + * Install theme from an approved zip url if not already installed. Activate and switch to the theme, if specified. * * @param string $url URL to the zip for the plugin. * @param boolean $activate Activate Status. @@ -130,11 +130,11 @@ public static function is_nfd_slug( $theme ) { } /** - * Retrieve Theme Stylesheet + * Retrieve Theme Stylesheet Name for a specified theme name and theme type. * * @param mixed $theme Slug of the theme present under includes/Data/Themes.php. * @param mixed $theme_type Type of theme Ref: includes/Data/Themes.php for types of theme slugs. - * @return string The theme stylesheet name. + * @return string|boolean */ public static function get_theme_stylesheet( $theme, $theme_type ) { $theme_list = Themes::get(); @@ -142,7 +142,7 @@ public static function get_theme_stylesheet( $theme, $theme_type ) { } /** - * Retrieve Theme Type + * Retrieve Theme Type - approved NFD Slug/WP Slug. * * @param string $theme Theme name * @return string Type of theme. Ref: includes/Data/Themes.php for the different types. diff --git a/includes/TaskManagers/PluginInstallTaskManager.php b/includes/TaskManagers/PluginInstallTaskManager.php index f189acd4e..d812d00fc 100644 --- a/includes/TaskManagers/PluginInstallTaskManager.php +++ b/includes/TaskManagers/PluginInstallTaskManager.php @@ -43,7 +43,7 @@ public function __construct() { } /** - * Retrieve the Queue Name. + * Retrieve the Queue Name for the TaskManager to perform Plugin installation. * * @return string */ @@ -229,7 +229,7 @@ public static function remove_from_queue( $plugin ) { } /** - * Returns the status of given plugin slug. + * Returns the status of given plugin slug - installing/completed. * * @param string $plugin Plugin Slug * @return string|false diff --git a/includes/TaskManagers/PluginUninstallTaskManager.php b/includes/TaskManagers/PluginUninstallTaskManager.php index f76787905..8c732a048 100644 --- a/includes/TaskManagers/PluginUninstallTaskManager.php +++ b/includes/TaskManagers/PluginUninstallTaskManager.php @@ -43,7 +43,7 @@ public function __construct() { } /** - * Retrieve the Queue Name. + * Retrieve the Queue Name for the TaskManager to perform Plugin uninstallation. * * @return string */ @@ -171,7 +171,7 @@ public static function add_to_queue( PluginUninstallTask $plugin_uninstall_task } /** - * Returns the status of given plugin slug. + * Returns the status of given plugin slug - uninstalling/completed. * * @param string $plugin Plugin Slug * @return string|false diff --git a/includes/TaskManagers/ThemeInstallTaskManager.php b/includes/TaskManagers/ThemeInstallTaskManager.php index 74ac16333..6af803c8e 100644 --- a/includes/TaskManagers/ThemeInstallTaskManager.php +++ b/includes/TaskManagers/ThemeInstallTaskManager.php @@ -43,7 +43,7 @@ public function __construct() { } /** - * Retrieve the Queue Name. + * Retrieve the Queue Name for the TaskManager to perform Theme installation. * * @return string */ @@ -192,7 +192,7 @@ public static function add_to_queue( ThemeInstallTask $theme_install_task ) { } /** - * Returns the status of given plugin slug. + * Returns the status of given plugin slug - installing/completed. * * @param string $theme Theme Slug * @return string|false From 497cc326bd2383c25b62a24a9d87dcf6c2552c05 Mon Sep 17 00:00:00 2001 From: Yashita Date: Tue, 23 May 2023 13:09:56 +0530 Subject: [PATCH 09/10] resolved spell check errors --- includes/Data/Flows.php | 2 +- includes/Data/Patterns.php | 2 +- includes/LoginRedirect.php | 2 +- includes/Models/Theme.php | 8 +++---- includes/ModuleController.php | 2 +- includes/RestApi/RestApiFilter.php | 8 +++---- .../Themes/ThemeVariationsController.php | 2 +- includes/Services/FlowService.php | 2 +- includes/Services/ThemeInstaller.php | 22 +++++++++---------- .../PluginUninstallTaskManager.php | 2 +- .../TaskManagers/ThemeInstallTaskManager.php | 2 +- includes/WP_Admin.php | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/includes/Data/Flows.php b/includes/Data/Flows.php index a04f56778..3e60bb629 100644 --- a/includes/Data/Flows.php +++ b/includes/Data/Flows.php @@ -167,7 +167,7 @@ public static function get_default_flow() { } /** - * Retrive all the known onboarding flows. + * Retrieve all the known onboarding flows. * * @return array A value of true for each key indicates that the flow has been approved * and a value of null indicates the flow has not been approved (or) has been temporarily disabled. diff --git a/includes/Data/Patterns.php b/includes/Data/Patterns.php index 59789e946..5dd880e4b 100644 --- a/includes/Data/Patterns.php +++ b/includes/Data/Patterns.php @@ -214,7 +214,7 @@ public static function get_pattern_from_slug( $pattern_slug ) { * Replace the header menu slug in the patterns array * * @param array $patterns Patterns for the specific step - * @param string $header_menu_slug header menu slug choosen by the user + * @param string $header_menu_slug header menu slug chosen by the user * * @return array */ diff --git a/includes/LoginRedirect.php b/includes/LoginRedirect.php index e69c7d76b..ff7c8c2d0 100644 --- a/includes/LoginRedirect.php +++ b/includes/LoginRedirect.php @@ -28,7 +28,7 @@ public static function sso( $original_redirect ) { */ public static function wplogin( $original_redirect, $requested_original_redirect, $user ) { // wp-login.php runs this filter on load and login failures - // We should only do a redirect with a succesful user login + // We should only do a redirect with a successful user login if ( ! ( $user instanceof \WP_User ) ) { return $original_redirect; } diff --git a/includes/Models/Theme.php b/includes/Models/Theme.php index 721eabc08..49bef74a9 100644 --- a/includes/Models/Theme.php +++ b/includes/Models/Theme.php @@ -41,7 +41,7 @@ public function __construct( $theme_name ) { /** * Sets the Theme Name * - * @param string $theme_name Theme Name + * @param string $theme_name name of the theme. * @return void */ public function set_theme_name( $theme_name ) { @@ -77,9 +77,9 @@ public function get_theme_image() { } /** - * Sets the status of a theme as a newfold theme. + * Sets the status of a theme as a Newfold theme. * - * @param boolean $is_newfold_theme Determines if there is a newfold theme + * @param boolean $is_newfold_theme Determines if there is a Newfold theme * @return void */ public function set_is_newfold_theme( $is_newfold_theme ) { @@ -96,7 +96,7 @@ public function get_is_newfold_theme() { } /** - * To JSON Serialise the Theme data + * To JSON Serialize the Theme data * * @return array */ diff --git a/includes/ModuleController.php b/includes/ModuleController.php index 6de4298b2..93a830e95 100644 --- a/includes/ModuleController.php +++ b/includes/ModuleController.php @@ -37,7 +37,7 @@ public static function module_switcher() { $enable_onboarding = self::verify_onboarding_criteria( $customer_data ); - // Check if he is a Non-Ecom Cust and Disable Redirect and Module + // Check if he is a Non-Ecommerce Customer and Disable Redirect and Module if ( ! $enable_onboarding ) { // Check if the Module Does Exist diff --git a/includes/RestApi/RestApiFilter.php b/includes/RestApi/RestApiFilter.php index 4b56c9fd6..38cdfb5c3 100644 --- a/includes/RestApi/RestApiFilter.php +++ b/includes/RestApi/RestApiFilter.php @@ -77,7 +77,7 @@ public static function wp_onboarding_nav_menu_filter( $response, $args ) { } /** - * Modify the reponse to make sure it has the dummy pages. + * Modify the response to make sure it has the dummy pages. * * @param array $data - array containing navigation menu data * @param integer $index - array index from the pages list @@ -140,7 +140,7 @@ public static function is_request_from_onboarding_flow( \WP_REST_Request $reques } /** - * Modify the reponse to make sure it has the dummy pages. + * Modify the response to make sure it has the dummy pages. * * @param array $response - response array * @@ -170,9 +170,9 @@ public static function modify_get_pages_response( $response ) { } /** - * Modify the reponse to make sure it has the dummy pages. + * Modify the response to make sure it has the dummy pages. * - * @param array $page - array containing page attibutes + * @param array $page - array containing page attributes * @param integer $index - array index from the pages list * * @return array diff --git a/includes/RestApi/Themes/ThemeVariationsController.php b/includes/RestApi/Themes/ThemeVariationsController.php index 8dbd6d654..1f75098ba 100644 --- a/includes/RestApi/Themes/ThemeVariationsController.php +++ b/includes/RestApi/Themes/ThemeVariationsController.php @@ -58,7 +58,7 @@ public function register_routes() { /** * Get the patterns arguments. - * Retrieves the orginal numerous variations if true, else sends the recently saved theme settings in the DB. + * Retrieves the original numerous variations if true, else sends the recently saved theme settings in the DB. * * @return array */ diff --git a/includes/Services/FlowService.php b/includes/Services/FlowService.php index dab38ca00..eb773e8c7 100644 --- a/includes/Services/FlowService.php +++ b/includes/Services/FlowService.php @@ -93,7 +93,7 @@ public static function update_flow_data( $params ) { $flow_data = array_replace_recursive( $flow_data, $params ); - // Update timestamp everytime the Onboarding flow data is updated. + // Update timestamp every time the Onboarding flow data is updated. $flow_data['updatedAt'] = time(); // Update Blog Information from Basic Info diff --git a/includes/Services/ThemeInstaller.php b/includes/Services/ThemeInstaller.php index 7c2b5c433..d4b8ed579 100644 --- a/includes/Services/ThemeInstaller.php +++ b/includes/Services/ThemeInstaller.php @@ -9,20 +9,20 @@ class ThemeInstaller { /** - * Install valid and accesible Themes based on the activation status. + * Install a whitelisted Theme based on the activation status. * - * @param string $theme Theme URL. - * @param boolean $activate Activate Status. + * @param string $theme Theme URL from Themes.php. + * @param boolean $activate Whether to activate the theme after install. * @return \WP_REST_Response|\WP_Error */ public static function install( $theme, $activate ) { $theme_list = Themes::get(); - // Checks if the theme slug is an nfd slug. + // Checks if the theme slug is an nfd slug. if ( self::is_nfd_slug( $theme ) ) { - // Retrieve the theme stylesheet to determine if it has been already installed. + // Retrieve the theme stylesheet to determine if it has been already installed. $stylesheet = $theme_list['nfd_slugs'][ $theme ]['stylesheet']; - // Check if the theme already exists. + // Check if the theme already exists. if ( ! ( \wp_get_theme( $stylesheet ) )->exists() ) { $status = self::install_from_zip( $theme_list['nfd_slugs'][ $theme ]['url'], @@ -39,7 +39,7 @@ public static function install( $theme, $activate ) { ); } - // If specified then activate the theme even if it already installed. + // If specified then activate the theme even if it already installed. if ( $activate && ( ( \wp_get_theme() )->get( 'TextDomain' ) !== $stylesheet ) ) { $status = \switch_theme( $stylesheet ); } @@ -52,10 +52,10 @@ public static function install( $theme, $activate ) { } /** - * Install theme from an approved zip url if not already installed. Activate and switch to the theme, if specified. + * Install theme from an custom zip url if not already installed. Activate and switch to the theme, if specified. * - * @param string $url URL to the zip for the plugin. - * @param boolean $activate Activate Status. + * @param string $url The ZIP URL to install the theme from. + * @param boolean $activate Whether to activate the plugin after install. * @param string $stylesheet Theme Stylesheet Name. * @return \WP_REST_Response|\WP_Error */ @@ -103,7 +103,7 @@ public static function install_from_zip( $url, $activate, $stylesheet ) { ); } - // Activate the theme if specified. + // Activate the theme if specified. if ( $activate && ( ( \wp_get_theme() )->get( 'TextDomain' ) !== $stylesheet ) ) { \switch_theme( $stylesheet ); } diff --git a/includes/TaskManagers/PluginUninstallTaskManager.php b/includes/TaskManagers/PluginUninstallTaskManager.php index 8c732a048..754b282be 100644 --- a/includes/TaskManagers/PluginUninstallTaskManager.php +++ b/includes/TaskManagers/PluginUninstallTaskManager.php @@ -43,7 +43,7 @@ public function __construct() { } /** - * Retrieve the Queue Name for the TaskManager to perform Plugin uninstallation. + * Retrieve the Queue Name for the TaskManager to perform Plugin Uninstalls. * * @return string */ diff --git a/includes/TaskManagers/ThemeInstallTaskManager.php b/includes/TaskManagers/ThemeInstallTaskManager.php index 6af803c8e..b981ce365 100644 --- a/includes/TaskManagers/ThemeInstallTaskManager.php +++ b/includes/TaskManagers/ThemeInstallTaskManager.php @@ -159,7 +159,7 @@ public function install() { * Adds a new ThemeInstallTask to the Theme Install queue. * The Task will be inserted at an appropriate position in the queue based on it's priority. * - * @param ThemeInstallTask $theme_install_task Theme Intsall Task to add to the queue + * @param ThemeInstallTask $theme_install_task Theme Install Task to add to the queue * @return array|false */ public static function add_to_queue( ThemeInstallTask $theme_install_task ) { diff --git a/includes/WP_Admin.php b/includes/WP_Admin.php index 297dc4802..77e9dc846 100644 --- a/includes/WP_Admin.php +++ b/includes/WP_Admin.php @@ -109,7 +109,7 @@ public static function register_assets() { } /** - * Initialise Plugins and Themes if necessary. + * Initialize Plugins and Themes if necessary. * * @return void */ From 3b530fb97ec5710a8455c2111cd0bb19ec5b2b09 Mon Sep 17 00:00:00 2001 From: Yashita Date: Wed, 24 May 2023 01:05:48 +0530 Subject: [PATCH 10/10] Update Brands.php --- includes/Data/Brands.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index d77c4754e..513a5c3f5 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -285,7 +285,7 @@ public static function get_brands() { /** * Sets the hosting brand for which Onboarding is active. * - * @param array $container The brand plugin container. + * @param object $container The brand plugin container. * @return void */ public static function set_current_brand( $container ) {