Skip to content

Commit

Permalink
Blaze: rely on method instead of filter to check for eligibility
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeherve committed Jan 13, 2023
1 parent 21c9c9d commit f8b9264
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Masterbar: update Blaze conditions to rely on the existing method from the package.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Automattic\Jetpack\Dashboard_Customizations;

use Automattic\Jetpack\Blaze;
use Automattic\Jetpack\Connection\Client;
use Jetpack_Plan;

Expand Down Expand Up @@ -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 );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Automattic\Jetpack\Dashboard_Customizations;

use Automattic\Jetpack\Blaze;
use JITM;

require_once __DIR__ . '/class-admin-menu.php';
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit f8b9264

Please sign in to comment.