Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blaze: rely on method instead of filter to check for eligibility #28340

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeherve On my test WoA sites I'm seeing:

[27-Jan-2023 16:51:07 UTC] PHP Deprecated:  Hook jetpack_dsp_promote_posts_enabled is <strong>deprecated</strong> since version jetpack-11.8.0 with no alternative available. in /wordpress/core/6.1.1/wp-includes/functions.php on line 5768

Looks like jetpack_dsp_promote_posts_enabled is still referenced in a couple places, will that be able to be cleaned up in the future?

Copy link
Member Author

@jeherve jeherve Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter is still in use in wpcomsh, indeed. I think Calypso still relies on the /me endpoint, and thus that filter, to display some elements. @paulopmt1 would know for sure.

This should happen when 1532-gh-Automattic/dotcom-forge gets addressed. Once that's done, I think we should be safe to remove the filter from wpcomsh.

I created 1239-gh-wpcomsh to get everything ready on the wpcomsh end.

'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