diff --git a/projects/packages/masterbar/changelog/remove-old-fly-panel b/projects/packages/masterbar/changelog/remove-old-fly-panel new file mode 100644 index 0000000000000..2188f44523b3c --- /dev/null +++ b/projects/packages/masterbar/changelog/remove-old-fly-panel @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Masterbar: Remove old fly panel diff --git a/projects/packages/masterbar/src/masterbar/class-masterbar.php b/projects/packages/masterbar/src/masterbar/class-masterbar.php index 5de5f1201b3c8..cff37f0ecb106 100644 --- a/projects/packages/masterbar/src/masterbar/class-masterbar.php +++ b/projects/packages/masterbar/src/masterbar/class-masterbar.php @@ -9,7 +9,6 @@ use Automattic\Jetpack\Assets; use Automattic\Jetpack\Connection\Manager as Connection_Manager; -use Automattic\Jetpack\Current_Plan as Jetpack_Plan; use Automattic\Jetpack\Device_Detection\User_Agent_Info; use Automattic\Jetpack\Modules; use Automattic\Jetpack\Redirect; @@ -794,13 +793,7 @@ public function add_me_submenu( $wp_admin_bar ) { $user_info = get_avatar( $this->user_email, 128, 'mm', '', array( 'force_display' => true ) ); $user_info .= '' . $this->display_name . ''; - $user_info .= '@' . $this->user_login . ''; - - $user_info .= sprintf( - '
', - $logout_url, - esc_html__( 'Sign Out', 'jetpack-masterbar' ) - ); + $user_info .= '' . $this->user_login . ''; $blog_id = Connection_Manager::get_site_id( true ); @@ -824,19 +817,8 @@ public function add_me_submenu( $wp_admin_bar ) { $wp_admin_bar->add_menu( array( 'parent' => $id, - 'id' => 'profile-header', + 'id' => 'profile', 'title' => esc_html__( 'Profile', 'jetpack-masterbar' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'my-profile', - 'title' => esc_html__( 'My Profile', 'jetpack-masterbar' ), 'href' => Redirect::get_url( 'calypso-me', $args ), 'meta' => array( 'class' => 'mb-icon', @@ -847,95 +829,14 @@ public function add_me_submenu( $wp_admin_bar ) { $wp_admin_bar->add_menu( array( 'parent' => $id, - 'id' => 'account-settings', - 'title' => esc_html__( 'Account Settings', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-me-account', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'billing', - 'title' => esc_html__( 'Manage Purchases', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-me-purchases', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'security', - 'title' => esc_html__( 'Security', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-me-security', $args ), + 'id' => 'logout', + 'title' => esc_html__( 'Log Out', 'jetpack-masterbar' ), + 'href' => $logout_url, 'meta' => array( 'class' => 'mb-icon', ), ) ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'notifications', - 'title' => esc_html__( 'Notifications', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-me-notifications', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'special-header', - 'title' => esc_html_x( - 'Special', - 'Title for Me sub-menu that contains Get Apps, Next Steps, and Help options', - 'jetpack-masterbar' - ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'get-apps', - 'title' => esc_html__( 'Get Apps', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-me-get-apps', $args ), - 'meta' => array( - 'class' => 'mb-icon user-info-item', - ), - ) - ); - - $help_link = Redirect::get_url( 'jetpack-support', $args ); - - if ( $this->site_woa ) { - $help_link = Redirect::get_url( 'calypso-help', $args ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'help', - 'title' => esc_html__( 'Help', 'jetpack-masterbar' ), - 'href' => $help_link, - 'meta' => array( - 'class' => 'mb-icon user-info-item', - ), - ) - ); } /** @@ -976,8 +877,6 @@ public function add_write_button( $wp_admin_bar ) { * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance. */ public function add_my_sites_submenu( $wp_admin_bar ) { - $current_user = wp_get_current_user(); - $blog_name = get_bloginfo( 'name' ); if ( empty( $blog_name ) ) { $blog_name = $this->primary_site_slug; @@ -1008,519 +907,7 @@ public function add_my_sites_submenu( $wp_admin_bar ) { return; } - $blog_id = Connection_Manager::get_site_id( true ); - - $args = array(); - if ( $blog_id ) { - $args['site'] = $blog_id; - } - - if ( $this->user_site_count > 1 ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'switch-site', - 'title' => esc_html__( 'Switch Site', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-sites', $args ), - ) - ); - } else { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'new-site', - 'title' => esc_html__( '+ Add New WordPress', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-start', array_merge( $args, array( 'query' => 'ref=admin-bar-logged-in' ) ) ), - ) - ); - } - - if ( is_user_member_of_blog( $current_user->ID ) ) { - $blavatar = ''; - $class = 'current-site'; - - if ( has_site_icon() ) { - $src = get_site_icon_url(); - $blavatar = ''; - $class = 'has-blavatar'; - } - - $blog_info = ' '; - $blog_info .= '' . esc_html( $blog_name ) . ''; - $blog_info .= '' . esc_html( $this->primary_site_url ) . ''; - - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'blog-info', - 'title' => $blog_info, - 'href' => esc_url( trailingslashit( $this->primary_site_url ) ), - 'meta' => array( - 'class' => $class, - ), - ) - ); - } - - // Site Preview. - if ( is_admin() ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'site-view', - 'title' => __( 'View Site', 'jetpack-masterbar' ), - 'href' => home_url(), - 'meta' => array( - 'class' => 'mb-icon', - 'target' => '_blank', - ), - ) - ); - } - - $this->add_my_home_submenu_item( $wp_admin_bar ); - - // Stats. - if ( ( new Modules() )->is_active( 'stats' ) && current_user_can( 'view_stats' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'blog-stats', - 'title' => esc_html__( 'Stats', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-stats', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - if ( current_user_can( 'manage_options' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'activity', - 'title' => esc_html__( 'Activity', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-activity-log', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - // Add Calypso plans link and plan type indicator. - if ( is_user_member_of_blog( $current_user->ID ) && current_user_can( 'manage_options' ) ) { - $plans_url = Redirect::get_url( 'calypso-plans', $args ); - $label = esc_html__( 'Plan', 'jetpack-masterbar' ); - $plan = Jetpack_Plan::get(); - - $plan_title = $this->create_menu_item_pair( - array( - 'url' => $plans_url, - 'id' => 'wp-admin-bar-plan', - 'label' => $label, - ), - array( - 'url' => $plans_url, - 'id' => 'wp-admin-bar-plan-badge', - 'label' => ! empty( $plan['product_name_short'] ) ? $plan['product_name_short'] : esc_html__( 'Free', 'jetpack-masterbar' ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'plan', - 'title' => $plan_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - // Publish group. - $wp_admin_bar->add_group( - array( - 'parent' => 'blog', - 'id' => 'publish', - ) - ); - - // Publish header. - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'publish-header', - 'title' => esc_html_x( 'Manage', 'admin bar menu group label', 'jetpack-masterbar' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - // Pages. - $pages_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-edit-pages', $args ), - 'id' => 'wp-admin-bar-edit-page', - 'label' => esc_html__( 'Site Pages', 'jetpack-masterbar' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-page', $args ), - 'id' => 'wp-admin-bar-new-page-badge', - 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack-masterbar' ), - ) - ); - - if ( ! current_user_can( 'edit_pages' ) ) { - $pages_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-edit-pages', $args ), - esc_html__( 'Site Pages', 'jetpack-masterbar' ), - 'wp-admin-bar-edit-page' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-page', - 'title' => $pages_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - - // Blog Posts. - $posts_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-edit-posts', $args ), - 'id' => 'wp-admin-bar-edit-post', - 'label' => esc_html__( 'Blog Posts', 'jetpack-masterbar' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-post', $args ), - 'id' => 'wp-admin-bar-new-post-badge', - 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack-masterbar' ), - ) - ); - - if ( ! current_user_can( 'edit_posts' ) ) { - $posts_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-edit-posts', $args ), - esc_html__( 'Blog Posts', 'jetpack-masterbar' ), - 'wp-admin-bar-edit-post' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-post', - 'title' => $posts_title, - 'meta' => array( - 'class' => 'inline-action mb-trackable', - ), - ) - ); - - // Comments. - if ( current_user_can( 'moderate_comments' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'comments', - 'title' => __( 'Comments', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-comments', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - // Testimonials. - if ( ( new Modules() )->is_active( 'custom-content-types' ) && get_option( 'jetpack_testimonial' ) ) { - $testimonials_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-list-jetpack-testimonial', $args ), - 'id' => 'wp-admin-bar-edit-testimonial', - 'label' => esc_html__( 'Testimonials', 'jetpack-masterbar' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-jetpack-testimonial', $args ), - 'id' => 'wp-admin-bar-new-testimonial', - 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack-masterbar' ), - ) - ); - - if ( ! current_user_can( 'edit_pages' ) ) { - $testimonials_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-list-jetpack-testimonial', $args ), - esc_html__( 'Testimonials', 'jetpack-masterbar' ), - 'wp-admin-bar-edit-testimonial' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-jetpack-testimonial', - 'title' => $testimonials_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - // Portfolio. - if ( ( new Modules() )->is_active( 'custom-content-types' ) && get_option( 'jetpack_portfolio' ) ) { - $portfolios_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-list-jetpack-portfolio', $args ), - 'id' => 'wp-admin-bar-edit-portfolio', - 'label' => esc_html__( 'Portfolio', 'jetpack-masterbar' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-jetpack-portfolio', $args ), - 'id' => 'wp-admin-bar-new-portfolio', - 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack-masterbar' ), - ) - ); - - if ( ! current_user_can( 'edit_pages' ) ) { - $portfolios_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-list-jetpack-portfolio', $args ), - esc_html__( 'Portfolio', 'jetpack-masterbar' ), - 'wp-admin-bar-edit-portfolio' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-jetpack-portfolio', - 'title' => $portfolios_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - if ( current_user_can( 'edit_theme_options' ) ) { - // Look and Feel group. - $wp_admin_bar->add_group( - array( - 'parent' => 'blog', - 'id' => 'look-and-feel', - ) - ); - - // Look and Feel header. - $wp_admin_bar->add_menu( - array( - 'parent' => 'look-and-feel', - 'id' => 'look-and-feel-header', - 'title' => esc_html_x( 'Personalize', 'admin bar menu group label', 'jetpack-masterbar' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; - if ( is_admin() ) { - // In wp-admin the `return` query arg will return to that page after closing the Customizer. - $customizer_url = add_query_arg( - array( - 'return' => rawurlencode( site_url( $request_uri ) ), - ), - wp_customize_url() - ); - } else { - /* - * On the frontend the `url` query arg will load that page in the Customizer - * and also return to it after closing - * non-home URLs won't work unless we undo domain mapping - * since the Customizer preview is unmapped to always have HTTPS. - */ - $current_page = '//' . $this->primary_site_slug . $request_uri; - $customizer_url = add_query_arg( array( 'url' => rawurlencode( $current_page ) ), wp_customize_url() ); - } - - $theme_title = $this->create_menu_item_pair( - array( - 'url' => $customizer_url, - 'id' => 'wp-admin-bar-cmz', - 'label' => esc_html_x( 'Customize', 'admin bar customize item label', 'jetpack-masterbar' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-themes', $args ), - 'id' => 'wp-admin-bar-themes', - 'label' => esc_html__( 'Themes', 'jetpack-masterbar' ), - ) - ); - $meta = array( - 'class' => 'mb-icon inline-action', - ); - $href = false; - - $wp_admin_bar->add_menu( - array( - 'parent' => 'look-and-feel', - 'id' => 'themes', - 'title' => $theme_title, - 'href' => $href, - 'meta' => $meta, - ) - ); - } - if ( current_user_can( 'manage_options' ) ) { - // Configuration group. - $wp_admin_bar->add_group( - array( - 'parent' => 'blog', - 'id' => 'configuration', - ) - ); - - // Configuration header. - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'configuration-header', - 'title' => esc_html_x( 'Configure', 'admin bar menu group label', 'jetpack-masterbar' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - if ( ( new Modules() )->is_active( 'publicize' ) || ( new Modules() )->is_active( 'sharedaddy' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'sharing', - 'title' => esc_html__( 'Sharing', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-sharing', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - $people_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-people-team', $args ), - 'id' => 'wp-admin-bar-people', - 'label' => esc_html__( 'People', 'jetpack-masterbar' ), - ), - array( - 'url' => admin_url( 'user-new.php' ), - 'id' => 'wp-admin-bar-people-add', - 'label' => esc_html_x( 'Add', 'admin bar people item label', 'jetpack-masterbar' ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'users-toolbar', - 'title' => $people_title, - 'href' => false, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - - $plugins_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-plugins', $args ), - 'id' => 'wp-admin-bar-plugins', - 'label' => esc_html__( 'Plugins', 'jetpack-masterbar' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-plugins-manage', $args ), - 'id' => 'wp-admin-bar-plugins-add', - 'label' => esc_html_x( 'Manage', 'Label for the button on the Masterbar to manage plugins', 'jetpack-masterbar' ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'plugins', - 'title' => $plugins_title, - 'href' => false, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - - if ( $this->site_woa ) { - $domain_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-domains', $args ), - 'id' => 'wp-admin-bar-domains', - 'label' => esc_html__( 'Domains', 'jetpack-masterbar' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-domains-add', $args ), - 'id' => 'wp-admin-bar-domains-add', - 'label' => esc_html_x( 'Add', 'Label for the button on the Masterbar to add a new domain', 'jetpack-masterbar' ), - ) - ); - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'domains', - 'title' => $domain_title, - 'href' => false, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'blog-settings', - 'title' => esc_html__( 'Settings', 'jetpack-masterbar' ), - 'href' => Redirect::get_url( 'calypso-settings-general', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - if ( ! is_admin() ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'legacy-dashboard', - 'title' => esc_html__( 'Dashboard', 'jetpack-masterbar' ), - 'href' => admin_url(), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - // Restore dashboard menu toggle that is needed on mobile views. if ( is_admin() ) { $wp_admin_bar->add_menu( diff --git a/projects/plugins/jetpack/changelog/remove-old-flyout-panel b/projects/plugins/jetpack/changelog/remove-old-flyout-panel new file mode 100644 index 0000000000000..0b80b22c03839 --- /dev/null +++ b/projects/plugins/jetpack/changelog/remove-old-flyout-panel @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Masterbar: Remove old fly panel diff --git a/projects/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php b/projects/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php index 0dec0edf684de..9d16258b94f9e 100644 --- a/projects/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php +++ b/projects/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php @@ -9,7 +9,6 @@ use Automattic\Jetpack\Assets; use Automattic\Jetpack\Connection\Manager as Connection_Manager; -use Automattic\Jetpack\Current_Plan as Jetpack_Plan; use Automattic\Jetpack\Device_Detection\User_Agent_Info; use Automattic\Jetpack\Redirect; use Automattic\Jetpack\Scan\Admin_Bar_Notice; @@ -784,13 +783,7 @@ public function add_me_submenu( $wp_admin_bar ) { $user_info = get_avatar( $this->user_email, 128, 'mm', '', array( 'force_display' => true ) ); $user_info .= '' . $this->display_name . ''; - $user_info .= '@' . $this->user_login . ''; - - $user_info .= sprintf( - '', - $logout_url, - esc_html__( 'Sign Out', 'jetpack' ) - ); + $user_info .= '' . $this->user_login . ''; $blog_id = Connection_Manager::get_site_id( true ); @@ -814,19 +807,8 @@ public function add_me_submenu( $wp_admin_bar ) { $wp_admin_bar->add_menu( array( 'parent' => $id, - 'id' => 'profile-header', + 'id' => 'profile', 'title' => esc_html__( 'Profile', 'jetpack' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'my-profile', - 'title' => esc_html__( 'My Profile', 'jetpack' ), 'href' => Redirect::get_url( 'calypso-me', $args ), 'meta' => array( 'class' => 'mb-icon', @@ -837,95 +819,14 @@ public function add_me_submenu( $wp_admin_bar ) { $wp_admin_bar->add_menu( array( 'parent' => $id, - 'id' => 'account-settings', - 'title' => esc_html__( 'Account Settings', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-me-account', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'billing', - 'title' => esc_html__( 'Manage Purchases', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-me-purchases', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'security', - 'title' => esc_html__( 'Security', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-me-security', $args ), + 'id' => 'logout', + 'title' => esc_html__( 'Log Out', 'jetpack' ), + 'href' => $logout_url, 'meta' => array( 'class' => 'mb-icon', ), ) ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'notifications', - 'title' => esc_html__( 'Notifications', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-me-notifications', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'special-header', - 'title' => esc_html_x( - 'Special', - 'Title for Me sub-menu that contains Get Apps, Next Steps, and Help options', - 'jetpack' - ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'get-apps', - 'title' => esc_html__( 'Get Apps', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-me-get-apps', $args ), - 'meta' => array( - 'class' => 'mb-icon user-info-item', - ), - ) - ); - - $help_link = Redirect::get_url( 'jetpack-support', $args ); - - if ( $this->site_woa ) { - $help_link = Redirect::get_url( 'calypso-help', $args ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => $id, - 'id' => 'help', - 'title' => esc_html__( 'Help', 'jetpack' ), - 'href' => $help_link, - 'meta' => array( - 'class' => 'mb-icon user-info-item', - ), - ) - ); } /** @@ -966,8 +867,6 @@ public function add_write_button( $wp_admin_bar ) { * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance. */ public function add_my_sites_submenu( $wp_admin_bar ) { - $current_user = wp_get_current_user(); - $blog_name = get_bloginfo( 'name' ); if ( empty( $blog_name ) ) { $blog_name = $this->primary_site_slug; @@ -998,519 +897,7 @@ public function add_my_sites_submenu( $wp_admin_bar ) { return; } - $blog_id = Connection_Manager::get_site_id( true ); - - $args = array(); - if ( $blog_id ) { - $args['site'] = $blog_id; - } - - if ( $this->user_site_count > 1 ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'switch-site', - 'title' => esc_html__( 'Switch Site', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-sites', $args ), - ) - ); - } else { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'new-site', - 'title' => esc_html__( '+ Add New WordPress', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-start', array_merge( $args, array( 'query' => 'ref=admin-bar-logged-in' ) ) ), - ) - ); - } - - if ( is_user_member_of_blog( $current_user->ID ) ) { - $blavatar = ''; - $class = 'current-site'; - - if ( has_site_icon() ) { - $src = get_site_icon_url(); - $blavatar = ''; - $class = 'has-blavatar'; - } - - $blog_info = ' '; - $blog_info .= '' . esc_html( $blog_name ) . ''; - $blog_info .= '' . esc_html( $this->primary_site_url ) . ''; - - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'blog-info', - 'title' => $blog_info, - 'href' => esc_url( trailingslashit( $this->primary_site_url ) ), - 'meta' => array( - 'class' => $class, - ), - ) - ); - } - - // Site Preview. - if ( is_admin() ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'site-view', - 'title' => __( 'View Site', 'jetpack' ), - 'href' => home_url(), - 'meta' => array( - 'class' => 'mb-icon', - 'target' => '_blank', - ), - ) - ); - } - - $this->add_my_home_submenu_item( $wp_admin_bar ); - - // Stats. - if ( Jetpack::is_module_active( 'stats' ) && current_user_can( 'view_stats' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'blog-stats', - 'title' => esc_html__( 'Stats', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-stats', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - if ( current_user_can( 'manage_options' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'activity', - 'title' => esc_html__( 'Activity', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-activity-log', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - // Add Calypso plans link and plan type indicator. - if ( is_user_member_of_blog( $current_user->ID ) && current_user_can( 'manage_options' ) ) { - $plans_url = Redirect::get_url( 'calypso-plans', $args ); - $label = esc_html__( 'Plan', 'jetpack' ); - $plan = Jetpack_Plan::get(); - - $plan_title = $this->create_menu_item_pair( - array( - 'url' => $plans_url, - 'id' => 'wp-admin-bar-plan', - 'label' => $label, - ), - array( - 'url' => $plans_url, - 'id' => 'wp-admin-bar-plan-badge', - 'label' => ! empty( $plan['product_name_short'] ) ? $plan['product_name_short'] : esc_html__( 'Free', 'jetpack' ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => 'blog', - 'id' => 'plan', - 'title' => $plan_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - // Publish group. - $wp_admin_bar->add_group( - array( - 'parent' => 'blog', - 'id' => 'publish', - ) - ); - - // Publish header. - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'publish-header', - 'title' => esc_html_x( 'Manage', 'admin bar menu group label', 'jetpack' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - // Pages. - $pages_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-edit-pages', $args ), - 'id' => 'wp-admin-bar-edit-page', - 'label' => esc_html__( 'Site Pages', 'jetpack' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-page', $args ), - 'id' => 'wp-admin-bar-new-page-badge', - 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ), - ) - ); - - if ( ! current_user_can( 'edit_pages' ) ) { - $pages_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-edit-pages', $args ), - esc_html__( 'Site Pages', 'jetpack' ), - 'wp-admin-bar-edit-page' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-page', - 'title' => $pages_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - - // Blog Posts. - $posts_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-edit-posts', $args ), - 'id' => 'wp-admin-bar-edit-post', - 'label' => esc_html__( 'Blog Posts', 'jetpack' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-post', $args ), - 'id' => 'wp-admin-bar-new-post-badge', - 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ), - ) - ); - - if ( ! current_user_can( 'edit_posts' ) ) { - $posts_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-edit-posts', $args ), - esc_html__( 'Blog Posts', 'jetpack' ), - 'wp-admin-bar-edit-post' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-post', - 'title' => $posts_title, - 'meta' => array( - 'class' => 'inline-action mb-trackable', - ), - ) - ); - - // Comments. - if ( current_user_can( 'moderate_comments' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'comments', - 'title' => __( 'Comments', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-comments', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - // Testimonials. - if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_testimonial' ) ) { - $testimonials_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-list-jetpack-testimonial', $args ), - 'id' => 'wp-admin-bar-edit-testimonial', - 'label' => esc_html__( 'Testimonials', 'jetpack' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-jetpack-testimonial', $args ), - 'id' => 'wp-admin-bar-new-testimonial', - 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ), - ) - ); - - if ( ! current_user_can( 'edit_pages' ) ) { - $testimonials_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-list-jetpack-testimonial', $args ), - esc_html__( 'Testimonials', 'jetpack' ), - 'wp-admin-bar-edit-testimonial' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-jetpack-testimonial', - 'title' => $testimonials_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - // Portfolio. - if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_portfolio' ) ) { - $portfolios_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-list-jetpack-portfolio', $args ), - 'id' => 'wp-admin-bar-edit-portfolio', - 'label' => esc_html__( 'Portfolio', 'jetpack' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-edit-jetpack-portfolio', $args ), - 'id' => 'wp-admin-bar-new-portfolio', - 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ), - ) - ); - - if ( ! current_user_can( 'edit_pages' ) ) { - $portfolios_title = $this->create_menu_item_anchor( - 'ab-item ab-primary mb-icon', - Redirect::get_url( 'calypso-list-jetpack-portfolio', $args ), - esc_html__( 'Portfolio', 'jetpack' ), - 'wp-admin-bar-edit-portfolio' - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'publish', - 'id' => 'new-jetpack-portfolio', - 'title' => $portfolios_title, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - if ( current_user_can( 'edit_theme_options' ) ) { - // Look and Feel group. - $wp_admin_bar->add_group( - array( - 'parent' => 'blog', - 'id' => 'look-and-feel', - ) - ); - - // Look and Feel header. - $wp_admin_bar->add_menu( - array( - 'parent' => 'look-and-feel', - 'id' => 'look-and-feel-header', - 'title' => esc_html_x( 'Personalize', 'admin bar menu group label', 'jetpack' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; - if ( is_admin() ) { - // In wp-admin the `return` query arg will return to that page after closing the Customizer. - $customizer_url = add_query_arg( - array( - 'return' => rawurlencode( site_url( $request_uri ) ), - ), - wp_customize_url() - ); - } else { - /* - * On the frontend the `url` query arg will load that page in the Customizer - * and also return to it after closing - * non-home URLs won't work unless we undo domain mapping - * since the Customizer preview is unmapped to always have HTTPS. - */ - $current_page = '//' . $this->primary_site_slug . $request_uri; - $customizer_url = add_query_arg( array( 'url' => rawurlencode( $current_page ) ), wp_customize_url() ); - } - - $theme_title = $this->create_menu_item_pair( - array( - 'url' => $customizer_url, - 'id' => 'wp-admin-bar-cmz', - 'label' => esc_html_x( 'Customize', 'admin bar customize item label', 'jetpack' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-themes', $args ), - 'id' => 'wp-admin-bar-themes', - 'label' => esc_html__( 'Themes', 'jetpack' ), - ) - ); - $meta = array( - 'class' => 'mb-icon inline-action', - ); - $href = false; - - $wp_admin_bar->add_menu( - array( - 'parent' => 'look-and-feel', - 'id' => 'themes', - 'title' => $theme_title, - 'href' => $href, - 'meta' => $meta, - ) - ); - } - if ( current_user_can( 'manage_options' ) ) { - // Configuration group. - $wp_admin_bar->add_group( - array( - 'parent' => 'blog', - 'id' => 'configuration', - ) - ); - - // Configuration header. - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'configuration-header', - 'title' => esc_html_x( 'Configure', 'admin bar menu group label', 'jetpack' ), - 'meta' => array( - 'class' => 'ab-submenu-header', - ), - ) - ); - - if ( Jetpack::is_module_active( 'publicize' ) || Jetpack::is_module_active( 'sharedaddy' ) ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'sharing', - 'title' => esc_html__( 'Sharing', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-sharing', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - - $people_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-people-team', $args ), - 'id' => 'wp-admin-bar-people', - 'label' => esc_html__( 'People', 'jetpack' ), - ), - array( - 'url' => admin_url( 'user-new.php' ), - 'id' => 'wp-admin-bar-people-add', - 'label' => esc_html_x( 'Add', 'admin bar people item label', 'jetpack' ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'users-toolbar', - 'title' => $people_title, - 'href' => false, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - - $plugins_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-plugins', $args ), - 'id' => 'wp-admin-bar-plugins', - 'label' => esc_html__( 'Plugins', 'jetpack' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-plugins-manage', $args ), - 'id' => 'wp-admin-bar-plugins-add', - 'label' => esc_html_x( 'Manage', 'Label for the button on the Masterbar to manage plugins', 'jetpack' ), - ) - ); - - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'plugins', - 'title' => $plugins_title, - 'href' => false, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - - if ( $this->site_woa ) { - $domain_title = $this->create_menu_item_pair( - array( - 'url' => Redirect::get_url( 'calypso-domains', $args ), - 'id' => 'wp-admin-bar-domains', - 'label' => esc_html__( 'Domains', 'jetpack' ), - ), - array( - 'url' => Redirect::get_url( 'calypso-domains-add', $args ), - 'id' => 'wp-admin-bar-domains-add', - 'label' => esc_html_x( 'Add', 'Label for the button on the Masterbar to add a new domain', 'jetpack' ), - ) - ); - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'domains', - 'title' => $domain_title, - 'href' => false, - 'meta' => array( - 'class' => 'inline-action', - ), - ) - ); - } - - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'blog-settings', - 'title' => esc_html__( 'Settings', 'jetpack' ), - 'href' => Redirect::get_url( 'calypso-settings-general', $args ), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - - if ( ! is_admin() ) { - $wp_admin_bar->add_menu( - array( - 'parent' => 'configuration', - 'id' => 'legacy-dashboard', - 'title' => esc_html__( 'Dashboard', 'jetpack' ), - 'href' => admin_url(), - 'meta' => array( - 'class' => 'mb-icon', - ), - ) - ); - } - // Restore dashboard menu toggle that is needed on mobile views. if ( is_admin() ) { $wp_admin_bar->add_menu( @@ -1525,7 +912,7 @@ public function add_my_sites_submenu( $wp_admin_bar ) { /** * Fires when menu items are added to the masterbar "My Sites" menu. * - * @since 5.4.0 + * @since jetpack-5.4.0 */ do_action( 'jetpack_masterbar' ); }