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

Untangle: Introduce the WordPress.com menu #35407

Closed
wants to merge 8 commits into from
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Add "WordPress.com > Site Tools"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Untangle: move items in Upgrades section to the WordPress.com menu for the classic view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Remove calls to add_woocommerce_installation_menu from WPcom_Admin_Menu and Atomic_Admin_Menu.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Untangle: Move Newsletter from Settings menu to Jetpack menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Untangle Calypso: Move Subscribers to Jetpack when wp-admin interface is selected
8 changes: 8 additions & 0 deletions projects/plugins/jetpack/changelog/update-wpcom-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Significance: minor
Type: other

Move the following items from Tools to the new WordPress.com menu for the calypso untangle project:
* Monetize
* Marketing
* Site Monitoring
* Hosting Configuration
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ public function reregister_menu_items() {
// Remove separators.
remove_menu_page( 'separator1' );
$this->add_stats_menu();
$this->add_upgrades_menu();

// When the interface is set to wp-admin, move items in Upgrades section to the WordPress.com-specific menu item.
if ( 'wp-admin' === get_option( 'wpcom_admin_interface' ) ) {
$this->add_wpcom_menu();
} else {
$this->add_upgrades_menu();
}
$this->add_posts_menu();
$this->add_media_menu();
$this->add_page_menu();
Expand Down Expand Up @@ -126,6 +132,44 @@ public function add_stats_menu() {
add_menu_page( __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'https://wordpress.com/stats/day/' . $this->domain, null, 'dashicons-chart-bar', 3 );
}

/**
* Adds WordPress.com menu.
*
* @return number The current position of the submenu.
*/
public function add_wpcom_menu() {
add_menu_page( esc_attr__( 'WordPress.com', 'jetpack' ), __( 'WordPress.com', 'jetpack' ), 'publish_posts', 'wpcom', null, 'dashicons-wordpress-alt', 4 );

$submenu_position = 0;
// We don't want to show the items related to the Upgrades on the staging site.
if ( ! get_option( 'wpcom_is_staging_site' ) ) {
add_submenu_page( 'wpcom', esc_attr__( 'Plans', 'jetpack' ), __( 'Plans', 'jetpack' ), 'manage_options', 'https://wordpress.com/plans/' . $this->domain, null, $submenu_position++ );

if ( defined( 'WPCOM_ENABLE_ADD_ONS_MENU_ITEM' ) && WPCOM_ENABLE_ADD_ONS_MENU_ITEM ) {
add_submenu_page( 'wpcom', esc_attr__( 'Add-Ons', 'jetpack' ), __( 'Add-Ons', 'jetpack' ), 'manage_options', 'https://wordpress.com/add-ons/' . $this->domain, null, $submenu_position++ );
}

add_submenu_page( 'wpcom', esc_attr__( 'Domains', 'jetpack' ), __( 'Domains', 'jetpack' ), 'manage_options', 'https://wordpress.com/domains/manage/' . $this->domain, null, $submenu_position++ );

/** This filter is already documented in modules/masterbar/admin-menu/class-atomic-admin-menu.php */
if ( apply_filters( 'jetpack_show_wpcom_upgrades_email_menu', false ) ) {
add_submenu_page( 'wpcom', esc_attr__( 'Emails', 'jetpack' ), __( 'Emails', 'jetpack' ), 'manage_options', 'https://wordpress.com/email/' . $this->domain, null, $submenu_position++ );
}

add_submenu_page( 'wpcom', esc_attr__( 'Purchases', 'jetpack' ), __( 'Purchases', 'jetpack' ), 'manage_options', 'https://wordpress.com/purchases/subscriptions/' . $this->domain, null, $submenu_position++ );
}

add_submenu_page( 'wpcom', esc_attr__( 'Marketing', 'jetpack' ), __( 'Marketing', 'jetpack' ), 'publish_posts', 'https://wordpress.com/marketing/tools/' . $this->domain, null, $submenu_position++ );
add_submenu_page( 'wpcom', esc_attr__( 'Monetize', 'jetpack' ), __( 'Monetize', 'jetpack' ), 'manage_options', 'https://wordpress.com/earn/' . $this->domain, null, $submenu_position++ );
add_submenu_page( 'wpcom', esc_attr__( 'Hosting Configuration', 'jetpack' ), __( 'Hosting Configuration', 'jetpack' ), 'manage_options', 'https://wordpress.com/hosting-config/' . $this->domain, null, $submenu_position++ );
add_submenu_page( 'wpcom', esc_attr__( 'Site Tools', 'jetpack' ), __( 'Site Tools', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/site-tools/' . $this->domain, null, $submenu_position++ );

// Remove the submenu auto-created by Core.
$this->hide_submenu_page( 'wpcom', 'wpcom' );

return $submenu_position;
}

/**
* Adds Upgrades menu.
*
Expand Down Expand Up @@ -348,8 +392,10 @@ public function add_tools_menu() {
$this->hide_submenu_page( 'tools.php', 'tools.php' );
$this->hide_submenu_page( 'tools.php', 'delete-blog' );

add_submenu_page( 'tools.php', esc_attr__( 'Marketing', 'jetpack' ), __( 'Marketing', 'jetpack' ), 'publish_posts', 'https://wordpress.com/marketing/tools/' . $this->domain, null, 0 );
add_submenu_page( 'tools.php', esc_attr__( 'Monetize', 'jetpack' ), __( 'Monetize', 'jetpack' ), 'manage_options', 'https://wordpress.com/earn/' . $this->domain, null, 1 );
if ( 'wp-admin' !== get_option( 'wpcom_admin_interface' ) ) {
add_submenu_page( 'tools.php', esc_attr__( 'Marketing', 'jetpack' ), __( 'Marketing', 'jetpack' ), 'publish_posts', 'https://wordpress.com/marketing/tools/' . $this->domain, null, 0 );
add_submenu_page( 'tools.php', esc_attr__( 'Monetize', 'jetpack' ), __( 'Monetize', 'jetpack' ), 'manage_options', 'https://wordpress.com/earn/' . $this->domain, null, 1 );
}
}

/**
Expand Down Expand Up @@ -381,7 +427,9 @@ public function add_options_menu() {

$this->update_submenus( 'options-general.php', $submenus_to_update );

add_submenu_page( 'options-general.php', esc_attr__( 'Newsletter', 'jetpack' ), __( 'Newsletter', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/newsletter/' . $this->domain, null, 7 );
if ( ! $this->use_wp_admin_interface() ) {
add_submenu_page( 'options-general.php', esc_attr__( 'Newsletter', 'jetpack' ), __( 'Newsletter', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/newsletter/' . $this->domain, null, 7 );
}
add_submenu_page( 'options-general.php', esc_attr__( 'Podcasting', 'jetpack' ), __( 'Podcasting', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/podcasting/' . $this->domain, null, 8 );
add_submenu_page( 'options-general.php', esc_attr__( 'Performance', 'jetpack' ), __( 'Performance', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/performance/' . $this->domain, null, 9 );
}
Expand All @@ -404,8 +452,15 @@ public function create_jetpack_menu( $position = 50, $separator = true ) {
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 );
add_submenu_page( 'jetpack', esc_attr__( 'Backup', 'jetpack' ), __( 'Backup', 'jetpack' ), 'manage_options', 'https://wordpress.com/backup/' . $this->domain, null, 3 );
if ( $this->use_wp_admin_interface() ) {
// wp-admin interface, add Subscribers under Jetpack menu.
add_submenu_page( 'jetpack', esc_attr__( 'Subscribers', 'jetpack' ), __( 'Subscribers', 'jetpack' ) . ' <span class="dashicons dashicons-external"></span>', 'list_users', 'https://wordpress.com/subscribers/' . $this->domain, null, 2 );
// wp-admin interface, add Newsletter under Jetpack menu.
add_submenu_page( 'jetpack', esc_attr__( 'Newsletter', 'jetpack' ), __( 'Newsletter', 'jetpack' ) . ' <span class="dashicons dashicons-external"></span>', 'manage_options', 'https://wordpress.com/settings/newsletter/' . $this->domain, null, 2 );
}

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

if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'jetpack' ) ) {
$this->hide_submenu_page( 'jetpack', 'jetpack#/settings' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public function reregister_menu_items() {
$this->add_new_site_link();
}

$this->add_woocommerce_installation_menu();
if ( $this->use_wp_admin_interface() ) {
$this->add_woocommerce_installation_menu();
}

ksort( $GLOBALS['menu'] );
}

Expand Down Expand Up @@ -129,7 +132,10 @@ public function add_users_menu() {
$this->update_submenus( $slug, $submenus_to_update );
}

add_submenu_page( 'users.php', esc_attr__( 'Subscribers', 'jetpack' ), __( 'Subscribers', 'jetpack' ), 'list_users', 'https://wordpress.com/subscribers/' . $this->domain, null );
// Not wp-admin interface, add Subscribers under Users menu.
if ( ! $this->use_wp_admin_interface() ) {
add_submenu_page( 'users.php', esc_attr__( 'Subscribers', 'jetpack' ), __( 'Subscribers', 'jetpack' ), 'list_users', 'https://wordpress.com/subscribers/' . $this->domain, null );
}

remove_submenu_page( 'users.php', 'profile.php' );
add_submenu_page( 'users.php', esc_attr__( 'My Profile', 'jetpack' ), __( 'My Profile', 'jetpack' ), 'read', 'https://wordpress.com/me/', null );
Expand Down Expand Up @@ -370,6 +376,15 @@ function_exists( 'stats_get_image_chart_src' )
add_menu_page( __( 'Stats', 'jetpack' ), $menu_title, 'view_stats', 'https://wordpress.com/stats/day/' . $this->domain, null, 'dashicons-chart-bar', 3 );
}

/**
* Adds WordPress.com menu.
*/
public function add_wpcom_menu() {
$submenu_position = parent::add_wpcom_menu();

add_submenu_page( 'wpcom', esc_attr__( 'Site Monitoring', 'jetpack' ), __( 'Site Monitoring', 'jetpack' ), 'manage_options', 'https://wordpress.com/site-monitoring/' . $this->domain, null, $submenu_position++ );
}

/**
* Adds Upgrades menu.
*
Expand Down Expand Up @@ -423,7 +438,12 @@ public function add_options_menu() {
);
}

add_submenu_page( 'options-general.php', esc_attr__( 'Hosting Configuration', 'jetpack' ), __( 'Hosting Configuration', 'jetpack' ), 'manage_options', 'https://wordpress.com/hosting-config/' . $this->domain, null, 11 );
/**
* Adds the Hosting Configuration submenu under the Settings menu when the interface is not set to wp-admin.
*/
if ( get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
add_submenu_page( 'options-general.php', esc_attr__( 'Hosting Configuration', 'jetpack' ), __( 'Hosting Configuration', 'jetpack' ), 'manage_options', 'https://wordpress.com/hosting-config/' . $this->domain, null, 11 );
}

// Page Optimize is active by default on all Atomic sites and registers a Settings > Performance submenu which
// would conflict with our own Settings > Performance that links to Calypso, so we hide it it since the Calypso
Expand All @@ -449,9 +469,11 @@ public function add_tools_menu() {
}

/**
* Adds the WordPress.com Site Monitoring submenu under the main Tools menu.
* Adds the WordPress.com Site Monitoring submenu under the main Tools menu when the interface is not set to wp-admin.
*/
add_submenu_page( 'tools.php', esc_attr__( 'Site Monitoring', 'jetpack' ), __( 'Site Monitoring', 'jetpack' ), 'manage_options', 'https://wordpress.com/site-monitoring/' . $this->domain, null, 7 );
if ( get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
add_submenu_page( 'tools.php', esc_attr__( 'Site Monitoring', 'jetpack' ), __( 'Site Monitoring', 'jetpack' ), 'manage_options', 'https://wordpress.com/site-monitoring/' . $this->domain, null, 7 );
}

/**
* Adds the WordPress.com Github Deployments submenu under the main Tools menu.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public function reregister_menu_items() {
$this->add_new_site_link();
}

$this->add_woocommerce_installation_menu( $this->get_current_plan() );
if ( $this->use_wp_admin_interface() ) {
$this->add_woocommerce_installation_menu();
}

ksort( $GLOBALS['menu'] );
}
Expand Down Expand Up @@ -361,7 +363,12 @@ public function add_users_menu() {
public function add_options_menu() {
parent::add_options_menu();

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 );
/**
* Adds the Hosting Configuration submenu under the Settings menu when the interface is not set to wp-admin.
*/
if ( get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
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
Original file line number Diff line number Diff line change
Expand Up @@ -484,72 +484,4 @@ public function hide_menu_based_on_submenu_provider() {
),
);
}

/**
* Tests test_add_woocommerce_installation_menu
*
* @covers ::add_woocommerce_installation_menu
*/
public function test_add_woocommerce_installation_menu() {
global $menu;

$woo_icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiNhMmFhYjIiIGQ9Ik02MTIuMTkyIDQyNi4zMzZjMC02Ljg5Ni0zLjEzNi01MS42LTI4LTUxLjYtMzcuMzYgMC00Ni43MDQgNzIuMjU2LTQ2LjcwNCA4Mi42MjQgMCAzLjQwOCAzLjE1MiA1OC40OTYgMjguMDMyIDU4LjQ5NiAzNC4xOTItLjAzMiA0Ni42NzItNzIuMjg4IDQ2LjY3Mi04OS41MnptMjAyLjE5MiAwYzAtNi44OTYtMy4xNTItNTEuNi0yOC4wMzItNTEuNi0zNy4yOCAwLTQ2LjYwOCA3Mi4yNTYtNDYuNjA4IDgyLjYyNCAwIDMuNDA4IDMuMDcyIDU4LjQ5NiAyNy45NTIgNTguNDk2IDM0LjE5Mi0uMDMyIDQ2LjY4OC03Mi4yODggNDYuNjg4LTg5LjUyek0xNDEuMjk2Ljc2OGMtNjguMjI0IDAtMTIzLjUwNCA1NS40ODgtMTIzLj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Ni42ODggMTIwLjUxMiAyOS4xNjggMTg1Ljk2OCAxLjg1NiAyLjkyOCAxLjUwNCA3LjAwOCA0LjU2IDEwLjQzMiAzLjE1Mi0xMC4yODggNjYuOTI4LTE2OC43ODQgOTQuOTYtMTY4Ljc4NCAyMi41NDQgMCAzMC40IDQ0LjU5MiAzMy41MzYgNjEuODI0IDYuMjA4IDIwLjY1NiAxMy4wODggNTUuMjE2IDIyLjQxNiA4Mi43NTIgMC0xMy43NzYgMTIuNDgtMjAzLjEyIDY1LjM5Mi0yMDMuMTIgMTguNTkyLjAzMiAyNi43MDQgNi45MjggMjYuNzA0IDI3LjU2OHpNODcwLjMyIDQyMi45MjhjMCA1NS4wODgtMzEuMDg4IDE1NC44OC0xMDIuNjQgMTU0Ljg4LTYuMTkyIDAtMTguNDQ4LTMuNjE2LTI1LjQyNC02LjAxNi0zMi40MzItMTEuMTY4LTUwLjE3Ni00OS42OTYtNTIuMjg4LTY2LjI1NiAwIDAtMy44ODgtMTcuOTItMy44ODgtNDAuODk2czMuODg4LTQ1LjE4NCAzLjg4OC00NS4xODRjMTUuNTUyLTc1LjcyOCA0My40ODgtMTA2LjczNiA5Ni4zODQtMTA2LjczNiA1OS4xMDQtLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4eiIvPjwvc3ZnPg==';

// By default, the WooCommerce installation menu item should NOT be displayed.
static::$admin_menu->add_woocommerce_installation_menu();

$this->assertArrayNotHasKey( 54, $menu );
$this->assertArrayNotHasKey( 55, $menu );

// Reset the menu array.
$menu = self::$menu_data;

// If the filter returns true, the WooCommerce installation menu should be displayed.
add_filter( 'jetpack_show_wpcom_woocommerce_installation_menu', '__return_true' );
static::$admin_menu->add_woocommerce_installation_menu();

$this->assertArrayHasKey( 54, $menu );
$this->assertArrayHasKey( 55, $menu );

$this->assertMatchesRegularExpression( '/^separator-custom-.*/', $menu['54'][2] );

$this->assertSame( 'WooCommerce', $menu[55][0] );
$this->assertSame( 'activate_plugins', $menu[55][1] );
$this->assertSame( 'https://wordpress.com/woocommerce-installation/' . static::$domain, $menu[55][2] );
$this->assertSame( 'WooCommerce', $menu[55][3] );
$this->assertSame( $woo_icon, $menu[55][6] );

remove_all_filters( 'jetpack_show_wpcom_woocommerce_installation_menu' );

// Reset the menu array.
$menu = self::$menu_data;

// If the filter returns false, the WooCommerce installation menu should NOT be displayed.
add_filter( 'jetpack_show_wpcom_woocommerce_installation_menu', '__return_false' );
static::$admin_menu->add_woocommerce_installation_menu();

$this->assertArrayNotHasKey( 54, $menu );
$this->assertArrayNotHasKey( 55, $menu );

remove_all_filters( 'jetpack_show_wpcom_woocommerce_installation_menu' );

// Reset the menu array.
$menu = self::$menu_data;

// Test filter signature with $current_plan passed in.
add_filter(
'jetpack_show_wpcom_woocommerce_installation_menu',
function ( $should_show, $current_plan ) {
return $current_plan['test'];
},
10,
2
);
static::$admin_menu->add_woocommerce_installation_menu( array( 'test' => true ) );

$this->assertArrayHasKey( 54, $menu );
$this->assertArrayHasKey( 55, $menu );

remove_all_filters( 'jetpack_show_wpcom_woocommerce_installation_menu' );
}
}
Loading