From 22839d2a499479718867ecf4f36d226231a42770 Mon Sep 17 00:00:00 2001 From: westi Date: Thu, 28 Oct 2010 08:31:36 +0000 Subject: [PATCH] Admin bar cleanup. See #14772 props filosofo. Moves CSS into seperate files. Patch cleanup included moving function call arguments back on to one line where not necessary to split them. git-svn-id: http://svn.automattic.com/wordpress/trunk@16038 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/admin-bar.php | 365 +++++++------- wp-includes/admin-bar/admin-bar-class.php | 116 +++-- wp-includes/admin-bar/admin-bar-css.php | 453 ------------------ wp-includes/admin-bar/admin-bar-debug.php | 13 +- .../admin-bar/admin-bar-superadmin.php | 122 +++-- wp-includes/css/admin-bar-rtl.css | 1 + wp-includes/css/admin-bar-rtl.dev.css | 221 +++++++++ wp-includes/css/admin-bar.css | 1 + wp-includes/css/admin-bar.dev.css | 370 ++++++++++++++ wp-includes/css/super-admin-bar.css | 1 + wp-includes/css/super-admin-bar.dev.css | 222 +++++++++ wp-includes/script-loader.php | 6 +- 12 files changed, 1154 insertions(+), 737 deletions(-) delete mode 100644 wp-includes/admin-bar/admin-bar-css.php create mode 100644 wp-includes/css/admin-bar-rtl.css create mode 100644 wp-includes/css/admin-bar-rtl.dev.css create mode 100644 wp-includes/css/admin-bar.css create mode 100644 wp-includes/css/admin-bar.dev.css create mode 100644 wp-includes/css/super-admin-bar.css create mode 100644 wp-includes/css/super-admin-bar.dev.css diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index ef71ef084b..39eb5a7e71 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -6,45 +6,31 @@ */ /** - * Instantiate the admin bar class and set it up as a global for access elsewhere. + * Instantiate the admin bar object and set it up as a global for access elsewhere. + * + * @since 3.1.0 + * @return bool Whether the admin bar was successfully initialized. */ function wp_admin_bar_init() { - global $current_user, $pagenow, $wp_admin_bar; + global $wp_admin_bar; - if ( ! show_admin_bar() ) + if ( ! is_admin_bar_showing() ) return false; - /* Set the protocol constant used throughout this code */ - if ( !defined( 'PROTO' ) ) - if ( is_ssl() ) define( 'PROTO', 'https://' ); else define( 'PROTO', 'http://' ); - - /* Don't load the admin bar if the user is not logged in */ - if ( !is_user_logged_in() ) - return false; - - /* Set up the settings we need to render menu items */ - if ( !is_object( $current_user ) ) - $current_user = wp_get_current_user(); - - /* Enqueue the JS files for the admin bar. */ - wp_enqueue_script( 'jquery', false, false, false, true ); - /* Load the admin bar class code ready for instantiation */ require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' ); - /* Only load super admin menu code if the logged in user is a super admin */ - if ( is_super_admin() ) { - require( ABSPATH . WPINC . '/admin-bar/admin-bar-debug.php' ); - require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' ); - } + /* Instantiate the admin bar */ + $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); + if ( class_exists( $admin_bar_class ) ) + $wp_admin_bar = new $admin_bar_class; + else + return false; + + $wp_admin_bar->initialize(); + $wp_admin_bar->add_menus(); - /* Initialize the admin bar */ - $wp_admin_bar = new wp_admin_bar(); - - add_action( 'wp_head', 'wp_admin_bar_css' ); - add_action( 'admin_head', 'wp_admin_bar_css' ); - - do_action('admin_bar_init'); + return true; } add_action( 'init', 'wp_admin_bar_init' ); @@ -56,11 +42,13 @@ add_action( 'init', 'wp_admin_bar_init' ); * It includes the action "wp_before_admin_bar_render" which should be used to hook in and * add new menus to the admin bar. That way you can be sure that you are adding at most optimal point, * right before the admin bar is rendered. This also gives you access to the $post global, among others. + * + * @since 3.1.0 */ function wp_admin_bar_render() { global $wp_admin_bar; - if ( !is_object( $wp_admin_bar ) ) + if ( ! is_object( $wp_admin_bar ) ) return false; $wp_admin_bar->load_user_locale_translations(); @@ -78,57 +66,50 @@ add_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); /** * Show the logged in user's gravatar as a separator. + * + * @since 3.1.0 */ function wp_admin_bar_me_separator() { - global $wp_admin_bar, $current_user; - - if ( !is_object( $wp_admin_bar ) ) - return false; - - $wp_admin_bar->add_menu( array( 'id' => 'me', 'title' => get_avatar( $current_user->ID, 16 ), 'href' => $wp_admin_bar->user->account_domain . 'wp-admin/profile.php' ) ); + global $wp_admin_bar; + $wp_admin_bar->add_menu( array( 'id' => 'me', 'title' => get_avatar( get_current_user_id(), 16 ), 'href' => admin_url('profile.php'), ) ); } -add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_me_separator', 10 ); /** - * Use the $wp_admin_bar global to add the "My Account" menu and all submenus. + * Add the "My Account" menu and all submenus. + * + * @since 3.1.0 */ function wp_admin_bar_my_account_menu() { - global $wp_admin_bar, $current_user; - - if ( !is_object( $wp_admin_bar ) ) - return false; + global $wp_admin_bar; /* Add the 'My Account' menu */ - $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __( 'My Account' ), 'href' => admin_url('profile.php') ) ); + $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __( 'My Account' ), 'href' => admin_url('profile.php'), ) ); /* Add the "My Account" sub menus */ - $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Edit My Profile' ), 'href' => admin_url('profile.php') ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Global Dashboard' ), 'href' => admin_url() ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Edit My Profile' ), 'href' => admin_url('profile.php'), ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Global Dashboard' ), 'href' => admin_url(), ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Log Out' ), 'href' => wp_logout_url(), ) ); } -add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_account_menu', 20 ); /** - * Use the $wp_admin_bar global to add the "My Sites/[Site Name]" menu and all submenus. + * Add the "My Sites/[Site Name]" menu and all submenus. + * + * @since 3.1.0 */ function wp_admin_bar_my_blogs_menu() { global $wpdb, $wp_admin_bar; - if ( !is_object( $wp_admin_bar ) ) - return false; - /* Add the 'My Dashboards' menu if the user has more than one site. */ if ( count( $wp_admin_bar->user->blogs ) > 1 ) { - $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => $wp_admin_bar->user->account_domain ) ); + $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => $wp_admin_bar->user->account_domain, ) ); $default = includes_url('images/wpmini-blue.png'); - $counter = 2; foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { $blogdomain = preg_replace( '!^https?://!', '', $blog->siteurl ); // @todo Replace with some favicon lookup. //$blavatar = 'Blavatar'; - $blavatar = 'Blavatar';; + $blavatar = '' . esc_attr__( 'Blavatar' ) . ''; $marker = ''; if ( strlen($blog->blogname) > 35 ) @@ -139,205 +120,183 @@ function wp_admin_bar_my_blogs_menu() { else $blogname = substr( $blog->blogname, 0, 35 ) . $marker; - if ( !isset( $blog->visible ) || $blog->visible === true ) { - $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/' ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/' ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/post-new.php' ) ); + if ( ! isset( $blog->visible ) || $blog->visible === true ) { + $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/', ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/', ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/post-new.php', ) ); + // @todo, stats plugins should add this: - //$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-s', 'title' => __( 'Site Stats' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/index.php?page=stats' ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/edit-comments.php' ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Read Site' ), 'href' => constant( 'PROTO' ) . $blogdomain ) ); + //$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-s', 'title' => __( 'Site Stats' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/index.php?page=stats' ) ); + + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/edit-comments.php', ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Read Site' ), 'href' => $wp_admin_bar->proto . $blogdomain, ) ); } - $counter++; } /* Add the "Manage Sites" menu item */ // @todo, use dashboard site. - $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'manage-blogs', 'title' => __( 'Manage Sites' ), admin_url('my-sites.php') ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'manage-blogs', 'title' => __( 'Manage Sites' ), admin_url('my-sites.php'), ) ); /* Add the 'My Dashboard' menu if the user only has one site. */ } else { - $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Site' ), 'href' => $wp_admin_bar->user->account_domain ) ); + $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Site' ), 'href' => $wp_admin_bar->user->account_domain, ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-d', 'title' => __( 'Dashboard' ), 'href' => admin_url(),) ); + $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-n', 'title' => __( 'New Post' ), 'href' => admin_url('post-new.php'),) ); - $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-d', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-n', 'title' => __( 'New Post' ), 'href' => admin_url('post-new.php') ) ); // @todo Stats plugins should add this. //$wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-s', 'title' => __( 'Site Stats' ), 'href' => admin_ur;('index.php?page=stats') ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-c', 'title' => __( 'Manage Comments' ), 'href' => admin_url('edit-comments.php') ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-v', 'title' => __( 'Read Site' ), 'href' => home_url() ) ); + + $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-c','title' => __( 'Manage Comments' ), 'href' => admin_url('edit-comments.php'), ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-v', 'title' => __( 'Read Site' ), 'href' => home_url(),) ); } } -add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_blogs_menu', 30 ); /** * Show the blavatar of the current site as a separator. + * + * @since 3.1.0 */ function wp_admin_bar_blog_separator() { - global $wp_admin_bar, $current_user, $current_blog; - - if ( !is_object( $wp_admin_bar ) ) - return false; - + global $wp_admin_bar, $current_blog; $default = includes_url('images/wpmini-blue.png'); - - $wp_admin_bar->add_menu( array( 'id' => 'blog', 'title' => '' . __( 'Current site avatar' ) . '', 'href' => home_url() ) ); + $wp_admin_bar->add_menu( array( 'id' => 'blog', 'title' => '' . esc_attr__( 'Current site avatar' ) . '', 'href' => home_url(), ) ); } -add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_blog_separator', 40 ); /** - * Use the $wp_admin_bar global to add a menu for site info, accessable to all users. + * Site info menu + * + * @since 3.1.0 */ function wp_admin_bar_bloginfo_menu() { global $wp_admin_bar; - if ( !is_object( $wp_admin_bar ) ) - return false; - /* Add the Site Info menu */ - $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '' ) ); + $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '', ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'bloginfo', 'title' => __( 'Get Shortlink' ), 'href' => '', 'meta' => array( 'onclick' => 'javascript:function wpcomshort() { var url=document.location;var links=document.getElementsByTagName('link');var found=0;for(var i = 0, l; l = links[i]; i++){if(l.getAttribute('rel')=='shortlink') {found=l.getAttribute('href');break;}}if (!found) {for (var i = 0; l = document.links[i]; i++) {if (l.getAttribute('rel') == 'shortlink') {found = l.getAttribute('href');break;}}}if (found) {prompt('URL:', found);} else {alert('No shortlink available for this page'); } } wpcomshort(); return false;' ) ) ); + // TODO: Move this js out into a seperate file? + $wp_admin_bar->add_menu( array( 'parent' => 'bloginfo', 'title' => __( 'Get Shortlink' ), 'href' => '', 'meta' => array( + 'onclick' => 'javascript:function wpcomshort() { var url=document.location;var links=document.getElementsByTagName('link');var found=0;for(var i = 0, l; l = links[i]; i++){if(l.getAttribute('rel')=='shortlink') {found=l.getAttribute('href');break;}}if (!found) {for (var i = 0; l = document.links[i]; i++) {if (l.getAttribute('rel') == 'shortlink') {found = l.getAttribute('href');break;}}}if (found) {prompt('' . esc_js( __( 'URL:' ) ) . '', found);} else {alert('' . esc_js( __( 'No shortlink available for this page.' ) ) . ''); } } wpcomshort(); return false;' ) ) ); } -add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_bloginfo_menu', 50 ); /** - * Use the $wp_admin_bar global to add the "Edit Post" menu when viewing a single post. + * Provide an edit link for posts and terms. + * + * @since 3.1.0 */ function wp_admin_bar_edit_menu() { - global $post, $wp_admin_bar; + global $wp_admin_bar, $wp_query; - if ( !is_object( $wp_admin_bar ) ) + $current_object = $wp_query->get_queried_object(); + + if ( empty( $current_object ) ) return false; - if ( !is_single() && !is_page() ) - return false; - - if ( !$post_type_object = get_post_type_object( $post->post_type ) ) - return false; - - if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) - return false; - - $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_post_link( $post->ID ) ) ); -} -add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 100 ); - -/** - * Load up the CSS needed to render the admin bar nice and pretty. - */ -function wp_admin_bar_css() { - global $pagenow, $wp_locale, $wp_admin_bar; - - if ( !is_object( $wp_admin_bar ) ) - return false; - - if ( !is_user_logged_in() ) - return; - - $nobump = false; - - /* Wish we could use wp_enqueue_style() here, but it will not let us pass GET params to the stylesheet correctly. */ - ?> - - - post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) ) { + $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_post_link( $current_object->ID ), ) ); + } elseif ( ! empty( $current_object->taxonomy ) && ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) ) { + $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ), ) ); + } } /** - * Load up the JS needed to allow the admin bar to function correctly. + * Style and scripts for the admin bar. + * + * @since 3.1.0 + * @todo move js into a admin-bar js file + * */ -function wp_admin_bar_js() { - global $wp_admin_bar; - - if ( !is_object( $wp_admin_bar ) ) - return false; - +function wp_admin_bar_header() { ?> + */ + + + + \ No newline at end of file +?> diff --git a/wp-includes/admin-bar/admin-bar-class.php b/wp-includes/admin-bar/admin-bar-class.php index 8d1aba11df..f213d448a2 100644 --- a/wp-includes/admin-bar/admin-bar-class.php +++ b/wp-includes/admin-bar/admin-bar-class.php @@ -1,20 +1,31 @@ proto = 'https://'; $this->user = new stdClass; $this->menu = new stdClass; /* Populate settings we need for the menu based on the current user. */ - $this->user->blogs = get_blogs_of_user( $current_user->id ); + $this->user->blogs = get_blogs_of_user( get_current_user_id() ); if ( is_multisite() ) { - $this->user->active_blog = get_active_blog_for_user( $current_user->id ); + $this->user->active_blog = get_active_blog_for_user( get_current_user_id() ); $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) ); $this->user->account_domain = $this->user->domain; } else { @@ -23,6 +34,17 @@ class WP_Admin_Bar { $this->user->account_domain = $this->user->domain; } $this->user->locale = get_locale(); + + add_action( 'wp_head', 'wp_admin_bar_header' ); + add_action( 'admin_head', 'wp_admin_bar_header' ); + + wp_enqueue_style( 'admin-bar' ); + + if ( is_super_admin() ) { + wp_enqueue_style( 'super-admin-bar' ); + } + + do_action( 'admin_bar_init' ); } function add_menu( $args = array() ) { @@ -44,26 +66,19 @@ class WP_Admin_Bar { if ( empty( $id ) ) $id = esc_attr( sanitize_title( trim( $title ) ) ); - if ( !empty( $parent ) ) { + if ( ! empty( $parent ) ) { /* Add the menu to the parent item */ - $child = array( - 'id' => $id, - 'title' => $title, - 'href' => $href - ); + $child = array( 'id' => $id, 'title' => $title, 'href' => $href ); - if ( !empty( $meta ) ) + if ( ! empty( $meta ) ) $child['meta'] = $meta; $this->add_node( $parent, $this->menu, $child ); } else { /* Add the menu item */ - $this->menu->{$id} = array( - 'title' => $title, - 'href' => $href - ); + $this->menu->{$id} = array( 'title' => $title, 'href' => $href ); - if ( !empty( $meta ) ) + if ( ! empty( $meta ) ) $this->menu->{$id}['meta'] = $meta; } } @@ -73,7 +88,7 @@ class WP_Admin_Bar { } function render() { - ?> + ?>
@@ -97,12 +113,36 @@ class WP_Admin_Bar { /* Helpers */ function recursive_render( $id, &$menu_item ) { ?> - + -
  • "> - onclick="" target=""> +
  • "> + onclick="" target=""> - +
      $child_menu_item ) : ?> recursive_render( $child_id, $child_menu_item ); ?> @@ -110,7 +150,7 @@ class WP_Admin_Bar {
    - +
  • {$id}['children'] ) ) + if ( ! empty( $menu->{$id}['children'] ) ) $this->add_node( $parent_id, $menu->{$id}['children'], $child ); } + $child = null; return false; } + function add_menus() { + add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_me_separator', 10 ); + add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_account_menu', 20 ); + add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_blogs_menu', 30 ); + add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_blog_separator', 40 ); + add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_bloginfo_menu', 50 ); + add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 100 ); + + if ( is_multisite() && is_super_admin() && function_exists('wp_admin_bar_superadmin_settings_menu') ) + add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_superadmin_settings_menu', 1000 ); + + do_action('add_admin_bar_menus'); + } + function remove_node( $id, &$menu ) { foreach( $menu as $menu_item_id => &$menu_item ) { if ( $menu_item_id == $id ) { @@ -139,7 +194,7 @@ class WP_Admin_Bar { return true; } - if ( !empty( $menu->{$menu_item_id}['children'] ) ) + if ( ! empty( $menu->{$menu_item_id}['children'] ) ) $this->remove_node( $id, $menu->{$menu_item_id}['children'] ); } @@ -148,7 +203,8 @@ class WP_Admin_Bar { function load_user_locale_translations() { $this->need_to_change_locale = ( get_locale() != $this->user->locale ); - if ( !$this->need_to_change_locale ) return; + if ( ! $this->need_to_change_locale ) + return; $this->previous_translations = get_translations_for_domain( 'default' ); $this->adminbar_locale_filter = lambda( '$_', '$GLOBALS["wp_admin_bar"]->user->locale;' ); unload_textdomain( 'default' ); @@ -159,10 +215,10 @@ class WP_Admin_Bar { function unload_user_locale_translations() { global $l10n; - if ( !$this->changed_locale ) return; + if ( ! $this->changed_locale ) + return; remove_filter( 'locale', $this->adminbar_locale_filter ); $l10n['default'] = &$this->previous_translations; - } } ?> diff --git a/wp-includes/admin-bar/admin-bar-css.php b/wp-includes/admin-bar/admin-bar-css.php deleted file mode 100644 index 64513fecf8..0000000000 --- a/wp-includes/admin-bar/admin-bar-css.php +++ /dev/null @@ -1,453 +0,0 @@ - - -#wpadminbar { direction:ltr; background:#666 url() 0 -222px repeat-x; color:#ddd; font:12px Arial, Helvetica, sans-serif; height:28px; left:0; margin:0; position:fixed; top:0; width:100%; z-index:99999; min-width: 960px; } -#wpadminbar ul, #wpadminbar ul li { position: relative; z-index: 99999; } -#wpadminbar ul li img { vertical-align: middle !important; margin-right: 8px !important; border: none !important; padding: 0 !important; } -#wpadminbar .quicklinks > ul > li > a { border-right: 1px solid #686868; border-left: 1px solid #808080; } -#wpadminbar .quicklinks > ul > li.ab-subscriptions > a, #wpadminbar .quicklinks > ul > li:last-child > a { border-right: none; } -#wpadminbar .quicklinks > ul > li.hover > a { border-left-color: #707070; } -#wpadminbar a { outline: none; } -#wpadminbar .avatar {border:1px solid #999 !important;padding:0 !important;margin:-3px 5px 0 0 !important;vertical-align:middle;float:none;display:inline !important; } -#wpadminbar .menupop ul li a {color:#555 !important;text-shadow:none;font-weight:normal;white-space:nowrap;} -#wpadminbar .menupop a > span {background:url() 100% 100.4% no-repeat;padding-right:.8em;line-height: 28px;} -#wpadminbar .menupop ul li a > span { display: block; background:url() 100% 97.2% no-repeat;padding-right:1.5em;line-height: 28px;} -#wpadminbar .menupop ul li a span#awaiting-mod { display: inline; background: #aaa; color: #fff; padding: 1px 5px; font-size: 10px; font-family: verdana; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } -#wpadminbar .menupop ul li a:hover span#awaiting-mod { background: #fff; color: #888; } -#wpadminbar .menupop ul {-moz-box-shadow:0 4px 8px rgba(0,0,0,0.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,0.1);background:#fff;display:none;position:absolute;border:1px solid #dfdfdf;border-top:none !important;float:none} -html>body #wpadminbar .menupop ul {background:rgba(255,255,255,0.97);border-color:rgba(0,0,0,0.1);} -#wpadminbar .menupop.ab-my-account ul, #wpadminbar .menupop.ab-my-dash ul, #wpadminbar .menupop.ab-new-post ul {min-width:140px} -#wpadminbar .menupop li {float:none;margin:0;padding:0;background-image:none;} -#wpadminbar .quicklinks a {border:none;color:#ddd !important;text-shadow:#555 0px -1px 0px;display:block;font:13px Arial, Helvetica, sans-serif;font-weight:normal;letter-spacing:normal;padding:0 0.85em;line-height:28px;text-decoration:none !important;} -#wpadminbar .quicklinks a:hover {text-shadow:#333 0px -1px 0px;} -#wpadminbar li.ab-privacy { float: right; background: #333; } -#wpadminbar li.ab-privacy > a > span { background: none; padding: 0; } -#wpadminbar li.ab-privacy span#priv-icon { display: block; text-indent: -999em; background:url() 40% 59.7% no-repeat; padding: 0; width: 13px; margin-right: -3px; } - -#wpadminbar li.ab-sadmin { float: right; background: #555 } -#wpadminbar li.ab-sadmin ul, #wpadminbar li.ab-privacy ul { right: 0; float: right; } -#wpadminbar li.ab-sadmin > a { font-size: 11px !important; padding: 0 7px !important; border: none !important; border-left: 1px solid #666 !important; } - -#wpadminbar li.ab-sadmin ul a, #wpadminbar li.ab-privacy a { border-right: none !important; border-left: none !important; } -#wpadminbar li.ab-sadmin ul li { right: 0; float: right; text-align: left; width: 100%; } -#wpadminbar li.ab-sadmin ul li a { padding-left: 1.75em; } -#wpadminbar li.ab-sadmin ul li a > span { background:url() 0% 101.8% no-repeat;padding-left: 1.25em; margin-left: -1.25em; line-height: 28px; padding-right: 0 !important; } -#wpadminbar li a.loading { background: url() 32% 59.8% no-repeat !important; text-indent: -999em; overflow: hidden; padding: 0 16px 0 0; height: 28px; display: block; float: left; margin-right: 2px; } - -#wpadminbar li:hover {background: #555 url() 0 -282px repeat-x;} -#wpadminbar li li:hover { color:#fff !important; background: #888 url() 0 -222px repeat-x !important;text-shadow: #666 0px -1px 0px;} -#wpadminbar li li:hover > a { color:#fff !important; } -.quicklinks ul {list-style:none;margin:0;padding:0;text-align:left} -.quicklinks ul li {float:left;margin:0} - -#adminbarlogin {float:left;display:inline;} - -#adminbarsearch {float:right; } -#adminbarsearch {height: 18px;padding: 3px;} -#adminbarsearch * {color: #555;font-size:12px;} -#adminbarsearch label, #adminbarsearch a { height: 28px; color: #ccc; display:block;float:left;padding:3px 4px;text-shadow:0px -1px 0px #444;} -#adminbarsearch a {text-decoration:underline;} -#adminbarsearch a:hover {color:#fff;} - -#wpadminbar li.ab-me:hover, #wpadminbar li.ab-blog:hover { background:none;} -#wpadminbar li.ab-me > a, #wpadminbar li.ab-blog > a { line-height: 18px !important; border: none !important; background:url() 100% 59.8% no-repeat; height: 28px; padding: 0 1.15em 0 0.7em; } -#wpadminbar li.ab-me > a.hover, #wpadminbar li.ab-blog > a.hover { background-position: 67% 59.8%; } -#wpadminbar li.ab-me img.avatar, #wpadminbar li.ab-blog img.avatar { margin: 4px 0 0 0 !important; vertical-align: middle; background: #eee; width: 16px !important; height: 16px !important; } -#wpadminbar li.ab-my-account a, #wpadminbar li.ab-bloginfo a { border-left: none !important; padding-left: 0.7em !important; margin-top: 0 !important; } -#wpadminbar li.ab-my-account > ul, #wpadminbar li.ab-bloginfo > ul { left: -7px; } -#wpadminbar ul li img { width: 16px !important; height: 16px !important; } - -#wpadminbar ul li a strong.count { text-shadow: none; background: #ddd; color: #555; margin-left: 5px; padding: 1px 6px; top: -1px; position: relative; font-size: 9px; -moz-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px; font-weight: normal } - -#wpadminbar #q { - line-height:normal !important; - width:140px !important; - margin-top:0px !important; -} -.adminbar-input { - display:block !important; - float:left !important; - font:12px Arial,Helvetica,sans-serif !important; - border:1px solid #626262 !important; - padding:2px 3px !important; - margin-right:3px !important; - background:#ddd url() top left no-repeat !important; - -webkit-border-radius:0 !important; - -khtml-border-radius:0 !important; - -moz-border-radius:0 !important; - border-radius:0 !important; - outline:none; - text-shadow:0 1px 0 #fff; -} -button.adminbar-button { - position:relative; - border:0; - cursor:pointer; - overflow:visible; - margin:0 !important; - float:left; - background:url() right -107px no-repeat; - padding:0 14px 0 0; - text-align:center; -} -button.adminbar-button span { - position:relative; - display:block; - white-space:nowrap; - height:19px; - background:url() left -69px no-repeat; - padding:3px 0 0 14px; - font:12px Arial,Helvetica,sans-serif !important; - font-weight:bold !important; - color:#444 !important; - text-shadow:0px 1px 0px #eee !important; -} -button.adminbar-button:active { - background-position:right -184px !important; - text-shadow:0px 1px 0px #eee !important; -} -button.adminbar-button:hover span { - color:#000 !important; -} -button.adminbar-button:active span { - background-position:left -146px !important; -} -button.adminbar-button::-moz-focus-inner { - border:none; -} -@media screen and (-webkit-min-device-pixel-ratio:0) { - button.adminbar-button span { - margin-top: -1px; - } -} - - - #wpadminbar { - direction:rtl; - font-family: Tahoma, Arial ,sans-serif; - right:0; - left:auto; - } - #wpadminbar div, #wpadminbar ul, #wpadminbar ul li { - min-height: 0; - } - #wpadminbar ul li img { margin-left: 8px !important; margin-right: 0 !important; } - #wpadminbar .quicklinks > ul > li > a { border-left: 1px solid #686868; border-right: 1px solid #808080;} - #wpadminbar .quicklinks > ul > li.ab-subscriptions > a, #wpadminbar .quicklinks > ul > li:last-child > a { border-left: none; border-right: 1px solid #808080;} - #wpadminbar .quicklinks > ul > li.hover > a { border-right-color: #707070; border-left-color: #686868; } - #wpadminbar .avatar {margin: -3px 0 0 5px !important; float:none; } - #wpadminbar .menupop a > span {background-position: 0 100.4%; padding-left:.8em;} - #wpadminbar .menupop ul li a > span { background-position: 0% 97.2%; padding-right:0;padding-left:1.5em } - #wpadminbar .menupop ul {right: 0; width:100%; min-width:150px;} - #wpadminbar .ab-my-account ul { width:200px;} - #wpadminbar .ab-my-blogs ul { width:300px;} - #wpadminbar .ab-my-blogs ul ul { width:200px;} - #wpadminbar .ab-subscribe ul { width:150px;} - #wpadminbar .ab-bloginfo ul { width:200px;} - #wpadminbar .ab-subscribe ul { width:150px;} - #wpadminbar .ab-subscriptions ul { width:200px;} - #wpadminbar .menupop ul li {width:auto} - #wpadminbar .quicklinks a {font-family: Tahoma, Arial, Helvetica, sans-serif;} - #wpadminbar li.ab-privacy { float: left; } - #wpadminbar li.ab-privacy span#priv-icon { text-indent: 999em; background-position: 60% 59.7%; padding: 0; margin-right: 0; margin-left: -3px;} - - #wpadminbar li.ab-sadmin { float: left; } - #wpadminbar li.ab-sadmin ul, #wpadminbar li.ab-privacy ul { right: auto; left: 0; float: left; } - #wpadminbar li.ab-sadmin > a { border-right: 1px solid #666 !important; border-left:none !important;} - - #wpadminbar li.ab-sadmin ul a, #wpadminbar li.ab-privacy a { border-right: none !important; border-left: none !important; } - #wpadminbar li.ab-sadmin ul li { left: 0; right:auto; float: left; text-align: right; } - - - #wpadminbar li.ab-sadmin ul li a { padding-right: 1.75em; padding-left: 0 } - #wpadminbar li.ab-sadmin ul li a > span { background-position: 100% 101.8%; padding-right: 1.25em !important; padding-left: 0 !important; margin-right: -1.25em; margin-left: 0; } - #wpadminbar li a.loading { background-position: right 50% !important; padding-right: 29px; padding-left: 0;} - #wpadminbar li.subscribed a strong { background-position: 68% 59.8% !important; padding: 0 0 0 16px; float: right; margin-left: 2px; } - - - .quicklinks ul {text-align:right} - .quicklinks ul li {float:right;} - - #adminbarlogin {float:right;} - - #adminbarsearch {display:none;} - #adminbarsearch label, #adminbarsearch a { float:right;} - - #wpadminbar li.ab-me > a, #wpadminbar li.ab-blog > a { background-position:0% 59.8%; padding: 0 0.7em 0 1.15em; } - #wpadminbar li.ab-me > a.hover, #wpadminbar li.ab-blog > a.hover { background-position: 33% 59.8%; } - #wpadminbar li.ab-my-account a, #wpadminbar li.ab-bloginfo a { border-right: none !important; padding-right: 0.7em !important; } - #wpadminbar li.ab-my-account > ul, #wpadminbar li.ab-bloginfo > ul { right: -7px; left:auto;} - - #wpadminbar ul li a strong.count { margin-right: 5px; margin-left: 0; position:static} - - - .adminbar-input { - float:right !important; - font-family: Tahoma, Arial,Helvetica,sans-serif !important; - margin-right:3px !important; - margin-left:0 !important; - background-position: right top !important; - } - button.adminbar-button { - float:right; - background-position: left -107px; - padding:0 0 0 14px; - } - button.adminbar-button span { - background-position: right -69px; - padding:3px 14px 0 0; - font-family: Tahoma, Arial,Helvetica,sans-serif !important; - } - button.adminbar-button:active { - background-position:left -184px !important; - } - button.adminbar-button:active span { - background-position:right -146px !important; - } - - body { padding-top: 28px !important; } - - - - body { padding-top: 28px; background-position: 0px 28px; } - - - - #querylist { - font-family: Arial, Tahoma, sans-serif; - display: none; - position: absolute; - top: 50px; - left: 50px; - right: 50px; - background: #fff; - padding: 20px; - -moz-box-shadow: 0 0 15px #888; - -webkit-box-shadow: 0 0 15px #888; - box-shadow: 0 0 15px #888; - z-index: 99999; - border: 10px solid #f0f0f0; - color: #000; - line-height: 150% !important; - } - #querylist pre { - font-size: 12px; - padding: 10px; - } - - #querylist h1 { - font-family: georgia, times, serif; - text-align: center; - font-size: 24px; - padding: 20px 5px; - background: #eee; - color: #555; - margin: 0; - } - #querylist div#debug-status { - background: #ccc; - color: #fff; - overflow: hidden; - height: 21px; - font-size: 14px; - font-family: georgia, times, serif; - padding: 7px 15px; - } - #querylist .left { float: left; } - #querylist .right { float: right; } - - #querylist h1, #querylist h2, #querylist h3 { - font-weight: normal; - } - - #querylist ul.debug-menu-links { - clear: left; - background: #ccc; - padding: 10px 15px 0; - overflow: hidden; - list-style: none; - margin: 0; - padding: 0 0 0 15px; - } - #querylist ul.debug-menu-links li { - float: left; - margin-right: 10px; - margin-bottom: 0 !important; - } - - #querylist ul.debug-menu-links li a { - outline: none; - display: block; - padding: 5px 9px; - margin-right: 0; - background: #bbb; - color: #fff !important; - text-decoration: none !important; - font-weight: normal; - font-size: 12px; - color: #555; - -webkit-border-top-right-radius: 4px; - -webkit-border-top-left-radius: 4px; - -moz-border-radius-topright: 4px; - -moz-border-radius-topleft: 4px; - } - #querylist ul.debug-menu-links li.current a { - background: #fff; - color: #555 !important; - } - - #querylist h2 { - float: left; - min-width: 150px; - border: 1px solid #eee; - padding: 5px 10px 15px; - clear: none; important; - text-align: center; - font-family: georgia, times, serif; - font-size: 28px; - margin: 15px 10px 15px 0 !important; - } - #querylist h2 span { - font-size: 12px; - color: #888; - text-transform: uppercase; - white-space: nowrap; - display: block; - margin-bottom: 5px; - } - - #object-cache-stats h2 { - border: none; - float: none; - text-align: left; - font-size: 22px; - margin-bottom: 0; - } - - #object-cache-stats ul.debug-menu-links { - padding: 0; - margin: 0; - background: none; - } - #object-cache-stats ul.debug-menu-links li { - float: left; - margin-bottom: 10px !important; - background: none !important; - border: 1px solid #eee !important; - color: #555 !important; - } - #object-cache-stats ul.debug-menu-links li.current a { - background: #ccc !important; - color: #fff !important; - -webkit-border-top-right-radius: 0; - -webkit-border-top-left-radius: 0; - -moz-border-radius-topright: 0; - -moz-border-radius-topleft: 0; - } - - #object-cache-stats ul.debug-menu-links li a { - background: none; - color: #555 !important; - overflow: hidden; - } - - #querylist h3 { - margin-bottom: 15px; - } - - #querylist ol#wpd-queries { - padding: 0 !important; - margin: 0 !important; - list-style: none; - clear: left; - } - #querylist ol#wpd-queries li { - padding: 10px; - background: #f0f0f0; - margin: 0 0 10px 0; - } - #querylist ol#wpd-queries li div.qdebug { - background: #e8e8e8; - margin: 10px -10px -10px -10px; - padding: 5px 150px 5px 5px; - font-size: 11px; - position: relative; - min-height: 20px; - } - - #querylist ol#wpd-queries li div.qdebug span { - position: absolute; - right: 10px; - top: 5px; - white-space: nowrap; - } - - #querylist a { - text-decoration: underline !important; - color: blue !important; - } - #querylist a:hover { - text-decoration: none !important; - } - #querylist .debug-menu-target { - display: none; - } - - #querylist ol { - font: 12px Monaco, "Courier New", Courier, Fixed !important; - line-height: 180% !important; - } - - #wpadminbar #admin-bar-micro ul li { - list-style-type: none; - position: relative; - margin: 0; - padding: 0; - } - #wpadminbar #admin-bar-micro ul ul, #wpadminbar #admin-bar-micro #awaiting-mod, #wpadminbar .ab-sadmin .count-0 { - display: none !important; - } - #wpadminbar #admin-bar-micro ul li:hover > ul { - display: block; - position: absolute; - top: -1px; - left: 100%; - } - #wpadminbar #admin-bar-micro li a { - display: block; - text-decoration: none; - } - #wpadminbar #admin-bar-micro li li a { - background: #ddd; - } - #wpadminbar #admin-bar-micro li li li a { - background: #fff; - } - - - - #querylist { - direction: ltr; - } - - #wpadminbar #admin-bar-micro ul li:hover > ul { - left: auto; - right: 100%; - } - - \ No newline at end of file diff --git a/wp-includes/admin-bar/admin-bar-debug.php b/wp-includes/admin-bar/admin-bar-debug.php index 5d1c0df207..928d0a1b2c 100644 --- a/wp-includes/admin-bar/admin-bar-debug.php +++ b/wp-includes/admin-bar/admin-bar-debug.php @@ -11,7 +11,7 @@ function wp_admin_bar_debug_menu() { global $wp_admin_bar, $wpdb; - if ( !is_super_admin() || !apply_filters('wp_admin_bar_enable_debug_menu', false) ) + if ( ! is_super_admin() || ! apply_filters('wp_admin_bar_enable_debug_menu', false ) ) return; $queries = $wpdb->num_queries; @@ -44,6 +44,15 @@ function wp_admin_bar_query_debug_list() { ?>