Skip to content

Commit 6309fba

Browse files
mmtrmatticbot
authored andcommitted
Untangling: Show "Jetpack -> Monetize" menu on all sites (#44216)
- Move the `/earn/:site` menu to Jetpack > Monetize for all sites (previously only visible on the classic interface). - The existing Tools > Monetize will now point to `/earn/jetpack-monetize/:site` so we can inform users with a callout that the menu has been moved (see Automattic/wp-calypso#104629). This menu will be removed after a month, and it's only visible to existing users. - The logic for the Jetpack submenus in WP.com has been slightly refactored, since it was a nightmare to place a submenu in an exact position for both the default and the classic interface. It's now all handled in the `wpcom_add_jetpack_submenu` function. The position of the menus follows the same order than in self-hosted sites. Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/16343284073 Upstream-Ref: Automattic/jetpack@f90ba72
1 parent ae81ebb commit 6309fba

File tree

7 files changed

+241
-261
lines changed

7 files changed

+241
-261
lines changed

jetpack_vendor/automattic/jetpack-masterbar/src/admin-menu/class-admin-menu.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,11 @@ public function add_tools_menu() {
350350

351351
// @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
352352
add_submenu_page( 'tools.php', esc_attr__( 'Marketing', 'jetpack-masterbar' ), __( 'Marketing', 'jetpack-masterbar' ), 'publish_posts', 'https://wordpress.com/marketing/tools/' . $this->domain, null, 0 );
353-
if ( ! $this->use_wp_admin_interface() ) {
353+
354+
// Temporary "Tools > Monetize" menu for existing users that shows a callout informing that the screen has moved to "Jetpack > Monetize".
355+
if ( ! $this->use_wp_admin_interface() && get_current_user_id() < 268854000 ) {
354356
// @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
355-
add_submenu_page( 'tools.php', esc_attr__( 'Monetize', 'jetpack-masterbar' ), __( 'Monetize', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/earn/' . $this->domain, null, 1 );
357+
add_submenu_page( 'tools.php', esc_attr__( 'Monetize', 'jetpack-masterbar' ), __( 'Monetize', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/earn/jetpack-monetize/' . $this->domain, null, 1 );
356358
}
357359
}
358360

jetpack_vendor/automattic/jetpack-masterbar/src/class-main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class Main {
1616

17-
const PACKAGE_VERSION = '0.18.2';
17+
const PACKAGE_VERSION = '0.19.0-alpha';
1818

1919
/**
2020
* Initializer.

jetpack_vendor/automattic/jetpack-mu-wpcom/src/features/wpcom-admin-menu/wpcom-admin-menu.php

Lines changed: 73 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
* @package automattic/jetpack-mu-wpcom
88
*/
99

10-
use Automattic\Jetpack\Admin_UI\Admin_Menu as Jetpack_Admin_UI_Admin;
1110
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
1211
use Automattic\Jetpack\Redirect;
13-
use Automattic\Jetpack\Status;
1412
use Automattic\Jetpack\Subscribers_Dashboard\Dashboard as Subscribers_Dashboard;
1513

1614
/**
@@ -200,133 +198,104 @@ function wpcom_add_hosting_menu() {
200198
}
201199
add_action( 'admin_menu', 'wpcom_add_hosting_menu' );
202200

203-
/**
204-
* Register the submenu items for Jetpack menu.
205-
*
206-
* We require a separate function for this because the priority needs to be 999.
207-
*
208-
* @return void
209-
*/
210-
function wpcom_add_untangled_jetpack_menu() {
211-
$domain = wp_parse_url( home_url(), PHP_URL_HOST );
212-
213-
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-scanner' ) ) );
214-
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-backups' ) ) );
215-
216-
Jetpack_Admin_UI_Admin::add_menu(
217-
esc_attr__( 'Scan', 'jetpack-mu-wpcom' ),
218-
__( 'Scan', 'jetpack-mu-wpcom' ),
219-
'manage_options',
220-
'https://wordpress.com/scan/' . $domain,
221-
/**
222-
* Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
223-
*/
224-
null,
225-
5
226-
);
227-
228-
Jetpack_Admin_UI_Admin::add_menu(
229-
esc_attr__( 'Backup', 'jetpack-mu-wpcom' ),
230-
__( 'Backup', 'jetpack-mu-wpcom' ),
231-
'manage_options',
232-
'https://wordpress.com/backup/' . $domain,
233-
/**
234-
* Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
235-
*/
236-
null,
237-
4
238-
);
239-
}
240-
241-
add_action( 'admin_menu', 'wpcom_add_untangled_jetpack_menu', 999 );
242-
243201
/**
244202
* Adds WordPress.com submenu items related to Jetpack under the Jetpack admin menu.
245203
*/
246204
function wpcom_add_jetpack_submenu() {
247205
$is_simple_site = defined( 'IS_WPCOM' ) && IS_WPCOM;
248-
$is_atomic_site = ! $is_simple_site;
249206
$uses_wp_admin_interface = get_option( 'wpcom_admin_interface' ) === 'wp-admin';
250207

251-
if ( ! $uses_wp_admin_interface ) {
252-
return;
253-
}
254-
255-
if ( $is_atomic_site && ( ( new Status() )->is_offline_mode() || ! ( new Connection_Manager( 'jetpack' ) )->is_user_connected() ) ) {
256-
return;
257-
}
258-
259208
$blog_id = Connection_Manager::get_site_id();
260209
if ( is_wp_error( $blog_id ) ) {
261210
return;
262211
}
263212

264-
// Hide submenu items that link to Jetpack Cloud.
265-
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'cloud-activity-log-wp-menu', array( 'site' => $blog_id ) ) ) );
266-
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'cloud-scan-history-wp-menu' ) ) );
267-
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'jetpack-menu-jetpack-manage-subscribers', array( 'site' => $blog_id ) ) ) );
213+
$domain = wp_parse_url( home_url(), PHP_URL_HOST );
268214

