Make WordPress Core

Changeset 16038


Ignore:
Timestamp:
10/28/2010 08:31:36 AM (16 years ago)
Author:
westi
Message:

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.

Location:
trunk/wp-includes
Files:
7 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/admin-bar.php

    r15938 r16038  
    77 
    88/**
    9  * Instantiate the admin bar class and set it up as a global for access elsewhere.
     9 * Instantiate the admin bar object and set it up as a global for access elsewhere.
     10 *
     11 * @since 3.1.0
     12 * @return bool Whether the admin bar was successfully initialized.
    1013 */
    1114function wp_admin_bar_init() {
    12         global $current_user, $pagenow, $wp_admin_bar;
    13 
    14         if ( ! show_admin_bar() )
     15        global $wp_admin_bar;
     16
     17        if ( ! is_admin_bar_showing() )
    1518                return false;
    16 
    17         /* Set the protocol constant used throughout this code */
    18         if ( !defined( 'PROTO' ) )
    19                 if ( is_ssl() ) define( 'PROTO', 'https://' ); else define( 'PROTO', 'http://' );
    20 
    21         /* Don't load the admin bar if the user is not logged in */
    22         if ( !is_user_logged_in() )
    23                 return false;
    24 
    25         /* Set up the settings we need to render menu items */
    26         if ( !is_object( $current_user ) )
    27                 $current_user = wp_get_current_user();
    28 
    29         /* Enqueue the JS files for the admin bar. */
    30         wp_enqueue_script( 'jquery', false, false, false, true );
    3119
    3220        /* Load the admin bar class code ready for instantiation */
    3321        require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' );
    3422
    35         /* Only load super admin menu code if the logged in user is a super admin */
    36         if ( is_super_admin() ) {
    37                 require( ABSPATH . WPINC . '/admin-bar/admin-bar-debug.php' );
    38                 require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' );
    39         }
    40 
    41         /* Initialize the admin bar */
    42         $wp_admin_bar = new wp_admin_bar();
    43 
    44         add_action( 'wp_head', 'wp_admin_bar_css' );
    45         add_action( 'admin_head', 'wp_admin_bar_css' );
    46 
    47         do_action('admin_bar_init');
     23        /* Instantiate the admin bar */
     24        $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
     25        if ( class_exists( $admin_bar_class ) )
     26                $wp_admin_bar = new $admin_bar_class;
     27        else
     28                return false;
     29       
     30        $wp_admin_bar->initialize();
     31        $wp_admin_bar->add_menus();
     32
     33        return true;
    4834}
    4935add_action( 'init', 'wp_admin_bar_init' );
    … …  
    5743 * add new menus to the admin bar. That way you can be sure that you are adding at most optimal point,
    5844 * right before the admin bar is rendered. This also gives you access to the $post global, among others.
     45 *
     46 * @since 3.1.0
    5947 */
    6048function wp_admin_bar_render() {
    6149        global $wp_admin_bar;
    6250
    63         if ( !is_object( $wp_admin_bar ) )
     51        if ( ! is_object( $wp_admin_bar ) )
    6452                return false;
    6553
    … …  
    7967/**
    8068 * Show the logged in user's gravatar as a separator.
     69 *
     70 * @since 3.1.0
    8171 */
    8272function wp_admin_bar_me_separator() {
    83         global $wp_admin_bar, $current_user;
    84 
    85         if ( !is_object( $wp_admin_bar ) )
    86                 return false;
    87 
    88         $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' ) );
    89 }
    90 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_me_separator', 10 );
    91 
    92 /**
    93  * Use the $wp_admin_bar global to add the "My Account" menu and all submenus.
     73        global $wp_admin_bar;
     74        $wp_admin_bar->add_menu( array( 'id' => 'me', 'title' => get_avatar( get_current_user_id(), 16 ), 'href' => admin_url('profile.php'), ) );
     75}
     76
     77/**
     78 * Add the "My Account" menu and all submenus.
     79 *
     80 * @since 3.1.0
    9481 */
    9582function wp_admin_bar_my_account_menu() {
    96         global $wp_admin_bar, $current_user;
    97 
    98         if ( !is_object( $wp_admin_bar ) )
    99                 return false;
     83        global $wp_admin_bar;
    10084
    10185        /* Add the 'My Account' menu */
    102         $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __( 'My Account' ), 'href' => admin_url('profile.php') ) );
     86        $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __( 'My Account' ),  'href' => admin_url('profile.php'), ) );
    10387
    10488        /* Add the "My Account" sub menus */
    105         $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Edit My Profile' ), 'href' => admin_url('profile.php') ) );
    106         $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Global Dashboard' ), 'href' => admin_url() ) );
    107         $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) );
    108 }
    109 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_account_menu', 20 );
    110 
    111 /**
    112  * Use the $wp_admin_bar global to add the "My Sites/[Site Name]" menu and all submenus.
     89        $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Edit My Profile' ), 'href' => admin_url('profile.php'), ) );
     90        $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Global Dashboard' ), 'href' => admin_url(), ) );
     91        $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Log Out' ), 'href' => wp_logout_url(), ) );
     92}
     93
     94/**
     95 * Add the "My Sites/[Site Name]" menu and all submenus.
     96 *
     97 * @since 3.1.0
    11398 */
    11499function wp_admin_bar_my_blogs_menu() {
    115100        global $wpdb, $wp_admin_bar;
    116101
    117         if ( !is_object( $wp_admin_bar ) )
    118                 return false;
    119 
    120102        /* Add the 'My Dashboards' menu if the user has more than one site. */
    121103        if ( count( $wp_admin_bar->user->blogs ) > 1 ) {
    122                 $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => $wp_admin_bar->user->account_domain ) );
     104                $wp_admin_bar->add_menu( array(  'id' => 'my-blogs', 'title' => __( 'My Sites' ),  'href' => $wp_admin_bar->user->account_domain, ) );
    123105
    124106                $default = includes_url('images/wpmini-blue.png');
    125107
    126                 $counter = 2;
    127108                foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
    128109                        $blogdomain = preg_replace( '!^https?://!', '', $blog->siteurl );
    129110                        // @todo Replace with some favicon lookup.
    130111                        //$blavatar = '<img src="' . esc_url( blavatar_url( blavatar_domain( $blog->siteurl ), 'img', 16, $default ) ) . '" alt="Blavatar" width="16" height="16" />';
    131                         $blavatar = '<img src="' . esc_url($default) . '" alt="Blavatar" width="16" height="16" />';;
     112                        $blavatar = '<img src="' . esc_url($default) . '" alt="' . esc_attr__( 'Blavatar' ) . '" width="16" height="16" />';
    132113
    133114                        $marker = '';
    … …  
    140121                                $blogname = substr( $blog->blogname, 0, 35 ) . $marker;
    141122
    142                         if ( !isset( $blog->visible ) || $blog->visible === true ) {
    143                                 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/' ) );
    144                                 $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/' ) );
    145                                 $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' ) );
     123                        if ( ! isset( $blog->visible ) || $blog->visible === true ) {
     124                                $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/', ) );
     125                                $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/', ) );
     126                                $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', ) );
     127
    146128                                // @todo, stats plugins should add this:
    147                                 //$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' ) );
    148                                 $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' ) );
    149                                 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Read Site' ), 'href' => constant( 'PROTO' ) . $blogdomain ) );
     129                                //$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' ) );
     130                               
     131                                $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', ) );
     132                                $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, ) );
    150133                        }
    151                         $counter++;
    152134                }
    153135
    154136                /* Add the "Manage Sites" menu item */
    155137                // @todo, use dashboard site.
    156                 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'manage-blogs', 'title' => __( 'Manage Sites' ), admin_url('my-sites.php') ) );
     138                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'manage-blogs', 'title' => __( 'Manage Sites' ), admin_url('my-sites.php'), ) );
    157139
    158140        /* Add the 'My Dashboard' menu if the user only has one site. */
    159141        } else {
    160                 $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Site' ), 'href' => $wp_admin_bar->user->account_domain ) );
    161 
    162                 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-d', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
    163                 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-n', 'title' => __( 'New Post' ), 'href' => admin_url('post-new.php') ) );
     142                $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Site' ), 'href' => $wp_admin_bar->user->account_domain, ) );
     143                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-d', 'title' => __( 'Dashboard' ), 'href' => admin_url(),) );
     144                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-n', 'title' => __( 'New Post' ), 'href' => admin_url('post-new.php'),) );
     145
    164146                // @todo Stats plugins should add this.
    165147                //$wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-s', 'title' => __( 'Site Stats' ), 'href' => admin_ur;('index.php?page=stats') ) );
    166                 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-c', 'title' => __( 'Manage Comments' ), 'href' => admin_url('edit-comments.php') ) );
    167                 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-v', 'title' => __( 'Read Site' ), 'href' => home_url() ) );
     148
     149                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-c','title' => __( 'Manage Comments' ), 'href' => admin_url('edit-comments.php'), ) );
     150                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-v', 'title' => __( 'Read Site' ), 'href' => home_url(),) );
    168151        }
    169152}
    170 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_blogs_menu', 30 );
    171153
    172154/**
    173155 * Show the blavatar of the current site as a separator.
     156 *
     157 * @since 3.1.0
    174158 */
    175159function wp_admin_bar_blog_separator() {
    176         global $wp_admin_bar, $current_user, $current_blog;
    177 
    178         if ( !is_object( $wp_admin_bar ) )
     160        global $wp_admin_bar, $current_blog;
     161        $default = includes_url('images/wpmini-blue.png');
     162        $wp_admin_bar->add_menu( array( 'id' => 'blog', 'title' => '<img class="avatar" src="' . $default . '" alt="' . esc_attr__( 'Current site avatar' ) . '" width="16" height="16" />',  'href' => home_url(), ) );
     163}
     164
     165/**
     166 * Site info menu
     167 *
     168 * @since 3.1.0
     169 */
     170function wp_admin_bar_bloginfo_menu() {
     171        global $wp_admin_bar;
     172
     173        /* Add the Site Info menu */
     174        $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '', ) );
     175
     176        // TODO: Move this js out into a seperate file?
     177        $wp_admin_bar->add_menu( array( 'parent' => 'bloginfo', 'title' => __( 'Get Shortlink' ), 'href' => '', 'meta' => array(
     178                        'onclick' => 'javascript:function wpcomshort() { var url=document.location;var links=document.getElementsByTagName(&#39;link&#39;);var found=0;for(var i = 0, l; l = links[i]; i++){if(l.getAttribute(&#39;rel&#39;)==&#39;shortlink&#39;) {found=l.getAttribute(&#39;href&#39;);break;}}if (!found) {for (var i = 0; l = document.links[i]; i++) {if (l.getAttribute(&#39;rel&#39;) == &#39;shortlink&#39;) {found = l.getAttribute(&#39;href&#39;);break;}}}if (found) {prompt(&#39;' . esc_js( __( 'URL:' ) ) . '&#39;, found);} else {alert(&#39;' . esc_js( __( 'No shortlink available for this page.' ) ) . '&#39;); } } wpcomshort(); return false;' ) ) );
     179}
     180
     181/**
     182 * Provide an edit link for posts and terms.
     183 *
     184 * @since 3.1.0
     185 */
     186function wp_admin_bar_edit_menu() {
     187        global $wp_admin_bar, $wp_query;
     188
     189        $current_object = $wp_query->get_queried_object();
     190
     191        if ( empty( $current_object ) )
    179192                return false;
    180193
    181         $default = includes_url('images/wpmini-blue.png');
    182 
    183         $wp_admin_bar->add_menu( array( 'id' => 'blog', 'title' => '<img class="avatar" src="' . $default . '" alt="' . __( 'Current site avatar' ) . '" width="16" height="16" />', 'href' => home_url() ) );
    184 }
    185 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_blog_separator', 40 );
    186 
    187 /**
    188  * Use the $wp_admin_bar global to add a menu for site info, accessable to all users.
    189  */
    190 function wp_admin_bar_bloginfo_menu() {
    191         global $wp_admin_bar;
    192 
    193         if ( !is_object( $wp_admin_bar ) )
    194                 return false;
    195 
    196         /* Add the Site Info menu */
    197         $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '' ) );
    198 
    199         $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(&#39;link&#39;);var found=0;for(var i = 0, l; l = links[i]; i++){if(l.getAttribute(&#39;rel&#39;)==&#39;shortlink&#39;) {found=l.getAttribute(&#39;href&#39;);break;}}if (!found) {for (var i = 0; l = document.links[i]; i++) {if (l.getAttribute(&#39;rel&#39;) == &#39;shortlink&#39;) {found = l.getAttribute(&#39;href&#39;);break;}}}if (found) {prompt(&#39;URL:&#39;, found);} else {alert(&#39;No shortlink available for this page&#39;); } } wpcomshort(); return false;' ) ) );
    200 }
    201 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_bloginfo_menu', 50 );
    202 
    203 /**
    204  * Use the $wp_admin_bar global to add the "Edit Post" menu when viewing a single post.
    205  */
    206 function wp_admin_bar_edit_menu() {
    207         global $post, $wp_admin_bar;
    208 
    209         if ( !is_object( $wp_admin_bar ) )
    210                 return false;
    211 
    212         if ( !is_single() && !is_page() )
    213                 return false;
    214 
    215         if ( !$post_type_object = get_post_type_object( $post->post_type ) )
    216                 return false;
    217 
    218         if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) )
    219                 return false;
    220 
    221         $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_post_link( $post->ID ) ) );
    222 }
    223 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 100 );
    224 
    225 /**
    226  * Load up the CSS needed to render the admin bar nice and pretty.
    227  */
    228 function wp_admin_bar_css() {
    229         global $pagenow, $wp_locale, $wp_admin_bar;
    230 
    231         if ( !is_object( $wp_admin_bar ) )
    232                 return false;
    233 
    234         if ( !is_user_logged_in() )
    235                 return;
    236 
    237         $nobump = false;
    238 
    239         /* Wish we could use wp_enqueue_style() here, but it will not let us pass GET params to the stylesheet correctly. */
     194        if ( ! empty( $current_object->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 ) ) {
     195                $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ),  'href' => get_edit_post_link( $current_object->ID ), ) );
     196        } elseif ( ! empty( $current_object->taxonomy ) &&  ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) ) {
     197                $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ), ) );
     198        }
     199}
     200
     201/**
     202 * Style and scripts for the admin bar.
     203 *
     204 * @since 3.1.0
     205 * @todo move js into a admin-bar js file
     206 *
     207 */
     208function wp_admin_bar_header() {
    240209        ?>
    241         <link rel="stylesheet" href="<?php echo includes_url('admin-bar/admin-bar-css.php') . '?t=' . get_current_theme() . '&amp;a=' . is_admin() . '&amp;p=' . is_ssl() . '&amp;sa=' . is_super_admin() . '&amp;td=' . $wp_locale->text_direction . '&amp;inc=' . includes_url() . '&amp;nobump=' . $nobump; ?>" type="text/css" />
    242         <!--[if IE 6]><style type="text/css">#wpadminbar, #wpadminbar .menupop a span, #wpadminbar .menupop ul li a:hover, #wpadminbar .myaccount a, .quicklinks a:hover,#wpadminbar .menupop:hover { background-image: none !important; } #wpadminbar .myaccount a { margin-left:0 !important; padding-left:12px !important;}</style><![endif]-->
    243         <style type="text/css" media="print">#wpadminbar { display:none; }</style><?php
    244 }
    245 
    246 /**
    247  * Load up the JS needed to allow the admin bar to function correctly.
    248  */
    249 function wp_admin_bar_js() {
    250         global $wp_admin_bar;
    251 
    252         if ( !is_object( $wp_admin_bar ) )
    253                 return false;
    254 
     210        <style type="text/css" media="print">#wpadminbar { display:none; }</style>
     211        <script type="text/javascript">
     212        /*      <![CDATA[ */
     213        (function(d, w) {
     214                var init = function() {
     215                        var b = d.getElementsByTagName('body')[0],
     216                        aB = d.getElementById('wpadminbar'),
     217                        s = d.getElementById('adminbar-search');
     218
     219                        if ( b && aB )
     220                                b.appendChild( aB );
     221
     222                        if ( s ) {
     223                                if ( '' == s.value )
     224                                        s.value = s.getAttribute('title');
     225
     226                                s.onblur = function() {
     227                                        this.value = '' == this.value ? this.getAttribute('title') : this.value;
     228                                }
     229                                s.onfocus = function() {
     230                                        this.value = this.getAttribute('title') == this.value ? '' : this.value;
     231                                }
     232                        }
     233                       
     234                        if ( w.location.hash )
     235                                w.scrollBy(0,-32);
     236                }
     237
     238                if ( w.addEventListener )
     239                        w.addEventListener('load', init, false);
     240                else if ( w.attachEvent )
     241                        w.attachEvent('onload', init);
     242
     243        })(document, window);
     244        /*      ]]> */
     245        </script>
     246        <?php
     247}
     248
     249// @TODO do we still need this in core?
     250function wp_admin_body_style() {
    255251        ?>
    256         <script type="text/javascript">
    257 /*      <![CDATA[ */
    258                 function pressthis(step) {if (step == 1) {if(navigator.userAgent.indexOf('Safari') >= 0) {Q=getSelection();}else {if(window.getSelection)Q=window.getSelection().toString();else if(document.selection)Q=document.selection.createRange().text;else Q=document.getSelection().toString();}} else {location.href='<?php echo $wp_admin_bar->user->account_domain; ?>wp-admin/post-new.php?text='+encodeURIComponent(Q.toString())+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);}}
    259                 function toggle_query_list() { var querylist = document.getElementById( 'querylist' );if( querylist.style.display == 'block' ) {querylist.style.display='none';} else {querylist.style.display='block';}}
    260 
    261                 jQuery( function() {
    262                         (function(jq){jq.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=jq.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){jq(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;jq(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{jq(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
    263                         ;(function(jq){jq.fn.superfish=function(op){var sf=jq.fn.superfish,c=sf.c,jqarrow=jq([''].join('')),over=function(){var jqjq=jq(this),menu=getMenu(jqjq);clearTimeout(menu.sfTimer);jqjq.showSuperfishUl().siblings().hideSuperfishUl();},out=function(){var jqjq=jq(this),menu=getMenu(jqjq),o=sf.op;clearTimeout(menu.sfTimer);menu.sfTimer=setTimeout(function(){o.retainPath=(jq.inArray(jqjq[0],o.jqpath)>-1);jqjq.hideSuperfishUl();if(o.jqpath.length&&jqjq.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.jqpath);}},o.delay);},getMenu=function(jqmenu){var menu=jqmenu.parents(['ul.',c.menuClass,':first'].join(''))[0];sf.op=sf.o[menu.serial];return menu;},addArrow=function(jqa){jqa.addClass(c.anchorClass).append(jqarrow.clone());};return this.each(function(){var s=this.serial=sf.o.length;var o=jq.extend({},sf.defaults,op);o.jqpath=jq('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){jq(this).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass);});sf.o[s]=sf.op=o;jq('li:has(ul)',this)[(jq.fn.hoverIntent&&!o.disableHI)?'hoverIntent':'hover'](over,out).each(function(){if(o.autoArrows)addArrow(jq('>a:first-child',this));}).not('.'+c.bcClass).hideSuperfishUl();var jqa=jq('a',this);jqa.each(function(i){var jqli=jqa.eq(i).parents('li');jqa.eq(i).focus(function(){over.call(jqli);}).blur(function(){out.call(jqli);});});o.onInit.call(this);}).each(function(){var menuClasses=[c.menuClass];if(sf.op.dropShadows&&!(jq.browser.msie&&jq.browser.version<7))menuClasses.push(c.shadowClass);jq(this).addClass(menuClasses.join(' '));});};var sf=jq.fn.superfish;sf.o=[];sf.op={};sf.IE7fix=function(){var o=sf.op;if(jq.browser.msie&&jq.browser.version>6&&o.dropShadows&&o.animation.opacity!=undefined) this.toggleClass(sf.c.shadowClass+'-off');};sf.c={bcClass:'sf-breadcrumb',menuClass:'sf-js-enabled',anchorClass:'sf-with-ul',arrowClass:'sf-sub-indicator',shadowClass:'sf-shadow'};sf.defaults={hoverClass:'sfHover',pathClass:'overideThisToUse',pathLevels:1,delay:600,animation:{opacity:'show'},speed:100,autoArrows:false,dropShadows:false,disableHI:false,onInit:function(){},onBeforeShow:function(){},onShow:function(){},onHide:function(){}};jq.fn.extend({hideSuperfishUl:function(){var o=sf.op,not=(o.retainPath===true)?o.jqpath:'';o.retainPath=false;var jqul=jq(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility','hidden');o.onHide.call(jqul);return this;},showSuperfishUl:function(){var o=sf.op,sh=sf.c.shadowClass+'-off',jqul=this.addClass(o.hoverClass).find('>ul:hidden').css('visibility','visible');sf.IE7fix.call(jqul);o.onBeforeShow.call(jqul);jqul.animate(o.animation,o.speed,function(){sf.IE7fix.call(jqul);o.onShow.call(jqul);});return this;}});})(jQuery);
    264 
    265                         <?php if ( is_single() ) : ?>
    266                         if ( jQuery(this).width() < 1100 ) jQuery("#adminbarsearch").hide();
    267                         <?php endif; ?>
    268                                
    269                         jQuery( '#wpadminbar li.ab-my-account, #wpadminbar li.ab-bloginfo' ).mouseover( function() {
    270                                 if ( jQuery(this).hasClass( 'ab-my-account' ) ) jQuery('#wpadminbar li.ab-me > a').addClass('hover');
    271                                 if ( jQuery(this).hasClass( 'ab-bloginfo' ) ) jQuery('#wpadminbar li.ab-blog > a').addClass('hover');
    272                         });
    273                        
    274                         jQuery( '#wpadminbar li.ab-my-account, #wpadminbar li.ab-bloginfo' ).mouseout( function() {
    275                                 if ( jQuery(this).hasClass( 'ab-my-account' ) ) jQuery('#wpadminbar li.ab-me > a').removeClass('hover');
    276                                 if ( jQuery(this).hasClass( 'ab-bloginfo' ) ) jQuery('#wpadminbar li.ab-blog > a').removeClass('hover');
    277                         });
    278 
    279                         <?php if ( is_single() ) : ?>
    280                         jQuery(window).resize( function() {
    281                                 if ( jQuery(this).width() < 1100 )
    282                                         jQuery("#adminbarsearch").hide();
    283                                
    284                                 if ( jQuery(this).width() > 1100 )
    285                                         jQuery("#adminbarsearch").show();
    286                         });
    287                         <?php endif; ?>
    288                        
    289                         jQuery( '#wpadminbar ul ul li a' ).mouseover( function() {
    290                                 var root = jQuery(this).parents('div.quicklinks ul > li');
    291                                 var par = jQuery(this).parent();
    292                                 var children = par.children('ul');
    293                                 if ( root.hasClass('ab-sadmin') )
    294                                         jQuery(children[0]).css('<?php echo( is_rtl() ? 'left' : 'right' ); ?>',par.parents('ul').width() - 1 +'px' );
    295                                 else
    296                                         jQuery(children[0]).css('<?php echo( is_rtl() ? 'right' : 'left' ); ?>',par.parents('ul').width() +'px' );
    297                                
    298                                 jQuery(children[0]).css('top', '0' );
    299                         });
    300                        
    301                         <?php if ( is_user_logged_in() ) : // Hash links scroll 32px back so admin bar doesn't cover. ?>
    302                                 if ( window.location.hash ) window.scrollBy(0,-32);
    303                         <?php endif; ?>
     252        <style type="text/css">
     253                <?php
    304254               
    305                 });
    306 
    307                 jQuery( function() {
    308                         jQuery('#wpadminbar').appendTo('body');
    309                         jQuery("#wpadminbar ul").superfish();
    310                 });
    311 
    312                 /*      ]]> */
    313         </script><?php
    314 }
    315 add_action( 'wp_footer', 'wp_admin_bar_js' );
    316 add_action( 'admin_footer', 'wp_admin_bar_js' );
    317 
    318 /**
    319  * Return a rendered admin bar via AJAX for use on pages that do not run inside the
    320  * WP environment. Used on bbPress forum pages to show the admin bar.
    321  */
    322 function wp_admin_bar_ajax_render() {
    323         global $wp_admin_bar;
    324 
    325         wp_admin_bar_js();
    326         wp_admin_bar_css();
    327         wp_admin_bar_render();
    328         die;
    329 }
    330 add_action( 'wp_ajax_admin_bar_render', 'wp_admin_bar_ajax_render' );
    331 
    332 function is_admin_bar() {
    333         return ( 0 === strpos($_SERVER['REQUEST_URI'], '/js/admin-bar') );
    334 }
    335 
    336 function wp_admin_bar_lang($locale) {
    337         if ( is_admin_bar() )
    338                 $locale = get_locale();
    339         return $locale;
    340 }
    341 add_filter('locale', 'wp_admin_bar_lang');
    342 
     255                if (
     256                        ( empty( $_GET['nobump'] ) || is_admin() ) &&
     257                        ! strpos( $_SERVER['REQUEST_URI'], 'media-upload.php' )
     258                ) :
     259                        ?>
     260                        body { padding-top: 28px !important; }
     261                        <?php
     262                endif;
     263
     264                if ( in_array( get_current_theme(), array('H3', 'H4', 'The Journalist v1.9') ) ) :
     265                        ?>
     266                        body { padding-top: 28px; background-position: 0px 28px; }
     267                        <?php
     268                endif;
     269
     270                ?>
     271        </style>
     272        <?php
     273}
     274
     275add_action('wp_head', 'wp_admin_body_style');
     276add_action('admin_head', 'wp_admin_body_style');
     277
     278/**
     279 * Determine whether the admin bar should be showing.
     280 *
     281 * @since 3.1.0
     282 *
     283 * @return bool Whether the admin bar should be showing.
     284 */
     285function is_admin_bar_showing() {
     286        global $show_admin_bar;
     287
     288        if ( ! isset( $show_admin_bar ) || null === $show_admin_bar ) {
     289                $show_admin_bar = true;
     290
     291                if ( defined('WP_SHOW_ADMIN_BAR') )
     292                        $show_admin_bar = (bool) WP_SHOW_ADMIN_BAR;
     293
     294                if ( ! is_user_logged_in() )
     295                        $show_admin_bar = false;
     296        }
     297
     298        $show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar );
     299
     300        return $show_admin_bar;
     301}
    343302?>
  • trunk/wp-includes/admin-bar/admin-bar-class.php

    r15915 r16038  
    11<?php
    22class WP_Admin_Bar {
    3         var $user;
     3        var $changed_locale = false;
    44        var $menu;
    55        var $need_to_change_locale = false;
    6         var $changed_locale = false;
    7 
    8         function WP_Admin_Bar() {
    9                 global $current_user, $blog_id;
     6        var $proto = 'http://';
     7        var $user;
     8
     9        function initialize() {
     10                global $blog_id;
     11
     12                /* Only load super admin menu code if the logged in user is a super admin */
     13                if ( is_super_admin() ) {
     14                        require( ABSPATH . WPINC . '/admin-bar/admin-bar-debug.php' );
     15                        require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' );
     16                }
     17               
     18                /* Set the protocol used throughout this code */
     19                if ( is_ssl() )
     20                        $this->proto = 'https://';
    1021
    1122                $this->user = new stdClass;
    … …  
    1324
    1425                /* Populate settings we need for the menu based on the current user. */
    15                 $this->user->blogs = get_blogs_of_user( $current_user->id );
     26                $this->user->blogs = get_blogs_of_user( get_current_user_id() );
    1627                if ( is_multisite() ) {
    17                         $this->user->active_blog = get_active_blog_for_user( $current_user->id );
     28                        $this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
    1829                        $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
    1930                        $this->user->account_domain = $this->user->domain;
    … …  
    2435                }
    2536                $this->user->locale = get_locale();
     37
     38                add_action( 'wp_head', 'wp_admin_bar_header' );
     39                add_action( 'admin_head', 'wp_admin_bar_header' );
     40
     41                wp_enqueue_style( 'admin-bar' );
     42
     43                if ( is_super_admin() ) {
     44                        wp_enqueue_style( 'super-admin-bar' );
     45                }
     46               
     47                do_action( 'admin_bar_init' );
    2648        }
    2749
    … …  
    4567                        $id = esc_attr( sanitize_title( trim( $title ) ) );
    4668
    47                 if ( !empty( $parent ) ) {
     69                if ( ! empty( $parent ) ) {
    4870                        /* Add the menu to the parent item */
    49                         $child = array(
    50                                 'id' => $id,
    51                                 'title' => $title,
    52                                 'href' => $href
    53                         );
    54 
    55                         if ( !empty( $meta ) )
     71                        $child = array( 'id' => $id, 'title' => $title, 'href' => $href );
     72
     73                        if ( ! empty( $meta ) )
    5674                                $child['meta'] = $meta;
    5775
    … …  
    5977                } else {
    6078                        /* Add the menu item */
    61                         $this->menu->{$id} = array(
    62                                 'title' => $title,
    63                                 'href' => $href
    64                         );
    65 
    66                         if ( !empty( $meta ) )
     79                        $this->menu->{$id} = array( 'title' => $title, 'href' => $href );
     80
     81                        if ( ! empty( $meta ) )
    6782                                $this->menu->{$id}['meta'] = $meta;
    6883                }
    … …  
    7489       
    7590        function render() {
    76         ?>
     91                ?>
    7792                <div id="wpadminbar" class="snap_nopreview no-grav">
    7893                        <div class="quicklinks">
    … …  
    86101                        <div id="adminbarsearch-wrap">
    87102                                <form action="<?php echo home_url(); ?>" method="get" id="adminbarsearch">
    88                                         <input class="adminbar-input" name="s" id="s" type="text" value="<?php esc_attr_e( 'Search' ); ?>" maxlength="150" onfocus="this.value=(this.value=='<?php esc_attr_e( 'Search' ); ?>') ? '' : this.value;" onblur="this.value=(this.value=='') ? '<?php esc_attr_e( 'Search' ); ?>' : this.value;" /> <button type="submit" class="adminbar-button"><span><?php _e('Search'); ?></span></button>
     103                                        <input class="adminbar-input" name="s" id="adminbar-search" type="text" title="<?php esc_attr_e( 'Search' ); ?>" value="" maxlength="150" />
     104                                        <button type="submit" class="adminbar-button"><span><?php _e('Search'); ?></span></button>
    89105                                </form>
    90106                        </div>
    … …  
    98114        /* Helpers */
    99115        function recursive_render( $id, &$menu_item ) { ?>
    100                 <?php $menuclass = ( !empty( $menu_item['children'] ) ) ? 'menupop ' : ''; ?>
    101 
    102                 <li class="<?php echo $menuclass . "ab-$id" ?><?php if ( !empty( $menu_item['meta']['class'] ) ) : ?><?php echo ' ' . $menu_item['meta']['class'] ?><?php endif; ?>">
    103                         <a href="<?php echo strip_tags( $menu_item['href'] ) ?>"<?php if ( !empty( $menu_item['meta']['onclick'] ) ) :?> onclick="<?php echo $menu_item['meta']['onclick'] ?>"<?php endif; ?><?php if ( !empty( $menu_item['meta']['target'] ) ) :?> target="<?php echo $menu_item['meta']['target'] ?>"<?php endif; ?>><?php if ( !empty( $menuclass ) ) : ?><span><?php endif; ?><?php echo $menu_item['title'] ?><?php if ( !empty( $menuclass ) ) : ?></span><?php endif; ?></a>
    104 
    105                         <?php if ( !empty( $menu_item['children'] ) ) : ?>
     116                <?php $menuclass = ( ! empty( $menu_item['children'] ) ) ? 'menupop ' : ''; ?>
     117
     118                <li class="<?php echo $menuclass . "ab-$id" ?><?php
     119                        if ( ! empty( $menu_item['meta']['class'] ) ) :
     120                                echo ' ' . $menu_item['meta']['class'];
     121                        endif;
     122                ?>">
     123                        <a href="<?php echo strip_tags( $menu_item['href'] ) ?>"<?php
     124                                if ( ! empty( $menu_item['meta']['onclick'] ) ) :
     125                                        ?> onclick="<?php echo $menu_item['meta']['onclick']; ?>"<?php
     126                                endif;
     127                        if ( ! empty( $menu_item['meta']['target'] ) ) :
     128                                ?> target="<?php echo $menu_item['meta']['target']; ?>"<?php
     129                        endif;
     130                       
     131                        ?>><?php
     132                       
     133                        if ( ! empty( $menuclass ) ) :
     134                                ?><span><?php
     135                        endif;
     136                       
     137                        echo $menu_item['title'];
     138                       
     139                        if ( ! empty( $menuclass ) ) :
     140                                ?></span><?php
     141                        endif;
     142                       
     143                        ?></a>
     144
     145                        <?php if ( ! empty( $menu_item['children'] ) ) : ?>
    106146                        <ul>
    107147                                <?php foreach ( $menu_item['children'] as $child_id => $child_menu_item ) : ?>
    … …  
    111151                        <?php endif; ?>
    112152
    113                         <?php if ( !empty( $menu_item['meta']['html'] ) ) : ?>
     153                        <?php if ( ! empty( $menu_item['meta']['html'] ) ) : ?>
    114154                                <?php echo $menu_item['meta']['html']; ?>
    115155                        <?php endif; ?>
    … …  
    125165                        }
    126166
    127                         if ( !empty( $menu->{$id}['children'] ) )
     167                        if ( ! empty( $menu->{$id}['children'] ) )
    128168                                $this->add_node( $parent_id, $menu->{$id}['children'], $child );
    129169                }
     170               
    130171                $child = null;
    131172
    132173                return false;
     174        }
     175
     176        function add_menus() {
     177                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_me_separator', 10 );
     178                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_account_menu', 20 );
     179                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_blogs_menu', 30 );
     180                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_blog_separator', 40 );
     181                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_bloginfo_menu', 50 );
     182                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 100 );
     183               
     184                if ( is_multisite() && is_super_admin() && function_exists('wp_admin_bar_superadmin_settings_menu') )
     185                        add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_superadmin_settings_menu', 1000 );
     186
     187                do_action('add_admin_bar_menus');
    133188        }
    134189
    … …  
    140195                        }
    141196
    142                         if ( !empty( $menu->{$menu_item_id}['children'] ) )
     197                        if ( ! empty( $menu->{$menu_item_id}['children'] ) )
    143198                                $this->remove_node( $id, $menu->{$menu_item_id}['children'] );
    144199                }
    … …  
    149204        function load_user_locale_translations() {
    150205                $this->need_to_change_locale = ( get_locale() != $this->user->locale );
    151                 if ( !$this->need_to_change_locale ) return;
     206                if ( ! $this->need_to_change_locale )
     207                        return;
    152208                $this->previous_translations = get_translations_for_domain( 'default' );
    153209                $this->adminbar_locale_filter = lambda( '$_', '$GLOBALS["wp_admin_bar"]->user->locale;' );
    … …  
    160216        function unload_user_locale_translations() {
    161217                global $l10n;
    162                 if ( !$this->changed_locale ) return;
     218                if ( ! $this->changed_locale )
     219                        return;
    163220                remove_filter( 'locale', $this->adminbar_locale_filter );
    164221                $l10n['default'] = &$this->previous_translations;
    165 
    166222        }
    167223}
  • trunk/wp-includes/admin-bar/admin-bar-debug.php

    r15671 r16038  
    1212        global $wp_admin_bar, $wpdb;
    1313
    14         if ( !is_super_admin() || !apply_filters('wp_admin_bar_enable_debug_menu', false) )
     14        if ( ! is_super_admin() || ! apply_filters('wp_admin_bar_enable_debug_menu', false ) )
    1515                return;
    1616
    … …  
    4545        <script type="text/javascript">
    4646        /* <![CDATA[ */
     47        var toggle_query_list = function() {
     48                var querylist = document.getElementById( 'querylist' );
     49                if( querylist && querylist.style.display == 'block' ) {
     50                        querylist.style.display='none';
     51                } else {
     52                        querylist.style.display='block';
     53                }
     54        }
     55
    4756        var clickDebugLink = function( targetsGroupId, obj) {
    4857                var sectionDivs = document.getElementById( targetsGroupId ).childNodes;
  • trunk/wp-includes/admin-bar/admin-bar-superadmin.php

    r15769 r16038  
    11<?php
    2 /**
    3  * Use the $wp_admin_bar global to add a menu for site admins and administrator controls.
    4  */
    5 function wp_admin_bar_superadmin_menus() {
    6         global $wp_admin_bar, $wpdb;
    7 
    8         if ( !is_object( $wp_admin_bar ) || !is_super_admin() )
    9                 return false;
    10 
    11         /* Add the "Super Admin" settings sub menu */
    12         if ( is_multisite() )
    13                 wp_admin_bar_superadmin_settings_menu();
    14 }
    15 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_superadmin_menus', 1000 );
    162
    173/**
    … …  
    228        global $wp_admin_bar, $current_blog, $current_user;
    239
    24         if ( !is_object( $wp_admin_bar ) || !is_super_admin() )
    25                 return false;
    26 
    2710        /* Add the main superadmin menu item */
    28         $wp_admin_bar->add_menu( array( 'id' => 'superadmin', 'title' => '&mu;', 'href' => '', 'meta' => array( 'class' => 'ab-sadmin' ) ) );
     11        $wp_admin_bar->add_menu( array(  'id' => 'superadmin', 'title' => '&mu;', 'href' => '', 'meta' => array( 'class' => 'ab-sadmin' ), ) );
    2912
    3013        wp_admin_bar_build_snackmenu();
    … …  
    3215        /* Get the settings we need for the current site */
    3316        $matureaction = $current_blog->mature ? 'unmatureblog' : 'matureblog';
    34         $maturetext = $current_blog->mature ? esc_attr__('Unmark as mature') : esc_attr__('Mark as mature');
    35         $suspendtext = $current_blog->spam ? esc_attr('Unsuspend site') : esc_attr('Suspend site');
     17        $maturetext_confirm = $current_blog->mature ?
     18                sprintf(
     19                        esc_attr__( 'Are you sure you want to unmark %s as mature?' ),
     20                        $current_blog->domain
     21                ) :
     22                sprintf(
     23                        esc_attr__( 'Are you sure you want to mark %s as mature?' ),
     24                        $current_blog->domain
     25                );
     26
    3627        $suspendaction = $current_blog->spam ? 'unspamblog' : 'spamblog';
    37         $mature_url = network_admin_url( "edit.php?action=confirm&amp;action2={$matureaction}&amp;id={$current_blog->blog_id}&amp;msg=" . urlencode( 'Are you sure you want to ' . strtolower( $maturetext ) . " {$current_blog->domain} as mature?" ) );
    38         $suspend_url = network_admin_url( "edit.php?action=confirm&amp;action2={$suspendaction}&amp;id={$current_blog->blog_id}&amp;msg=" . urlencode( 'Are you sure you want to ' . strtolower( $suspendtext ) . " {$current_blog->domain} ?" ) );
     28        $suspendtext_confirm = $current_blog->spam ?
     29                sprintf(
     30                        esc_attr__( 'Are you sure you want to unsuspend site %s?' ),
     31                        $current_blog->domain
     32                ) :
     33                sprintf(
     34                        esc_attr__( 'Are you sure you want to suspend site %s?' ),
     35                        $current_blog->domain
     36                );
     37               
     38        $mature_url = network_admin_url( "edit.php?action=confirm&amp;action2={$matureaction}&amp;id={$current_blog->blog_id}&amp;msg=" . urlencode( $maturetext_confirm ) );
     39        $suspend_url = network_admin_url( "edit.php?action=confirm&amp;action2={$suspendaction}&amp;id={$current_blog->blog_id}&amp;msg=" . urlencode( $suspendtext_confirm ) );
    3940
    4041        /* Add the submenu items to the Super Admin menu */
    41         $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Site Dashboard' ), 'href' => admin_url(), 'position' => 10 ) );
    42         $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Site Options' ),  'href' => network_admin_url( "sites.php?action=blogs&amp;searchaction=id&amp;s={$current_blog->blog_id}" ), 'position' => 30 ) );
    43         $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => "$maturetext", 'href' => $mature_url, 'position' => 50 ) );
    44         $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => "$suspendtext", 'href' => $suspend_url, 'position' => 80 ) );
     42        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Site Dashboard' ), 'href' => admin_url(), 'position' => 10, ) );
     43        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Site Options' ), 'href' => network_admin_url( "sites.php?action=blogs&amp;searchaction=id&amp;s={$current_blog->blog_id}" ), 'position' => 30, ) );
     44        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => ( $current_blog->mature ? __('Unmark as mature') : __('Mark as mature') ), 'href' => $mature_url, 'position' => 50, ) );
     45        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => ( $current_blog->spam ? __('Unsuspend site') : __('Suspend site') ), 'href' => $suspend_url, 'position' => 80, ) );
    4546}
    4647
    4748function wp_admin_bar_build_snackmenu() {
    4849        global $wp_admin_bar, $menu, $submenu, $pagenow;
    49 
    50         if ( !is_object( $wp_admin_bar ) || !is_super_admin() )
    51                 return false;
    5250
    5351        // Hide moderation count, filter removed at the bottom of this function
    … …  
    6159
    6260        /* Add the snack menu submenu to the superadmin menu */
    63         $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => 'Snack Menu', 'href' => '/wp-admin/' ) );
     61        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Snack Menu' ), 'href' => '/wp-admin/',) );
    6462
    6563        /* Loop through the submenus and add them */
    … …  
    7573                        if ( false !== $pos = strpos($menu_file, '?') )
    7674                                $menu_file = substr($menu_file, 0, $pos);
    77                         if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) {
     75
     76                        if (
     77                                (
     78                                        'index.php' != $submenu[$item[2]][0][2] &&
     79                                        file_exists( WP_PLUGIN_DIR . "/$menu_file" )
     80                                ) ||
     81                                ! empty( $menu_hook )
     82                        ) {
     83                               
    7884                                $admin_is_parent = true;
    79                                 $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$submenu[$item[2]][0][2]}") ) );
     85                                $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$submenu[$item[2]][0][2]}"), ) );
     86
    8087                        } else {
    81                                 $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$submenu[$item[2]][0][2]}") ) );
     88                                $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$submenu[$item[2]][0][2]}"), ) );
    8289                        }
    8390                } else if ( current_user_can($item[1]) ) {
    … …  
    8794                        if ( false !== $pos = strpos($menu_file, '?') )
    8895                                $menu_file = substr($menu_file, 0, $pos);
    89                         if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) {
     96
     97                        if (
     98                                (
     99                                        'index.php' != $item[2] &&
     100                                        file_exists( WP_PLUGIN_DIR . "/$menu_file" )
     101                                ) ||
     102                                ! empty($menu_hook)
     103                        ) {
     104
    90105                                $admin_is_parent = true;
    91                                 $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$item[2]}") ) );
     106                                $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$item[2]}"), ) );
    92107                        } else {
    93                                 $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$item[2]}") ) );
     108                                $wp_admin_bar->add_menu( array(  'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$item[2]}"), ) );
    94109                        }
    95110                }
    96111
    97                 if ( !empty($submenu[$item[2]]) ) {
     112                if ( ! empty($submenu[$item[2]]) ) {
    98113                        $first = true;
    99114                        $unique_submenu = array();
    … …  
    114129                                $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]);
    115130                                $sub_file = $sub_item[2];
     131
    116132                                if ( false !== $pos = strpos($sub_file, '?') )
    117133                                        $sub_file = substr($sub_file, 0, $pos);
    118134                               
    119                                 if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) {
     135                                if (
     136                                        (
     137                                                'index.php' != $sub_item[2] &&
     138                                                file_exists( WP_PLUGIN_DIR . "/$sub_file" )
     139                                        ) ||
     140                                        ! empty($menu_hook)
     141                                ) {
    120142                                        // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
    121                                
    122                                         $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($menu_file);
    123                                         if ( $parent_exists )
    124                                                 $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$item[2]}?page={$sub_item[2]}") ) );
    125                                         elseif ( 'admin.php' == $pagenow || !$parent_exists )
    126                                                 $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("admin.php?page={$sub_item[2]}") ) );
    127                                         else
    128                                                 $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$item[2]}?page={$sub_item[2]}") ) );
     143                                        if (
     144                                                (
     145                                                        ! $admin_is_parent &&
     146                                                        file_exists(WP_PLUGIN_DIR . "/$menu_file") &&
     147                                                        ! is_dir(WP_PLUGIN_DIR . "/{$item[2]}")
     148                                                ) ||
     149                                                file_exists( $menu_file )
     150                                        ) {
     151                                                $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$item[2]}?page={$sub_item[2]}"), ) );
     152                                        } else {
     153                                                $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("admin.php?page={$sub_item[2]}"), ) );
     154                                        }
    129155                                } else {
    130                                         $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$sub_item[2]}") ) );
     156                                        $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$sub_item[2]}"), ) );
    131157                                }
    132158                        }
  • trunk/wp-includes/script-loader.php

    r16022 r16038  
    457457        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
    458458
    459         $rtl_styles = array( 'wp-admin', 'global', 'colors', 'colors-fresh', 'colors-classic', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'nav-menu', 'farbtastic' );
     459        $rtl_styles = array( 'wp-admin', 'global', 'colors', 'colors-fresh', 'colors-classic', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'nav-menu', 'farbtastic', 'admin-bar' );
    460460        // Any rtl stylesheets that don't have a .dev version for ltr
    461461        $no_suffix = array( 'farbtastic' );
    … …  
    492492        $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
    493493        $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100907' );
     494       
     495        // Admin bar
     496        $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101028' );
     497        $styles->add( 'super-admin-bar', "/wp-includes/css/super-admin-bar$suffix.css", array(), '20101028' );
    494498
    495499        foreach ( $rtl_styles as $rtl_style ) {
Note: See TracChangeset for help on using the changeset viewer.