From 2fa7e7e8ea7eb786692fb619d22ece19ff97074e Mon Sep 17 00:00:00 2001 From: Mamatha Rao Date: Tue, 18 Jun 2024 15:43:40 +0530 Subject: [PATCH 1/3] Lint Fixes --- includes/Data/Brands.php | 85 +++++++------- includes/Data/Plugins.php | 129 ++++++++++++---------- includes/ECommerce.php | 19 ++-- includes/I18nService.php | 3 +- includes/Partials/CaptiveFlow.php | 89 +++++++++++---- includes/Partials/WooCommerceBacklink.php | 36 +++++- includes/Permissions.php | 4 +- 7 files changed, 228 insertions(+), 137 deletions(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index f53d84b3..4bf04be5 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -6,6 +6,12 @@ * Contains Brand information. */ final class Brands { + /** + * Retrieve and sanitize the brand name from the container. + * + * @param Container $container The container object that holds the plugin instance. + * @return string The sanitized brand name + * */ private static function get_brand_name( Container $container ) { $brand_raw_value = $container->plugin()->brand; return \sanitize_title( str_replace( '_', '-', $brand_raw_value ) ); @@ -13,6 +19,7 @@ private static function get_brand_name( Container $container ) { /** * Brand specific data * + * @param Container $container The container object * @return array */ public static function get_config( Container $container ) { @@ -20,78 +27,78 @@ public static function get_config( Container $container ) { switch ( $brand ) { case 'crazy-domains': return array( - 'brand' => 'crazy-domains', - 'name' => 'CrazyDomains', - 'url' => 'https://crazydomains.com', - 'hireExpertsInfo' => 'admin.php?page=crazy-domains#/marketplace/services/blue-sky', - 'support' => 'https://www.crazydomains.in/contact', - 'adminPage' => 'admin.php?page=crazy-domains', - 'setup' => array( + 'brand' => 'crazy-domains', + 'name' => 'CrazyDomains', + 'url' => 'https://crazydomains.com', + 'hireExpertsInfo' => 'admin.php?page=crazy-domains#/marketplace/services/blue-sky', + 'support' => 'https://www.crazydomains.in/contact', + 'adminPage' => 'admin.php?page=crazy-domains', + 'setup' => array( 'payment' => array( 'Paypal' ), 'shipping' => array( 'Shippo' ), ), - 'defaultContact' => array( + 'defaultContact' => array( 'woocommerce_default_country' => 'AU:NSW', 'woocommerce_currency' => 'AUD', ), - 'wondercartBuyNow' => '' + 'wondercartBuyNow' => '', ); case 'bluehost-india': return array( - 'brand' => 'bluehost-india', - 'name' => 'Bluehost', - 'url' => 'https://bluehost.in', - 'hireExpertsInfo' => 'https://www.bluehost.in/solutions/full-service', - 'support' => 'https://helpchat.bluehost.in', - 'adminPage' => 'admin.php?page=bluehost', - 'setup' => array( - 'payment' => array('Paypal', 'Razorpay', 'Stripe'), + 'brand' => 'bluehost-india', + 'name' => 'Bluehost', + 'url' => 'https://bluehost.in', + 'hireExpertsInfo' => 'https://www.bluehost.in/solutions/full-service', + 'support' => 'https://helpchat.bluehost.in', + 'adminPage' => 'admin.php?page=bluehost', + 'setup' => array( + 'payment' => array( 'Paypal', 'Razorpay', 'Stripe' ), 'shipping' => array(), ), - 'defaultContact' => array( + 'defaultContact' => array( 'woocommerce_default_country' => 'IN:AP', 'woocommerce_currency' => 'INR', ), - 'wondercartBuyNow' => '' + 'wondercartBuyNow' => '', ); case 'hostgator': case 'hostgator-latam': return array( - 'brand' => 'hostgator', - 'name' => 'hostgator', - 'url' => 'https://hostgator.com', - 'hireExpertsInfo' => 'admin.php?page=hostgator#/marketplace/services/blue-sky', - 'support' => 'https://www.hostgator.com/contact', - 'adminPage' => 'admin.php?page=hostgator', - 'setup' => array( + 'brand' => 'hostgator', + 'name' => 'hostgator', + 'url' => 'https://hostgator.com', + 'hireExpertsInfo' => 'admin.php?page=hostgator#/marketplace/services/blue-sky', + 'support' => 'https://www.hostgator.com/contact', + 'adminPage' => 'admin.php?page=hostgator', + 'setup' => array( 'payment' => array( 'Paypal', 'Razorpay', 'Stripe' ), 'shipping' => array(), ), - 'defaultContact' => array( + 'defaultContact' => array( 'woocommerce_default_country' => 'BR:AL', 'woocommerce_currency' => 'BRL', ), - 'wondercartBuyNow' => '' + 'wondercartBuyNow' => '', ); case 'bluehost': default: return array( - 'brand' => 'bluehost', - 'name' => 'Bluehost', - 'url' => 'https://bluehost.com', - 'hireExpertsInfo' => 'admin.php?page=bluehost#/marketplace/services/blue-sky', - 'support' => 'https://www.bluehost.com/contact', - 'adminPage' => 'admin.php?page=bluehost', - 'setup' => array( - 'payment' => array('Paypal', 'Razorpay', 'Stripe'), - 'shipping' => array('Shippo'), + 'brand' => 'bluehost', + 'name' => 'Bluehost', + 'url' => 'https://bluehost.com', + 'hireExpertsInfo' => 'admin.php?page=bluehost#/marketplace/services/blue-sky', + 'support' => 'https://www.bluehost.com/contact', + 'adminPage' => 'admin.php?page=bluehost', + 'setup' => array( + 'payment' => array( 'Paypal', 'Razorpay', 'Stripe' ), + 'shipping' => array( 'Shippo' ), ), - 'defaultContact' => array( + 'defaultContact' => array( 'woocommerce_default_country' => 'US:AZ', 'woocommerce_currency' => 'USD', ), - 'wondercartBuyNow' => 'https://my.bluehost.com/hosting/app?utm_source=wp-marketplace&utm_medium=brand-plugin&utm_campaign=wordpress-ad&utm_content=buynow#/marketplace/product' + 'wondercartBuyNow' => 'https://my.bluehost.com/hosting/app?utm_source=wp-marketplace&utm_medium=brand-plugin&utm_campaign=wordpress-ad&utm_content=buynow#/marketplace/product', ); } } diff --git a/includes/Data/Plugins.php b/includes/Data/Plugins.php index c2802b61..9346c406 100644 --- a/includes/Data/Plugins.php +++ b/includes/Data/Plugins.php @@ -4,111 +4,122 @@ /** * List of Plugin Slugs/Files */ -final class Plugins -{ +final class Plugins { + /** + * An associative array of free plugins with their corresponding admin page URLs and file paths. + * + * @var array> $free_plugins + */ public static $free_plugins = array( - 'jetpack' => array( - 'url' => 'admin.php?page=jetpack#/dashboard', + 'jetpack' => array( + 'url' => 'admin.php?page=jetpack#/dashboard', 'file' => 'jetpack/jetpack.php', ), - 'jetpack-boost' => array( - 'url' => 'admin.php?page=jetpack-boost', + 'jetpack-boost' => array( + 'url' => 'admin.php?page=jetpack-boost', 'file' => 'jetpack-boost/jetpack-boost.php', ), - 'wordpress-seo' => array( - 'url' => 'admin.php?page=wpseo_dashboard', + 'wordpress-seo' => array( + 'url' => 'admin.php?page=wpseo_dashboard', 'file' => 'wordpress-seo/wp-seo.php', ), - 'wpforms-lite' => array( - 'url' => 'admin.php?page=wpforms-overview', + 'wpforms-lite' => array( + 'url' => 'admin.php?page=wpforms-overview', 'file' => 'wpforms-lite/wpforms.php', ), - 'google-analytics-for-wordpress' => array( - 'url' => 'admin.php?page=monsterinsights_reports', + 'google-analytics-for-wordpress' => array( + 'url' => 'admin.php?page=monsterinsights_reports', 'file' => 'google-analytics-for-wordpress/googleanalytics.php', ), - 'optinmonster' => array( - 'url' => 'admin.php?page=optin-monster-dashboard', + 'optinmonster' => array( + 'url' => 'admin.php?page=optin-monster-dashboard', 'file' => 'optinmonster/optin-monster-wp-api.php', ), 'creative-mail-by-constant-contact' => array( - 'url' => 'admin.php?page=creativemail', + 'url' => 'admin.php?page=creativemail', 'file' => 'creative-mail-by-constant-contact/creative-mail-plugin.php', ), ); - + /** + * An associative array of supported plugins with their corresponding file paths and admin page URLs. + * + * @var array> $supported_plugins + */ public static $supported_plugins = array( - 'woocommerce' => array( + 'woocommerce' => array( 'file' => 'woocommerce/woocommerce.php', - 'url' => 'admin.php?page=wc-settings', + 'url' => 'admin.php?page=wc-settings', ), 'nfd_slug_yith_woocommerce_customize_myaccount_page' => array( 'file_extended' => 'yith-woocommerce-customize-myaccount-page-extended/init.php', - 'file_premium' => 'yith-woocommerce-customize-myaccount-page-premium/init.php', - 'file' => 'yith-woocommerce-customize-myaccount-page/init.php', - 'url' => 'admin.php?page=yith_wcmap_panel', + 'file_premium' => 'yith-woocommerce-customize-myaccount-page-premium/init.php', + 'file' => 'yith-woocommerce-customize-myaccount-page/init.php', + 'url' => 'admin.php?page=yith_wcmap_panel', ), - 'nfd_slug_yith_woocommerce_gift_cards' => array( + 'nfd_slug_yith_woocommerce_gift_cards' => array( 'file_extended' => 'yith-woocommerce-gift-cards-extended/init.php', - 'file_premium' => 'yith-woocommerce-gift-cards-premium/init.php', - 'file' => 'yith-woocommerce-gift-cards/init.php', - 'url' => 'admin.php?page=yith_woocommerce_gift_cards_panel', + 'file_premium' => 'yith-woocommerce-gift-cards-premium/init.php', + 'file' => 'yith-woocommerce-gift-cards/init.php', + 'url' => 'admin.php?page=yith_woocommerce_gift_cards_panel', ), - 'nfd_slug_yith_woocommerce_wishlist' => array( + 'nfd_slug_yith_woocommerce_wishlist' => array( 'file_extended' => 'yith-woocommerce-wishlist-extended/init.php', - 'file_premium' => 'yith-woocommerce-wishlist-premium/init.php', - 'file' => 'yith-woocommerce-wishlist/init.php', - 'url' => 'admin.php?page=yith_wcwl_panel', + 'file_premium' => 'yith-woocommerce-wishlist-premium/init.php', + 'file' => 'yith-woocommerce-wishlist/init.php', + 'url' => 'admin.php?page=yith_wcwl_panel', ), - 'nfd_slug_yith_woocommerce_ajax_product_filter' => array( + 'nfd_slug_yith_woocommerce_ajax_product_filter' => array( 'file_extended' => 'yith-woocommerce-ajax-product-filter-extended/init.php', - 'file_premium' => 'yith-woocommerce-ajax-product-filter-premium/init.php', - 'file' => 'yith-woocommerce-ajax-product-filter/init.php', - 'url' => 'admin.php?page=yith_wcan_panel', + 'file_premium' => 'yith-woocommerce-ajax-product-filter-premium/init.php', + 'file' => 'yith-woocommerce-ajax-product-filter/init.php', + 'url' => 'admin.php?page=yith_wcan_panel', ), - 'nfd_slug_yith_woocommerce_booking' => array( + 'nfd_slug_yith_woocommerce_booking' => array( 'file_extended' => 'yith-woocommerce-booking-extended/init.php', - 'file_premium' => 'yith-woocommerce-booking-premium/init.php', - 'file' => 'yith-woocommerce-booking/init.php', - 'url' => 'admin.php?page=yith_wcbk_panel', + 'file_premium' => 'yith-woocommerce-booking-premium/init.php', + 'file' => 'yith-woocommerce-booking/init.php', + 'url' => 'admin.php?page=yith_wcbk_panel', ), - 'yith-woocommerce-ajax-search' => array( + 'yith-woocommerce-ajax-search' => array( 'file_extended' => 'yith-woocommerce-ajax-search-extended/init.php', - 'file_premium' => 'yith-woocommerce-ajax-search-premium/init.php', - 'file' => 'yith-woocommerce-ajax-search/init.php', - 'url' => 'admin.php?page=yith_wcas_panel', + 'file_premium' => 'yith-woocommerce-ajax-search-premium/init.php', + 'file' => 'yith-woocommerce-ajax-search/init.php', + 'url' => 'admin.php?page=yith_wcas_panel', ), 'nfd_slug_yith_shippo_shippings_for_woocommerce' => array( 'file' => 'yith-shippo-shippings-for-woocommerce-extended/init.php', - 'url' => 'admin.php?page=yith_shippo_shipping_for_woocommerce', + 'url' => 'admin.php?page=yith_shippo_shipping_for_woocommerce', ), - 'nfd_slug_yith_paypal_payments_for_woocommerce' => array( + 'nfd_slug_yith_paypal_payments_for_woocommerce' => array( 'file' => 'yith-paypal-payments-for-woocommerce-extended/init.php', - 'url' => 'admin.php?page=yith_paypal_payments', + 'url' => 'admin.php?page=yith_paypal_payments', ), - 'nfd_slug_ecomdash_wordpress_plugin' => array( + 'nfd_slug_ecomdash_wordpress_plugin' => array( 'file' => 'ecomdash-wordpress-plugin/ecomdash-plugin.php', - 'url' => 'admin.php?page=newfold-ecomdash', + 'url' => 'admin.php?page=newfold-ecomdash', ), - 'nfd_slug_woo_razorpay' => array( + 'nfd_slug_woo_razorpay' => array( 'file' => 'woo-razorpay/woo-razorpay.php', - 'url' => 'admin.php?page=wc-settings&tab=checkout§ion=razorpay', + 'url' => 'admin.php?page=wc-settings&tab=checkout§ion=razorpay', ), - 'nfd_slug_wonder_cart' => array( + 'nfd_slug_wonder_cart' => array( 'file' => 'wonder-cart/init.php', - 'url' => 'admin.php?page=wonder-cart', + 'url' => 'admin.php?page=wonder-cart', + ), + 'nfd_slug_yith_stripe_payments_for_woocommerce' => array( + 'file' => 'yith-stripe-payments-for-woocommerce-extended/init.php', + 'url' => 'admin.php?page=yith_stripe_payments_panel', ), - 'nfd_slug_yith_stripe_payments_for_woocommerce' => array( - 'file' => 'yith-stripe-payments-for-woocommerce-extended/init.php', - 'url' => 'admin.php?page=yith_stripe_payments_panel', - ) ); - public static function supported_plugins() - { - return array_merge(Plugins::$supported_plugins, Plugins::$free_plugins); + /** + * Get a merged array of supported and free plugins. + * + * @return array> A combined array of supported and free plugins. + */ + public static function supported_plugins() { + return array_merge( self::$supported_plugins, self::$free_plugins ); } - -} \ No newline at end of file +} diff --git a/includes/ECommerce.php b/includes/ECommerce.php index 50c4f4f2..fa57b978 100644 --- a/includes/ECommerce.php +++ b/includes/ECommerce.php @@ -106,8 +106,8 @@ public function __construct( Container $container ) { add_filter( 'manage_edit-page_sortable_columns', array( $this, 'sortable_columns' ) ); add_action( 'wp_login', array( $this, 'show_store_setup' ) ); add_action( 'auth_cookie_expired', array( $this, 'show_store_setup' ) ); - add_action('admin_head', array( $this, 'hide_wp_pointer_with_css' ) ); - add_action('admin_enqueue_scripts', array( $this, 'set_wpnav_collapse_setting')); + add_action( 'admin_head', array( $this, 'hide_wp_pointer_with_css' ) ); + add_action( 'admin_enqueue_scripts', array( $this, 'set_wpnav_collapse_setting' ) ); if ( ( $container->plugin()->id === 'bluehost' && ( $canAccessGlobalCTB || $hasYithExtended ) ) || ( $container->plugin()->id === 'hostgator' && $hasYithExtended ) ) { add_filter( 'admin_menu', array( $this, 'custom_add_promotion_menu_item' ) ); @@ -197,7 +197,7 @@ public static function add_filters( $tags, $function_to_add, $priority = 10, $ac } /** - * Set the wpnav_collapse setting + * Set the wpnav_collapse setting */ public function set_wpnav_collapse_setting() { @@ -460,7 +460,7 @@ public function custom_product_general_options() { wp_enqueue_style( 'Create_a_Promotion', NFD_ECOMMERCE_PLUGIN_URL . 'vendor/newfold-labs/wp-module-ecommerce/includes/Promotions.css', array(), '1.0', 'all' ); echo ''; } @@ -576,7 +576,7 @@ public function detect_plugin_activation( $plugin ) { * @return void */ public function hide_columns() { - if ( 1 == get_option( 'onboarding_experience_level' ) ) { + if ( 1 === get_option( 'onboarding_experience_level' ) ) { if ( ! get_user_meta( get_current_user_id(), 'manageedit-pagecolumnshidden' ) ) { update_user_meta( get_current_user_id(), 'manageedit-pagecolumnshidden', array( 'author', 'comments', 'date', 'wpseo-score', 'wpseo-score-readability', 'wpseo-title', 'wpseo-metadesc', 'wpseo-focuskw', 'wpseo-links' ) ); } @@ -592,7 +592,7 @@ public function hide_columns() { * @param array $columns Array of column names for posts/pages */ public function custom_status_column( $columns ) { - if ( 'product' != get_post_type() && 1 == get_option( 'onboarding_experience_level' ) ) { + if ( 'product' !== get_post_type() && 1 === get_option( 'onboarding_experience_level' ) ) { // Add 'Status' column after 'Title' $columns['status'] = __( 'Status', 'wp-module-ecommerce' ); } @@ -631,7 +631,7 @@ public function custom_status_column_content( $column_name, $post_id ) { if ( $coming_soon ) { $background_color = '#E8ECF0'; } - echo '' . $label_text . '
' . __( 'Last Modified', 'wp-module-ecommerce' ) . ' : ' . mysql2date( 'Y/m/d \a\t g:i a', $post_date ); + echo '' . esc_html( $label_text ) . '
' . esc_html( __( 'Last Modified', 'wp-module-ecommerce' ) ) . ' : ' . esc_html( mysql2date( 'Y/m/d \a\t g:i a', $post_date ) ); } } @@ -645,8 +645,8 @@ public function sortable_columns( $columns ) { return $columns; } - /* - * On login, it checks whether to show the migration steps, post migration to user + /** + * On login, it checks whether to show the migration steps, post migration to user */ public function show_store_setup() { $site_url = get_option( 'siteurl', false ); @@ -681,7 +681,6 @@ function check_url_match( $brand_name, $site_url ) { * * @return void */ - public function hide_wp_pointer_with_css() { echo '