Skip to content

Commit

Permalink
Move Jetpack menu position for atomic wp-admin (#35154)
Browse files Browse the repository at this point in the history
* Move Jetpack menu position for atomic wp-admin

* Add comments

* Move redundant code to create_jetpack_menu
  • Loading branch information
candy02058912 authored Jan 26, 2024
1 parent c02befb commit 91da16e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Move Jetpack to the same menu position as standalone Jetpack site.
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,21 @@ public function add_options_menu() {
}

/**
* Adds Jetpack menu.
* Create Jetpack menu.
*
* @param int $position Menu position.
* @param bool $separator Whether to add a separator before the menu.
*/
public function add_jetpack_menu() {
$this->add_admin_menu_separator( 50, 'manage_options' );
public function create_jetpack_menu( $position = 50, $separator = true ) {
if ( $separator ) {
$this->add_admin_menu_separator( $position, 'manage_options' );
++$position;
}

$icon = ( new Logo() )->get_base64_logo();
$is_menu_updated = $this->update_menu( 'jetpack', null, null, null, $icon, 51 );
$is_menu_updated = $this->update_menu( 'jetpack', null, null, null, $icon, $position );
if ( ! $is_menu_updated ) {
add_menu_page( esc_attr__( 'Jetpack', 'jetpack' ), __( 'Jetpack', 'jetpack' ), 'manage_options', 'jetpack', null, $icon, 51 );
add_menu_page( esc_attr__( 'Jetpack', 'jetpack' ), __( 'Jetpack', 'jetpack' ), 'manage_options', 'jetpack', null, $icon, $position );
}

add_submenu_page( 'jetpack', esc_attr__( 'Activity Log', 'jetpack' ), __( 'Activity Log', 'jetpack' ), 'manage_options', 'https://wordpress.com/activity-log/' . $this->domain, null, 2 );
Expand All @@ -414,6 +420,13 @@ public function add_jetpack_menu() {
}
}

/**
* Adds Jetpack menu.
*/
public function add_jetpack_menu() {
$this->create_jetpack_menu();
}

/**
* Add the calypso /woocommerce-installation/ menu item.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,18 @@ public function get_upsell_nudge() {
}
}

/**
* Adds Jetpack menu.
*/
public function add_jetpack_menu() {
// This is supposed to be the same as class-admin-menu but with a different position specified for the Jetpack menu.
if ( 'wp-admin' === get_option( 'wpcom_admin_interface' ) ) {
parent::create_jetpack_menu( 2, false );
} else {
parent::add_jetpack_menu();
}
}

/**
* Adds Stats menu.
*/
Expand Down

0 comments on commit 91da16e

Please sign in to comment.