From 7ccf9de1639619f894d7def416156e54cc5ca2e8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Sep 2023 13:41:59 +0200 Subject: [PATCH 1/6] Admin_Notifications::add_notification(): bug fix The `Admin_Notifications::add_notification()` method only expects one parameter, so no need to ask WP for 2. --- src/admin-notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admin-notifications.php b/src/admin-notifications.php index db6c02c..4aaff16 100644 --- a/src/admin-notifications.php +++ b/src/admin-notifications.php @@ -20,7 +20,7 @@ class Admin_Notifications implements Integration { * @return void */ public function add_hooks() { - \add_action( 'Yoast\WP\Test_Helper\notification', [ $this, 'add_notification' ], 10, 2 ); + \add_action( 'Yoast\WP\Test_Helper\notification', [ $this, 'add_notification' ] ); \add_action( 'Yoast\WP\Test_Helper\notifications', [ $this, 'display_notifications' ] ); } From b4bea4c9a919acfa3d661a656360c391b8c897b1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Sep 2023 13:42:53 +0200 Subject: [PATCH 2/6] Downgrader::downgrade(): bug fix The `$adapter` property does not exist. The `$adapter` local variable does. --- src/downgrader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/downgrader.php b/src/downgrader.php index e65d9ea..cc849f8 100644 --- a/src/downgrader.php +++ b/src/downgrader.php @@ -151,7 +151,7 @@ protected function downgrade( $target_version ) { $adapter->remove_version( $version ); $adapter->commit_transaction(); } catch ( Exception $e ) { - $this->adapter->rollback_transaction(); + $adapter->rollback_transaction(); throw new Exception( \sprintf( From 6249daf47bc68ad4c95a9056443ed717f3b97ec0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Sep 2023 13:43:35 +0200 Subject: [PATCH 3/6] Feature_Toggler::add_hooks(): use the correct function The `wpseo_enable_feature` hook is a filter, not an action. --- src/feature-toggler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/feature-toggler.php b/src/feature-toggler.php index 15fa9a4..3ad81d6 100644 --- a/src/feature-toggler.php +++ b/src/feature-toggler.php @@ -36,7 +36,7 @@ public function __construct( Option $option ) { * @return void */ public function add_hooks() { - \add_action( 'wpseo_enable_feature', [ $this, 'enable_features' ] ); + \add_filter( 'wpseo_enable_feature', [ $this, 'enable_features' ] ); \add_action( 'admin_post_yoast_seo_feature_toggler', From 75912ac6db5190cfdd9efe4f758e4ac2e8bb09d1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Sep 2023 13:44:42 +0200 Subject: [PATCH 4/6] Plugin_Toggler::verify_nonce(): consistent return type The return type is documented as `bool`, but the function contained a path which didn't return any value. Fixed now. --- src/plugin-toggler.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugin-toggler.php b/src/plugin-toggler.php index d5f268e..faa2377 100644 --- a/src/plugin-toggler.php +++ b/src/plugin-toggler.php @@ -431,6 +431,8 @@ private function verify_nonce() { if ( isset( $_GET['ajax_nonce'] ) && \wp_verify_nonce( $_GET['ajax_nonce'], 'yoast-plugin-toggle' ) ) { return true; } + + return false; } /** From 3b74fcd54e5de169ddc5cdd2583b566c147c3470 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Sep 2023 13:49:59 +0200 Subject: [PATCH 5/6] Admin_Page::add_assets(): bug fix The third (`$deps`) parameter for `wp_enqueue_style()` expects an array of strings, not `null`. Ref: https://developer.wordpress.org/reference/functions/wp_enqueue_style/ --- src/admin-page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admin-page.php b/src/admin-page.php index 12c486b..8087d53 100644 --- a/src/admin-page.php +++ b/src/admin-page.php @@ -44,7 +44,7 @@ public function add_assets() { \wp_enqueue_style( 'yoast-test-admin-style', \plugin_dir_url( \YOAST_TEST_HELPER_FILE ) . 'assets/css/admin.css', - null, + [], \YOAST_TEST_HELPER_VERSION ); \wp_enqueue_script( 'masonry' ); From 395d8bf1933fa142f5233ff231b63c51d2f5d914 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Sep 2023 13:51:45 +0200 Subject: [PATCH 6/6] Plugin_Toggler::activate_plugin(): bug fix The second (`$redirect`) parameter for `activate_plugin()` expects a string, not `null`. Ref: https://developer.wordpress.org/reference/functions/activate_plugin/ --- src/plugin-toggler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin-toggler.php b/src/plugin-toggler.php index faa2377..08d199e 100644 --- a/src/plugin-toggler.php +++ b/src/plugin-toggler.php @@ -394,7 +394,7 @@ private function activate_plugin( $group, $plugin ) { } $plugin_path = $this->plugin_groups[ $group ][ $plugin ]; - \activate_plugin( \plugin_basename( $plugin_path ), null, false, true ); + \activate_plugin( \plugin_basename( $plugin_path ), '', false, true ); } /**