From d0710a54874b7a16d5e41001c77a9e1b67de0566 Mon Sep 17 00:00:00 2001 From: Louis Laugesen Date: Fri, 17 Jan 2025 13:00:59 +1100 Subject: [PATCH 1/4] Hide Performance menu item when duplciate views experiment is enabled --- .../masterbar/src/admin-menu/class-atomic-admin-menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php b/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php index 2a723cc124ac2..cb8825736b745 100644 --- a/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php +++ b/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php @@ -448,7 +448,7 @@ function_exists( 'wpcom_is_duplicate_views_experiment_enabled' ) && // Hide Settings > Performance when the interface is set to wp-admin. // This is due to these settings are mostly also available in Jetpack > Settings, in the Performance tab. - if ( $this->use_wp_admin_interface() ) { + if ( $this->use_wp_admin_interface() || ( function_exists( 'wpcom_is_duplicate_views_experiment_enabled' ) && wpcom_is_duplicate_views_experiment_enabled() ) ) { $this->hide_submenu_page( 'options-general.php', 'https://wordpress.com/settings/performance/' . $this->domain ); } } From 6cf27c670d88586125e4e501c88cae14aadfd8b4 Mon Sep 17 00:00:00 2001 From: Louis Laugesen Date: Fri, 17 Jan 2025 13:02:10 +1100 Subject: [PATCH 2/4] changelog --- .../masterbar/changelog/update-remove-performance-menu-item | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/masterbar/changelog/update-remove-performance-menu-item diff --git a/projects/packages/masterbar/changelog/update-remove-performance-menu-item b/projects/packages/masterbar/changelog/update-remove-performance-menu-item new file mode 100644 index 0000000000000..9ce2c1f9e01ac --- /dev/null +++ b/projects/packages/masterbar/changelog/update-remove-performance-menu-item @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Hides the Performance menu item on wordpress.com From 44b01f6e2843d0ab730ac4a5cd8970e3d57325e5 Mon Sep 17 00:00:00 2001 From: Louis Laugesen Date: Fri, 17 Jan 2025 13:10:41 +1100 Subject: [PATCH 3/4] Instead of hiding, don't add it instead - covers simple and atomic. --- .../packages/masterbar/src/admin-menu/class-admin-menu.php | 5 ++++- .../masterbar/src/admin-menu/class-atomic-admin-menu.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/packages/masterbar/src/admin-menu/class-admin-menu.php b/projects/packages/masterbar/src/admin-menu/class-admin-menu.php index 3b0085f29391d..4faec86b22c0d 100644 --- a/projects/packages/masterbar/src/admin-menu/class-admin-menu.php +++ b/projects/packages/masterbar/src/admin-menu/class-admin-menu.php @@ -396,7 +396,10 @@ public function add_options_menu() { // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. add_submenu_page( 'options-general.php', esc_attr__( 'Podcasting', 'jetpack-masterbar' ), __( 'Podcasting', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/podcasting/' . $this->domain, null, 8 ); // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. - add_submenu_page( 'options-general.php', esc_attr__( 'Performance', 'jetpack-masterbar' ), __( 'Performance', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/performance/' . $this->domain, null, 9 ); + + if ( function_exists( 'wpcom_is_duplicate_views_experiment_enabled' ) && ! wpcom_is_duplicate_views_experiment_enabled() ) { + add_submenu_page( 'options-general.php', esc_attr__( 'Performance', 'jetpack-masterbar' ), __( 'Performance', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/performance/' . $this->domain, null, 9 ); + } } /** diff --git a/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php b/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php index cb8825736b745..2a723cc124ac2 100644 --- a/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php +++ b/projects/packages/masterbar/src/admin-menu/class-atomic-admin-menu.php @@ -448,7 +448,7 @@ function_exists( 'wpcom_is_duplicate_views_experiment_enabled' ) && // Hide Settings > Performance when the interface is set to wp-admin. // This is due to these settings are mostly also available in Jetpack > Settings, in the Performance tab. - if ( $this->use_wp_admin_interface() || ( function_exists( 'wpcom_is_duplicate_views_experiment_enabled' ) && wpcom_is_duplicate_views_experiment_enabled() ) ) { + if ( $this->use_wp_admin_interface() ) { $this->hide_submenu_page( 'options-general.php', 'https://wordpress.com/settings/performance/' . $this->domain ); } } From 64465eea8e6667919bb8a6aad6bb0a698bdb4a74 Mon Sep 17 00:00:00 2001 From: Louis Laugesen Date: Fri, 17 Jan 2025 16:35:43 +1100 Subject: [PATCH 4/4] Fix phan-suppress annotation placement --- projects/packages/masterbar/src/admin-menu/class-admin-menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/packages/masterbar/src/admin-menu/class-admin-menu.php b/projects/packages/masterbar/src/admin-menu/class-admin-menu.php index 4faec86b22c0d..4e52f6f966f05 100644 --- a/projects/packages/masterbar/src/admin-menu/class-admin-menu.php +++ b/projects/packages/masterbar/src/admin-menu/class-admin-menu.php @@ -395,9 +395,9 @@ public function add_options_menu() { add_submenu_page( 'options-general.php', esc_attr__( 'Newsletter', 'jetpack-masterbar' ), __( 'Newsletter', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/newsletter/' . $this->domain, null, 7 ); // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. add_submenu_page( 'options-general.php', esc_attr__( 'Podcasting', 'jetpack-masterbar' ), __( 'Podcasting', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/podcasting/' . $this->domain, null, 8 ); - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. if ( function_exists( 'wpcom_is_duplicate_views_experiment_enabled' ) && ! wpcom_is_duplicate_views_experiment_enabled() ) { + // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. add_submenu_page( 'options-general.php', esc_attr__( 'Performance', 'jetpack-masterbar' ), __( 'Performance', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/performance/' . $this->domain, null, 9 ); } }