From f8b9264c6b6676028ed6e849ed584d7154f679e5 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Fri, 13 Jan 2023 11:55:29 +0100 Subject: [PATCH] Blaze: rely on method instead of filter to check for eligibility See #28088 for another example of this. This is possible thanks to the recent improvements in that method. It also lays the foundation for us using that method to dynamically check for eligibility via an API call. --- .../changelog/update-blaze-conditions-masterbar | 4 ++++ projects/plugins/jetpack/class.jetpack.php | 4 ++++ .../admin-menu/class-atomic-admin-menu.php | 13 ++----------- .../masterbar/admin-menu/class-wpcom-admin-menu.php | 3 ++- 4 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/update-blaze-conditions-masterbar diff --git a/projects/plugins/jetpack/changelog/update-blaze-conditions-masterbar b/projects/plugins/jetpack/changelog/update-blaze-conditions-masterbar new file mode 100644 index 0000000000000..9518c0b94f339 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-blaze-conditions-masterbar @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Masterbar: update Blaze conditions to rely on the existing method from the package. diff --git a/projects/plugins/jetpack/class.jetpack.php b/projects/plugins/jetpack/class.jetpack.php index 79ab32ff78a1d..41846758f801f 100644 --- a/projects/plugins/jetpack/class.jetpack.php +++ b/projects/plugins/jetpack/class.jetpack.php @@ -6013,6 +6013,10 @@ public function deprecated_hooks() { 'replacement' => null, 'version' => 'jetpack-11.0.0', ), + 'jetpack_dsp_promote_posts_enabled' => array( + 'replacement' => null, + 'version' => 'jetpack-11.8.0', + ), ); foreach ( $filter_deprecated_list as $tag => $args ) { diff --git a/projects/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php b/projects/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php index cbd18116c5959..98b891b256358 100644 --- a/projects/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php +++ b/projects/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php @@ -7,6 +7,7 @@ namespace Automattic\Jetpack\Dashboard_Customizations; +use Automattic\Jetpack\Blaze; use Automattic\Jetpack\Connection\Client; use Jetpack_Plan; @@ -365,17 +366,7 @@ function_exists( 'wpcom_site_has_feature' ) && // performance settings already have a link to Page Optimize settings page. $this->hide_submenu_page( 'options-general.php', 'page-optimize' ); - /** - * Wether to show the Advertising menu under the main Tools menu. - * - * @module masterbar - * - * @since 11.4 - * - * @param bool $menu_enabled Wether the menu entry is shown. - * @param int $user_id The Advertising menu will be shown/hidden for this user. - */ - if ( apply_filters( 'jetpack_dsp_promote_posts_enabled', false, get_current_user_id() ) ) { + if ( Blaze::should_initialize() ) { add_submenu_page( 'tools.php', esc_attr__( 'Advertising', 'jetpack' ), __( 'Advertising', 'jetpack' ), 'manage_options', 'https://wordpress.com/advertising/' . $this->domain, null, 1 ); } } diff --git a/projects/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php b/projects/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php index 81a1f5f80cbab..155a61c55877a 100644 --- a/projects/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php +++ b/projects/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php @@ -7,6 +7,7 @@ namespace Automattic\Jetpack\Dashboard_Customizations; +use Automattic\Jetpack\Blaze; use JITM; require_once __DIR__ . '/class-admin-menu.php'; @@ -346,7 +347,7 @@ public function add_users_menu() { public function add_options_menu() { parent::add_options_menu(); - if ( apply_filters( 'dsp_promote_posts_enabled', false, get_current_user_id() ) ) { + if ( Blaze::should_initialize() ) { add_submenu_page( 'tools.php', esc_attr__( 'Advertising', 'jetpack' ), __( 'Advertising', 'jetpack' ), 'manage_options', 'https://wordpress.com/advertising/' . $this->domain, null, 1 ); } add_submenu_page( 'options-general.php', esc_attr__( 'Hosting Configuration', 'jetpack' ), __( 'Hosting Configuration', 'jetpack' ), 'manage_options', 'https://wordpress.com/hosting-config/' . $this->domain, null, 10 );