X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/af50974463450c98503e763a7836a50e260461a9..7f1521bf193b382565eb753043c161f4cb3fcda7:/wp-includes/admin-bar.php diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index 32853c3a..746fdca7 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -22,7 +22,7 @@ function _wp_admin_bar_init() { return false; /* Load the admin bar class code ready for instantiation */ - require( ABSPATH . WPINC . '/class-wp-admin-bar.php' ); + require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' ); /* Instantiate the admin bar */ @@ -44,9 +44,6 @@ function _wp_admin_bar_init() { return true; } -// Don't remove. Wrong way to disable. -add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); -add_action( 'admin_init', '_wp_admin_bar_init' ); /** * Render the admin bar to the page based on the $wp_admin_bar->menu member var. @@ -92,8 +89,6 @@ function wp_admin_bar_render() { */ do_action( 'wp_after_admin_bar_render' ); } -add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); -add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); /** * Add the WordPress logo menu. @@ -105,11 +100,8 @@ add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); function wp_admin_bar_wp_menu( $wp_admin_bar ) { $wp_admin_bar->add_menu( array( 'id' => 'wp-logo', - 'title' => '', + 'title' => '' . __( 'About WordPress' ) . '', 'href' => self_admin_url( 'about.php' ), - 'meta' => array( - 'title' => __('About WordPress'), - ), ) ); if ( is_user_logged_in() ) { @@ -118,7 +110,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) { 'parent' => 'wp-logo', 'id' => 'about', 'title' => __('About WordPress'), - 'href' => self_admin_url( 'about.php' ), + 'href' => self_admin_url( 'about.php' ), ) ); } @@ -135,7 +127,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) { 'parent' => 'wp-logo-external', 'id' => 'documentation', 'title' => __('Documentation'), - 'href' => __('http://codex.wordpress.org/'), + 'href' => __('https://codex.wordpress.org/'), ) ); // Add forums link @@ -198,7 +190,6 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) { 'href' => $profile_url, 'meta' => array( 'class' => $class, - 'title' => __('My Account'), ), ) ); } @@ -338,10 +329,16 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) return; + if ( $wp_admin_bar->user->active_blog ) { + $my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' ); + } else { + $my_sites_url = admin_url( 'my-sites.php' ); + } + $wp_admin_bar->add_menu( array( 'id' => 'my-sites', 'title' => __( 'My Sites' ), - 'href' => admin_url( 'my-sites.php' ), + 'href' => $my_sites_url, ) ); if ( is_super_admin() ) { @@ -609,9 +606,6 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 'id' => 'new-content', 'title' => $title, 'href' => admin_url( current( array_keys( $actions ) ) ), - 'meta' => array( - 'title' => _x( 'Add New', 'admin bar menu group label' ), - ), ) ); foreach ( $actions as $link => $action ) { @@ -662,14 +656,33 @@ function wp_admin_bar_comments_menu( $wp_admin_bar ) { function wp_admin_bar_appearance_menu( $wp_admin_bar ) { $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) ); - if ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) - $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'themes', 'title' => __('Themes'), 'href' => admin_url('themes.php') ) ); - - if ( ! current_user_can( 'edit_theme_options' ) ) - return; - $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ); + + if ( current_user_can( 'switch_themes' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'themes', + 'title' => __( 'Themes' ), + 'href' => admin_url( 'themes.php' ), + 'meta' => array( + 'class' => 'hide-if-customize', + ), + ) ); + + if ( current_user_can( 'customize' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'customize-themes', + 'title' => __( 'Themes' ), + 'href' => add_query_arg( urlencode( 'autofocus[section]' ), 'themes', $customize_url ), // urlencode() needed due to #16859 + 'meta' => array( + 'class' => 'hide-if-no-customize', + ), + ) ); + } + } + if ( current_user_can( 'customize' ) ) { $wp_admin_bar->add_menu( array( 'parent' => 'appearance', @@ -683,8 +696,33 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) { add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); } - if ( current_theme_supports( 'widgets' ) ) - $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __('Widgets'), 'href' => admin_url('widgets.php') ) ); + if ( ! current_user_can( 'edit_theme_options' ) ) { + return; + } + + if ( current_theme_supports( 'widgets' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'widgets', + 'title' => __( 'Widgets' ), + 'href' => admin_url( 'widgets.php' ), + 'meta' => array( + 'class' => 'hide-if-customize', + ), + ) ); + + if ( current_user_can( 'customize' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'customize-widgets', + 'title' => __( 'Widgets' ), + 'href' => add_query_arg( urlencode( 'autofocus[panel]' ), 'widgets', $customize_url ), // urlencode() needed due to #16859 + 'meta' => array( + 'class' => 'hide-if-no-customize', + ), + ) ); + } + } if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); @@ -779,6 +817,7 @@ function wp_admin_bar_search_menu( $wp_admin_bar ) { $form = '
'; $form .= ''; + $form .= ''; $form .= ''; $form .= '
';