269-
$domain = wp_parse_url( home_url(), PHP_URL_HOST );
270-
$activity_log_url = 'https://wordpress.com/activity-log/' . $domain;
271-
$monetize_url = 'https://wordpress.com/earn/' . $domain;
272-
$subscribers_url = 'https://wordpress.com/subscribers/' . $domain;
273-
$newsletter_url = 'https://wordpress.com/settings/newsletter/' . $domain;
274-
$podcasting_url = 'https://wordpress.com/settings/podcasting/' . $domain;
215+
// Jetpack > Scan.
216+
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'cloud-scan-history-wp-menu' ) ) );
217+
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-scanner' ) ) );
218+
add_submenu_page(
219+
'jetpack',
220+
esc_attr__( 'Scan', 'jetpack-mu-wpcom' ),
221+
__( 'Scan', 'jetpack-mu-wpcom' ),
222+
'manage_options',
223+
'https://wordpress.com/scan/' . $domain,
224+
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
225+
);
275226

276-
// Add submenu items that link to WordPress.com.
227+
// Jetpack > Backup.
228+
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-backups' ) ) );
277229
add_submenu_page(
278230
'jetpack',
279-
__( 'Activity Log', 'jetpack-mu-wpcom' ),
280-
__( 'Activity Log', 'jetpack-mu-wpcom' ),
231+
esc_attr__( 'Backup', 'jetpack-mu-wpcom' ),
232+
__( 'Backup', 'jetpack-mu-wpcom' ),
281233
'manage_options',
282-
$activity_log_url,
234+
'https://wordpress.com/backup/' . $domain,
283235
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
284236
);
285237

238+
// Jetpack > Monetize.
286239
add_submenu_page(
287240
'jetpack',
288-
__( 'Monetize', 'jetpack-mu-wpcom' ),
241+
esc_attr__( 'Monetize', 'jetpack-mu-wpcom' ),
289242
__( 'Monetize', 'jetpack-mu-wpcom' ),
290243
'manage_options',
291-
$monetize_url,
244+
'https://wordpress.com/earn/' . $domain,
292245
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
293246
);
294247

295-
if ( ! apply_filters( 'jetpack_wp_admin_subscriber_management_enabled', false ) ) {
248+
if ( $uses_wp_admin_interface ) {
249+
// Jetpack > Activity Log.
250+
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'cloud-activity-log-wp-menu', array( 'site' => $blog_id ) ) ) );
296251
add_submenu_page(
297252
'jetpack',
298-
__( 'Subscribers', 'jetpack-mu-wpcom' ),
299-
__( 'Subscribers', 'jetpack-mu-wpcom' ),
253+
__( 'Activity Log', 'jetpack-mu-wpcom' ),
254+
__( 'Activity Log', 'jetpack-mu-wpcom' ),
300255
'manage_options',
301-
$subscribers_url,
256+
'https://wordpress.com/activity-log/' . $domain,
302257
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
303258
);
304-
} else {
305-
$subscribers_dashboard = new Subscribers_Dashboard();
306-
$subscribers_dashboard->add_wp_admin_submenu();
307-
}
308259

