Skip to content

Commit

Permalink
Move Jetpack menu position for atomic wp-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
candy02058912 committed Jan 23, 2024
1 parent 0b37082 commit b180548
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 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 @@ -7,8 +7,10 @@

namespace Automattic\Jetpack\Dashboard_Customizations;

use Automattic\Jetpack\Assets\Logo;
use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Current_Plan as Jetpack_Plan;
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Status;

require_once __DIR__ . '/class-admin-menu.php';
Expand Down Expand Up @@ -328,6 +330,35 @@ public function get_upsell_nudge() {
}
}

/**
* Adds Jetpack menu.
*/
public function add_jetpack_menu() {
if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' ) {
$icon = ( new Logo() )->get_base64_logo();
$is_menu_updated = $this->update_menu( 'jetpack', null, null, null, $icon, 2 );
if ( ! $is_menu_updated ) {
add_menu_page( esc_attr__( 'Jetpack', 'jetpack' ), __( 'Jetpack', 'jetpack' ), 'manage_options', 'jetpack', null, $icon, 2 );
}

add_submenu_page( 'jetpack', esc_attr__( 'Activity Log', 'jetpack' ), __( 'Activity Log', 'jetpack' ), 'manage_options', 'https://wordpress.com/activity-log/' . $this->domain, null, 2 );
add_submenu_page( 'jetpack', esc_attr__( 'Backup', 'jetpack' ), __( 'Backup', 'jetpack' ), 'manage_options', 'https://wordpress.com/backup/' . $this->domain, null, 3 );

if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'jetpack' ) ) {
$this->hide_submenu_page( 'jetpack', 'jetpack#/settings' );
$this->hide_submenu_page( 'jetpack', 'stats' );
$this->hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-backups' ) ) );
$this->hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-scanner' ) ) );
}
if ( ! $is_menu_updated ) {
// Remove the submenu auto-created by Core just to be sure that there no issues on non-admin roles.
remove_submenu_page( 'jetpack', 'jetpack' );
}
} else {
parent::add_jetpack_menu();
}
}

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

0 comments on commit b180548

Please sign in to comment.