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

Move Jetpack menu position for atomic wp-admin #35154

Merged
merged 4 commits into from
Jan 26, 2024
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: 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();
Copy link
Contributor Author

@candy02058912 candy02058912 Jan 22, 2024

Choose a reason for hiding this comment

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

Will need to change this line to parent::add_jetpack_menu( $position, $seperator ); to see the changes mentioned in the PR description.

Update: I've completely changed the approach as modifying the parameters as mentioned in the strikethrough will also mean a change is needed for https://github.com/Automattic/wc-calypso-bridge/blob/master/includes/class-wc-calypso-bridge-ecommerce-admin-menu.php

}
}

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