309-
if ( $is_simple_site ) {
260+
// Jetpack > Subscribers.
261+
if ( ! apply_filters( 'jetpack_wp_admin_subscriber_management_enabled', false ) ) {
262+
wpcom_hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'jetpack-menu-jetpack-manage-subscribers', array( 'site' => $blog_id ) ) ) );
263+
add_submenu_page(
264+
'jetpack',
265+
__( 'Subscribers', 'jetpack-mu-wpcom' ),
266+
__( 'Subscribers', 'jetpack-mu-wpcom' ),
267+
'manage_options',
268+
'https://wordpress.com/subscribers/' . $domain,
269+
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
270+
);
271+
} else {
272+
$subscribers_dashboard = new Subscribers_Dashboard();
273+
$subscribers_dashboard->add_wp_admin_submenu();
274+
}
275+
276+
// Jetpack > Newsletter.
277+
if ( $is_simple_site ) {
278+
add_submenu_page(
279+
'jetpack',
280+
__( 'Newsletter', 'jetpack-mu-wpcom' ),
281+
__( 'Newsletter', 'jetpack-mu-wpcom' ),
282+
'manage_options',
283+
'https://wordpress.com/settings/newsletter/' . $domain,
284+
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
285+
);
286+
}
287+
288+
// Jetpack > Podcasting
310289
add_submenu_page(
311290
'jetpack',
312-
__( 'Newsletter', 'jetpack-mu-wpcom' ),
313-
__( 'Newsletter', 'jetpack-mu-wpcom' ),
291+
__( 'Podcasting', 'jetpack-mu-wpcom' ),
292+
__( 'Podcasting', 'jetpack-mu-wpcom' ),
314293
'manage_options',
315-
$newsletter_url,
294+
'https://wordpress.com/settings/podcasting/' . $domain,
316295
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
317296
);
318297
}
319298

320-
// Jetpack > Podcasting
321-
add_submenu_page(
322-
'jetpack',
323-
__( 'Podcasting', 'jetpack-mu-wpcom' ),
324-
__( 'Podcasting', 'jetpack-mu-wpcom' ),
325-
'manage_options',
326-
$podcasting_url,
327-
null // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
328-
);
329-
330299
// Re-order menu.
331300
global $submenu;
332301
if ( ! isset( $submenu['jetpack'] ) ) {
@@ -336,26 +305,35 @@ function wpcom_add_jetpack_submenu() {
336305
$desired_order = array(
337306
'my-jetpack',
338307
'stats',
339-
$activity_log_url,
308+
'boost',
309+
'social',
340310
'akismet-key-config',
341-
'jetpack-search',
342-
$monetize_url,
343-
$subscribers_url,
311+
'activity-log',
312+
'scan',
313+
'backup',
314+
'forms',
315+
'earn',
316+
'search',
317+
'subscribers',
318+
'newsletter',
319+
'podcasting',
320+
'jetpack#/settings',
321+
'jetpack#/dashboard',
344322
);
345323
$ordered_submenu = array();
346324

347325
// Re-add submenu items in the desired order.
348326
foreach ( $desired_order as $slug ) {
349327
foreach ( $submenu['jetpack'] as $item ) {
350-
if ( $item[2] === $slug ) {
328+
if ( str_contains( $item[2], $slug ) ) {
351329
$ordered_submenu[] = $item;
352330
}
353331
}
354332
}
355333

356334
// Add any remaining submenu items.
357335
foreach ( $submenu['jetpack'] as $item ) {
358-
if ( ! in_array( $item[2], $desired_order, true ) ) {
336+
if ( ! in_array( $item, $ordered_submenu, true ) ) {
359337
$ordered_submenu[] = $item;
360338
}
361339
}

jetpack_vendor/i18n-map.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
),
5151
'jetpack-masterbar' => array(
5252
'path' => 'jetpack_vendor/automattic/jetpack-masterbar',
53-
'ver' => '0.18.2',
53+
'ver' => '0.19.0-alpha1752749930',
5454
),
5555
'jetpack-mu-wpcom' => array(
5656
'path' => 'jetpack_vendor/automattic/jetpack-mu-wpcom',
57-
'ver' => '6.7.0-alpha1752692359',
57+
'ver' => '6.7.0-alpha1752749930',
5858
),
5959
'jetpack-password-checker' => array(
6060
'path' => 'jetpack_vendor/automattic/jetpack-password-checker',

0 commit comments

Comments
 (0)