From c979b00f644032086c46df3ed098c1321cd7c1ac Mon Sep 17 00:00:00 2001 From: Arati Bhandare Date: Thu, 25 Apr 2024 12:49:42 +0530 Subject: [PATCH] Fix doing it wrong way notice for set_wpnav_collapse_setting function in Ecommerce.php file --- composer.lock | 24 ++++++++++++------------ includes/ECommerce.php | 12 ++++-------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/composer.lock b/composer.lock index 4845b00d..fb81236b 100644 --- a/composer.lock +++ b/composer.lock @@ -1585,16 +1585,16 @@ }, { "name": "newfold-labs/wp-php-standards", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-php-standards.git", - "reference": "e97e34d7d2df0cefdcb6f3c06714aae417b26044" + "reference": "a486fb541e890ee87dc387eaea0644101e728464" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-php-standards/zipball/e97e34d7d2df0cefdcb6f3c06714aae417b26044", - "reference": "e97e34d7d2df0cefdcb6f3c06714aae417b26044", + "url": "https://api.github.com/repos/newfold-labs/wp-php-standards/zipball/a486fb541e890ee87dc387eaea0644101e728464", + "reference": "a486fb541e890ee87dc387eaea0644101e728464", "shasum": "" }, "require": { @@ -1615,10 +1615,10 @@ ], "description": "PHP Code Sniffer Standards for Newfold WordPress projects.", "support": { - "source": "https://github.com/newfold-labs/wp-php-standards/tree/1.2.2", + "source": "https://github.com/newfold-labs/wp-php-standards/tree/1.2.3", "issues": "https://github.com/newfold-labs/wp-php-standards/issues" }, - "time": "2023-01-06T11:45:52+00:00" + "time": "2024-04-22T20:09:45+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -2196,16 +2196,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.1", + "version": "3.9.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", "shasum": "" }, "require": { @@ -2272,7 +2272,7 @@ "type": "open_collective" } ], - "time": "2024-03-31T21:03:09+00:00" + "time": "2024-04-23T20:25:34+00:00" }, { "name": "symfony/console", @@ -4911,5 +4911,5 @@ "platform-overrides": { "php": "7.0.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/includes/ECommerce.php b/includes/ECommerce.php index e6fbe90f..f74cfcbb 100644 --- a/includes/ECommerce.php +++ b/includes/ECommerce.php @@ -95,9 +95,7 @@ public function __construct( Container $container ) { add_action( 'before_woocommerce_init', array( $this, 'dismiss_woo_payments_cta' ) ); add_action( 'load-toplevel_page_' . $container->plugin()->id, array( $this, 'disable_creative_mail_banner' ) ); add_action( 'activated_plugin', array( $this, 'detect_plugin_activation' ), 10, 1 ); - - $brandNameValue = $container->plugin()->brand; - $this->set_wpnav_collapse_setting( $brandNameValue ); + 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' ) ); @@ -187,12 +185,11 @@ public static function add_filters( $tags, $function_to_add, $priority = 10, $ac } /** - * Set the wpnav_collapse setting - * - * @param string $brandNameValue The brand name value + * Set the wpnav_collapse setting */ - public static function set_wpnav_collapse_setting( $brandNameValue ) { + public function set_wpnav_collapse_setting() { + $brandNameValue = $this->container->plugin()->brand; wp_enqueue_script( 'nfd_wpnavbar_setting', NFD_ECOMMERCE_PLUGIN_URL . 'vendor/newfold-labs/wp-module-ecommerce/includes/wpnavbar.js', array( 'jquery' ), '1.0', true ); $params = array('nfdbrandname' => $brandNameValue); wp_localize_script( 'nfd_wpnavbar_setting', 'navBarParams', $params ); @@ -364,7 +361,6 @@ public function register_assets() { NFD_ECOMMERCE_DIR . '/languages' ); \wp_enqueue_script( 'nfd-ecommerce-dependency' ); - \wp_enqueue_script( 'nfd_wpnavbar_setting' ); } }