WordPress.org

Make WordPress Core

Ticket #14772: 14772.diff

File 14772.diff, 64.3 KB (added by ryan, 3 years ago)

First pass

  • wp-includes/admin-bar.php

     
     1<?php 
     2/** 
     3 * Admin Bar 
     4 * 
     5 * This code handles the building and rendering of the press bar. 
     6 */ 
     7  
     8/** 
     9 * Instantiate the admin bar class and set it up as a global for access elsewhere. 
     10 */ 
     11function wp_admin_bar_init() { 
     12        global $current_user, $pagenow, $wp_admin_bar; 
     13 
     14        /* Set the protocol constant used throughout this code */ 
     15        if ( !defined( 'PROTO' ) ) 
     16                if ( is_ssl() ) define( 'PROTO', 'https://' ); else define( 'PROTO', 'http://' ); 
     17 
     18        /* Don't load the admin bar if the user is not logged in, or we are using press this */ 
     19        if ( !is_user_logged_in() || 'press-this.php' ==  $pagenow ) 
     20                return false; 
     21 
     22        /* Set up the settings we need to render menu items */ 
     23        if ( !is_object( $current_user ) ) 
     24                $current_user = wp_get_current_user(); 
     25 
     26        /* Enqueue the JS files for the admin bar. */ 
     27        if ( is_user_logged_in() ) 
     28                wp_enqueue_script( 'jquery', false, false, false, true ); 
     29         
     30        /* Load the admin bar class code ready for instantiation */ 
     31        require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' ); 
     32 
     33        /* Only load super admin menu code if the logged in user is a super admin */ 
     34        if ( is_super_admin() ) { 
     35                require( ABSPATH . WPINC . '/admin-bar/admin-bar-debug.php' ); 
     36                if ( is_multisite() ) 
     37                        require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' ); 
     38        } 
     39 
     40        /* Initialize the admin bar */ 
     41        $wp_admin_bar = new wp_admin_bar(); 
     42} 
     43add_action( 'init', 'wp_admin_bar_init' ); 
     44 
     45/** 
     46 * Render the admin bar to the page based on the $wp_admin_bar->menu member var. 
     47 * This is called very late on the footer actions so that it will render after anything else being 
     48 * added to the footer. 
     49 * 
     50 * It includes the action "wp_before_admin_bar_render" which should be used to hook in and 
     51 * add new menus to the admin bar. That way you can be sure that you are adding at most optimal point, 
     52 * right before the admin bar is rendered. This also gives you access to the $post global, among others. 
     53 */ 
     54function wp_admin_bar_render() { 
     55        global $wp_admin_bar; 
     56 
     57        if ( !is_object( $wp_admin_bar ) ) 
     58                return false; 
     59                 
     60        $wp_admin_bar->load_user_locale_translations(); 
     61 
     62        do_action( 'wp_before_admin_bar_render' ); 
     63 
     64        $wp_admin_bar->render(); 
     65 
     66        do_action( 'wp_after_admin_bar_render' ); 
     67         
     68        $wp_admin_bar->unload_user_locale_translations(); 
     69} 
     70add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); 
     71add_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); 
     72 
     73/** 
     74 * Show the logged in user's gravatar as a separator. 
     75 */ 
     76function wp_admin_bar_me_separator() { 
     77        global $wp_admin_bar, $current_user; 
     78 
     79        if ( !is_object( $wp_admin_bar ) ) 
     80                return false; 
     81 
     82        $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' ) ); 
     83} 
     84add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_me_separator', 10 ); 
     85 
     86/** 
     87 * Use the $wp_admin_bar global to add the "My Account" menu and all submenus. 
     88 */ 
     89function wp_admin_bar_my_account_menu() { 
     90        global $wp_admin_bar, $current_user; 
     91 
     92        if ( !is_object( $wp_admin_bar ) ) 
     93                return false; 
     94 
     95        /* Add the 'My Account' menu */ 
     96        $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __( 'My Account' ), 'href' => admin_url('profile.php') ) ); 
     97 
     98        /* Add the "My Account" sub menus */ 
     99        $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Edit My Profile' ), 'href' => admin_url('profile.php') ) ); 
     100        $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Global Dashboard' ), 'href' => admin_url() ) ); 
     101        $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) ); 
     102} 
     103add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_account_menu', 20 ); 
     104 
     105/** 
     106 * Use the $wp_admin_bar global to add the "My Blogs/[Blog Name]" menu and all submenus. 
     107 */ 
     108function wp_admin_bar_my_blogs_menu() { 
     109        global $wpdb, $wp_admin_bar; 
     110 
     111        if ( !is_object( $wp_admin_bar ) ) 
     112                return false; 
     113 
     114        /* Remove the global dashboard */ 
     115        if ( is_multisite() ) { 
     116                foreach ( (array) $wp_admin_bar->user->blogs as $key => $blog ) { 
     117                        if ( get_dashboard_blog() == $blog->domain ) 
     118                                unset( $wp_admin_bar->user->blogs[$key] ); 
     119                } 
     120        } 
     121 
     122        /* Add the 'My Dashboards' menu if the user has more than one blog. */ 
     123        if ( count( $wp_admin_bar->user->blogs ) > 1 ) { 
     124                $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Blogs' ), 'href' => $wp_admin_bar->user->account_domain ) ); 
     125 
     126                $default = includes_url('images/wpmini-blue.png'); 
     127 
     128                $counter = 2; 
     129                foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { 
     130                        $blogdomain = preg_replace( '!^https?://!', '', $blog->siteurl ); 
     131                        // @todo Replace with some favicon lookup. 
     132                        //$blavatar = '<img src="' . esc_url( blavatar_url( blavatar_domain( $blog->siteurl ), 'img', 16, $default ) ) . '" alt="Blavatar" width="16" height="16" />'; 
     133                        $blavatar = '<img src="' . esc_url($default) . '" alt="Blavatar" width="16" height="16" />';; 
     134 
     135                        $marker = ''; 
     136                        if ( strlen($blog->blogname) > 35 ) 
     137                                $marker = '...'; 
     138 
     139                        if ( empty( $blog->blogname ) ) 
     140                                $blogname = $blog->domain; 
     141                        else 
     142                                $blogname = substr( $blog->blogname, 0, 35 ) . $marker; 
     143 
     144                        if ( !isset( $blog->visible ) || $blog->visible === true ) { 
     145                                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/' ) ); 
     146                                $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/' ) ); 
     147                                $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' ) ); 
     148                                // @todo, stats plugins should add this: 
     149                                //$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-s', 'title' => __( 'Blog Stats' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/index.php?page=stats' ) ); 
     150                                $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' ) ); 
     151                                $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Read Blog' ), 'href' => constant( 'PROTO' ) . $blogdomain ) ); 
     152                        } 
     153                        $counter++; 
     154                } 
     155 
     156                /* Add the "Manage Blogs" menu item */ 
     157                // @todo, use dashboard blog. 
     158                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'manage-blogs', 'title' => __( 'Manage Blogs' ), admin_url('my-sites.php') ) ); 
     159 
     160        /* Add the 'My Dashboard' menu if the user only has one blog. */ 
     161        } else { 
     162                $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Blog' ), 'href' => $wp_admin_bar->user->account_domain ) ); 
     163 
     164                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-d', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); 
     165                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-n', 'title' => __( 'New Post' ), 'href' => admin_url('post-new.php') ) ); 
     166                // @todo Stats plugins should add this. 
     167                //$wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-s', 'title' => __( 'Blog Stats' ), 'href' => admin_ur;('index.php?page=stats') ) ); 
     168                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-c', 'title' => __( 'Manage Comments' ), 'href' => admin_url('edit-comments.php') ) ); 
     169                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-v', 'title' => __( 'Read Blog' ), 'href' => home_url() ) ); 
     170        } 
     171} 
     172add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_blogs_menu', 30 ); 
     173 
     174/** 
     175 * Show the blavatar of the current blog as a separator. 
     176 */ 
     177function wp_admin_bar_blog_separator() { 
     178        global $wp_admin_bar, $current_user, $current_blog; 
     179 
     180        if ( !is_object( $wp_admin_bar ) ) 
     181                return false; 
     182 
     183        $default = includes_url('images/wpmini-blue.png'); 
     184 
     185        $wp_admin_bar->add_menu( array( 'id' => 'blog', 'title' => '<img class="avatar" src="' . $default . '" alt="' . __( 'Current blog avatar' ) . '" width="16" height="16" />', 'href' => home_url() ) ); 
     186} 
     187add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_blog_separator', 40 ); 
     188 
     189/** 
     190 * Use the $wp_admin_bar global to add a menu for blog info, accessable to all users. 
     191 */ 
     192function wp_admin_bar_bloginfo_menu() { 
     193        global $wp_admin_bar; 
     194 
     195        if ( !is_object( $wp_admin_bar ) ) 
     196                return false; 
     197 
     198        /* Add the Blog Info menu */ 
     199        $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Blog Info' ), 'href' => '' ) ); 
     200 
     201        $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;); } return false; } wpcomshort();' ) ) ); 
     202} 
     203add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_bloginfo_menu', 50 ); 
     204 
     205/** 
     206 * Use the $wp_admin_bar global to add the "Edit Post" menu when viewing a single post. 
     207 */ 
     208function wp_admin_bar_edit_menu() { 
     209        global $post, $wp_admin_bar; 
     210 
     211        if ( !is_object( $wp_admin_bar ) ) 
     212                return false; 
     213 
     214        if ( !is_single() && !is_page() ) 
     215                return false; 
     216 
     217        if ( !$post_type_object = get_post_type_object( $post->post_type ) ) 
     218                return false; 
     219 
     220        if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) 
     221                return false; 
     222 
     223        $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_post_link( $post->ID ) ) ); 
     224} 
     225add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 100 ); 
     226 
     227/** 
     228 * Load up the CSS needed to render the admin bar nice and pretty. 
     229 */ 
     230function wp_admin_bar_css() { 
     231        global $pagenow, $wp_locale; 
     232 
     233        if ( !is_user_logged_in() ) 
     234                return false; 
     235 
     236        if ( 'press-this.php' == $pagenow ) 
     237                return; 
     238 
     239        /* Wish we could use wp_enqueue_style() here, but it will not let us pass GET params to the stylesheet correctly. */ 
     240        ?> 
     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(); ?>" type="text/css" /> 
     242        <!--[if IE 6]><style type="text/css">#wpcombar, #wpcombar .menupop a span, #wpcombar .menupop ul li a:hover, #wpcombar .myaccount a, .quicklinks a:hover,#wpcombar .menupop:hover { background-image: none !important; } #wpcombar .myaccount a { margin-left:0 !important; padding-left:12px !important;}</style><![endif]--> 
     243        <style type="text/css" media="print">#wpcombar { display:none; }</style><?php 
     244} 
     245add_action( 'wp_head', 'wp_admin_bar_css' ); 
     246add_action( 'admin_head', 'wp_admin_bar_css' ); 
     247 
     248/** 
     249 * Load up the JS needed to allow the admin bar to function correctly. 
     250 */ 
     251function wp_admin_bar_js() { 
     252        global $wp_admin_bar; 
     253 
     254        if ( !is_object( $wp_admin_bar ) ) 
     255                return false; 
     256 
     257        ?> 
     258        <script type="text/javascript"> 
     259/*      <![CDATA[ */ 
     260                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);}} 
     261                function toggle_query_list() { var querylist = document.getElementById( 'querylist' );if( querylist.style.display == 'block' ) {querylist.style.display='none';} else {querylist.style.display='block';}} 
     262 
     263                jQuery( function() { 
     264                        (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); 
     265                        ;(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); 
     266 
     267                        <?php if ( is_single() ) : ?> 
     268                        if ( jQuery(this).width() < 1100 ) jQuery("#adminbarsearch").hide(); 
     269                        <?php endif; ?> 
     270                                 
     271                        jQuery( '#wpcombar li.ab-my-account, #wpcombar li.ab-bloginfo' ).mouseover( function() { 
     272                                if ( jQuery(this).hasClass( 'ab-my-account' ) ) jQuery('#wpcombar li.ab-me > a').addClass('hover'); 
     273                                if ( jQuery(this).hasClass( 'ab-bloginfo' ) ) jQuery('#wpcombar li.ab-blog > a').addClass('hover'); 
     274                        }); 
     275                         
     276                        jQuery( '#wpcombar li.ab-my-account, #wpcombar li.ab-bloginfo' ).mouseout( function() { 
     277                                if ( jQuery(this).hasClass( 'ab-my-account' ) ) jQuery('#wpcombar li.ab-me > a').removeClass('hover'); 
     278                                if ( jQuery(this).hasClass( 'ab-bloginfo' ) ) jQuery('#wpcombar li.ab-blog > a').removeClass('hover'); 
     279                        }); 
     280 
     281                        <?php if ( is_single() ) : ?> 
     282                        jQuery(window).resize( function() { 
     283                                if ( jQuery(this).width() < 1100 ) 
     284                                        jQuery("#adminbarsearch").hide(); 
     285                                 
     286                                if ( jQuery(this).width() > 1100 ) 
     287                                        jQuery("#adminbarsearch").show(); 
     288                        }); 
     289                        <?php endif; ?> 
     290                         
     291                        jQuery( '#wpcombar ul ul li a' ).mouseover( function() { 
     292                                var root = jQuery(this).parents('div.quicklinks ul > li'); 
     293                                var par = jQuery(this).parent(); 
     294                                var children = par.children('ul'); 
     295                                if ( root.hasClass('ab-sadmin') ) 
     296                                        jQuery(children[0]).css('<?php echo( is_rtl() ? 'left'  : 'right' ); ?>',par.parents('ul').width() - 1 +'px' ); 
     297                                else 
     298                                        jQuery(children[0]).css('<?php echo( is_rtl() ? 'right'  : 'left' ); ?>',par.parents('ul').width() +'px' ); 
     299                                 
     300                                jQuery(children[0]).css('top', '0' ); 
     301                        }); 
     302                         
     303                        <?php if ( is_user_logged_in() ) : // Hash links scroll 32px back so admin bar doesn't cover. ?> 
     304                                if ( window.location.hash ) window.scrollBy(0,-32); 
     305                        <?php endif; ?> 
     306                 
     307                }); 
     308 
     309                jQuery( function() {  
     310                        jQuery('#wpcombar').appendTo('body');  
     311                        jQuery("#wpcombar ul").superfish(); 
     312                }); 
     313 
     314                /*      ]]> */ 
     315        </script><?php 
     316} 
     317add_action( 'wp_footer', 'wp_admin_bar_js' ); 
     318add_action( 'admin_footer', 'wp_admin_bar_js' ); 
     319 
     320/** 
     321 * Return a rendered admin bar via AJAX for use on pages that do not run inside the 
     322 * WP environment. Used on bbPress forum pages to show the admin bar. 
     323 */ 
     324function wp_admin_bar_ajax_render() { 
     325        global $wp_admin_bar; 
     326         
     327        wp_admin_bar_js(); 
     328        wp_admin_bar_css(); 
     329        wp_admin_bar_render(); 
     330        die; 
     331} 
     332add_action( 'wp_ajax_adminbar_render', 'wp_admin_bar_ajax_render' ); 
     333 
     334?> 
  • wp-includes/user.php

    Property changes on: wp-includes/admin-bar.php
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
    575575} 
    576576 
    577577/** 
     578 * Get the blogs a user belong to. 
     579 * 
     580 * $since 3.0.0 
     581 * 
     582 * @param int $id User Id 
     583 * @param bool $all Whether to retrieve all blog details or an abbreviated set of details. Default is abbreviated. 
     584 * @return array A list of the user's blogs. 
     585 */ 
     586function get_blogs_of_user( $id, $all = false ) { 
     587        global $wpdb; 
     588 
     589        if ( !is_multisite() ) { 
     590                global $blog_id; 
     591                $blogs = array(); 
     592                $blogs[ $blog_id ]->userblog_id = $blog_id; 
     593                $blogs[ $blog_id ]->blogname = get_option('blogname'); 
     594                $blogs[ $blog_id ]->domain = ''; 
     595                $blogs[ $blog_id ]->path = ''; 
     596                $blogs[ $blog_id ]->site_id = 1; 
     597                $blogs[ $blog_id ]->siteurl = get_option('siteurl'); 
     598                return $blogs; 
     599        } 
     600 
     601        $cache_suffix = $all ? '_all' : '_short'; 
     602        $return = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' ); 
     603        if ( $return ) 
     604                return apply_filters( 'get_blogs_of_user', $return, $id, $all ); 
     605 
     606        $user = get_userdata( (int) $id ); 
     607        if ( !$user ) 
     608                return false; 
     609 
     610        $blogs = $match = array(); 
     611        $prefix_length = strlen($wpdb->base_prefix); 
     612        foreach ( (array) $user as $key => $value ) { 
     613                if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix ) 
     614                        continue; 
     615                if ( substr($key, -12, 12) != 'capabilities' ) 
     616                        continue; 
     617                if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) { 
     618                        if ( count( $match ) > 2 ) 
     619                                $blog_id = $match[ 2 ]; 
     620                        else 
     621                                $blog_id = 1; 
     622                        $blog = get_blog_details( $blog_id ); 
     623                        if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) { 
     624                                $blogs[ $blog_id ]->userblog_id = $blog_id; 
     625                                $blogs[ $blog_id ]->blogname            = $blog->blogname; 
     626                                $blogs[ $blog_id ]->domain              = $blog->domain; 
     627                                $blogs[ $blog_id ]->path                        = $blog->path; 
     628                                $blogs[ $blog_id ]->site_id             = $blog->site_id; 
     629                                $blogs[ $blog_id ]->siteurl             = $blog->siteurl; 
     630                        } 
     631                } 
     632        } 
     633 
     634        wp_cache_add( 'blogs_of_user_' . $id . $cache_suffix, $blogs, 'users', 5 ); 
     635        return apply_filters( 'get_blogs_of_user', $blogs, $id, $all ); 
     636} 
     637 
     638function get_ordered_blogs_of_user( $user_id, $visibility = true ) { 
     639        $newblogs      = $ordered = array(); 
     640        $blogs         = get_blogs_of_user( $user_id ); 
     641        $order_meta    = get_user_meta( $user_id, 'blog_order' ); 
     642        $visible_meta  = get_user_meta( $user_id, 'blog_visibility' ); 
     643         
     644        $order = $order_meta; 
     645        if ( !is_array( $order ) ) 
     646                $order = array(); 
     647 
     648        $visible = $visible_meta; 
     649        if ( !is_array( $visible ) ) 
     650                $visible = array(); 
     651         
     652        // Index the blogs by userblog_id and set the visibility flag 
     653        // Visibility is on by default, unless a linked site then off 
     654        foreach ( $blogs AS $blog ) { 
     655                $blog->visible = true; 
     656 
     657                if ( isset( $visible[$blog->userblog_id] ) ) 
     658                        $blog->visible = $visible[$blog->userblog_id]; 
     659 
     660                $newblogs[$blog->userblog_id] = $blog; 
     661        } 
     662 
     663        // Add the blogs to our list by order 
     664        foreach ( (array)$order AS $id ) { 
     665                // A previous change was saving the entire blog details into ordered, not just the blog ID - this detects it 
     666                if ( is_object( $id ) && isset( $id->userblog_id ) ) 
     667                        $id = $id->userblog_id; 
     668                         
     669                if ( is_numeric( $id ) && isset( $newblogs[intval( $id )] ) ) { 
     670                        $ordered[$id] = $newblogs[$id]; 
     671                        unset( $newblogs[$id] ); 
     672                } 
     673        } 
     674 
     675        // Add any blog not yet ordered to the end 
     676        foreach ( $newblogs AS $blog ) { 
     677                $ordered[$blog->userblog_id] = $blog; 
     678        } 
     679 
     680        // If we're only interested in visible blogs then remove the rest 
     681        if ( $visibility ) { 
     682                foreach ( (array)$ordered AS $pos => $blog ) { 
     683                        if ( $blog->visible == false ) 
     684                                unset( $ordered[$pos] ); 
     685                } 
     686        } 
     687 
     688/* 
     689        // Set the order and visible options if the user doesn't have any, 
     690        // but rate limit it so that the global DB doesn't get hammered 
     691        if ( !is_array( $order_meta ) && ( 1 == mt_rand( 1, 10 ) ) ) 
     692                update_usermeta( $user_id, 'blog_order', array() ); 
     693 
     694        if ( !is_array( $visible_meta ) && ( 1 == mt_rand( 1, 10 ) ) ) 
     695                update_usermeta( $user_id, 'blog_visibility', array() ); 
     696*/ 
     697 
     698        return apply_filters( 'ordered_blogs', $ordered ); 
     699} 
     700 
     701function set_blog_visibility( $blog_id, $visible ) { 
     702        global $current_user; 
     703 
     704        if ( is_blog_user( $blog_id ) ) { 
     705                $visibility = get_user_meta( $current_user->ID, 'blog_visibility' ); 
     706                if ( !is_array( $visibility ) ) 
     707                        $visibility = array(); 
     708 
     709                $visibility[$blog_id] = $visible; 
     710 
     711                update_user_meta( $current_user->ID, 'blog_visibility', $visibility ); 
     712        } 
     713} 
     714 
     715/** 
     716 * Checks if the current user belong to a given blog. 
     717 * 
     718 * @since 3.0.0 
     719 * 
     720 * @param int $blog_id Blog ID 
     721 * @return bool True if the current users belong to $blog_id, false if not. 
     722 */ 
     723function is_blog_user( $blog_id = 0 ) { 
     724        global $wpdb; 
     725  
     726        $current_user = wp_get_current_user(); 
     727        if ( !$blog_id ) 
     728                $blog_id = $wpdb->blogid; 
     729 
     730        $cap_key = $wpdb->base_prefix . $blog_id . '_capabilities'; 
     731 
     732        if ( is_array($current_user->$cap_key) && in_array(1, $current_user->$cap_key) ) 
     733                return true; 
     734 
     735        return false; 
     736} 
     737 
     738/** 
    578739 * Add meta data field to a user. 
    579740 * 
    580741 * Post meta data is called "Custom Fields" on the Administration Panels. 
  • wp-includes/admin-bar/admin-bar-class.php

     
     1<?php 
     2class WP_Admin_Bar { 
     3        var $user; 
     4        var $menu; 
     5        var $need_to_change_locale = false; 
     6        var $changed_locale = false; 
     7 
     8        function WP_Admin_Bar() { 
     9                global $current_user, $blog_id; 
     10 
     11                $this->user = new stdClass; 
     12                $this->menu = new stdClass; 
     13 
     14                /* Populate settings we need for the menu based on the current user. */ 
     15                $this->user->blogs = get_ordered_blogs_of_user( $current_user->id ); 
     16                if ( is_multisite() ) { 
     17                        $this->user->active_blog = get_active_blog_for_user( $current_user->id ); 
     18                        $this->user->domain = ( $this->user->active_blog == 'username only' ) ? get_dashboard_blog() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) ); 
     19                        $this->user->account_domain = $this->user->domain; 
     20                } else { 
     21                        $this->user->active_blog = $this->user->blogs[$blog_id]; 
     22                        $this->user->domain = home_url(); 
     23                        $this->user->account_domain = home_url(); 
     24                } 
     25                $this->user->locale = get_locale(); 
     26        } 
     27 
     28        function add_menu( $args = array() ) { 
     29                $defaults = array( 
     30                        'title' => false, 
     31                        'href' => false, 
     32                        'parent' => false, // false for a root menu, pass the ID value for a submenu of that menu. 
     33                        'id' => false, // defaults to a sanitized title value. 
     34                        'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '' ); 
     35                ); 
     36 
     37                $r = wp_parse_args( $args, $defaults ); 
     38                extract( $r, EXTR_SKIP ); 
     39 
     40                if ( empty( $title ) ) 
     41                        return false; 
     42 
     43                /* Make sure we have a valid ID */ 
     44                if ( empty( $id ) ) 
     45                        $id = esc_attr( sanitize_title( trim( $title ) ) ); 
     46 
     47                if ( !empty( $parent ) ) { 
     48                        /* 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 ) ) 
     56                                $child['meta'] = $meta; 
     57 
     58                        $this->add_node( $parent, $this->menu, $child ); 
     59                } else { 
     60                        /* Add the menu item */ 
     61                        $this->menu->{$id} = array( 
     62                                'title' => $title, 
     63                                'href' => $href 
     64                        ); 
     65 
     66                        if ( !empty( $meta ) ) 
     67                                $this->menu->{$id}['meta'] = $meta; 
     68                } 
     69        } 
     70 
     71        function remove_menu( $id ) { 
     72                return $this->remove_node( $id, $this->menu ); 
     73        } 
     74         
     75        function render() { 
     76        ?> 
     77                <div id="wpcombar" class="snap_nopreview no-grav"> 
     78                        <div class="quicklinks"> 
     79                                <ul> 
     80                                        <?php foreach ( (array) $this->menu as $id => $menu_item ) : ?> 
     81                                                <?php $this->recursive_render( $id, $menu_item ) ?> 
     82                                        <?php endforeach; ?> 
     83                                </ul> 
     84                        </div> 
     85 
     86                        <div id="adminbarsearch-wrap"> 
     87                                <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> 
     89                                </form> 
     90                        </div> 
     91                </div> 
     92 
     93                <?php 
     94                /* Wipe the menu, might reduce memory usage, but probably not. */ 
     95                $this->menu = null; 
     96        } 
     97 
     98        /* Helpers */ 
     99        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'] ) ) : ?> 
     106                        <ul> 
     107                                <?php foreach ( $menu_item['children'] as $child_id => $child_menu_item ) : ?> 
     108                                        <?php $this->recursive_render( $child_id, $child_menu_item ); ?> 
     109                                <?php endforeach; ?> 
     110                        </ul> 
     111                        <?php endif; ?> 
     112 
     113                        <?php if ( !empty( $menu_item['meta']['html'] ) ) : ?> 
     114                                <?php echo $menu_item['meta']['html']; ?> 
     115                        <?php endif; ?> 
     116                </li><?php 
     117        } 
     118 
     119        function add_node( $parent_id, &$menu, $child ) { 
     120                foreach( $menu as $id => &$menu_item ) { 
     121                        if ( $parent_id == $id ) { 
     122                                $menu->{$parent_id}['children']->{$child['id']} = $child; 
     123                                $child = null; 
     124                                return true; 
     125                        } 
     126 
     127                        if ( !empty( $menu->{$id}['children'] ) ) 
     128                                $this->add_node( $parent_id, $menu->{$id}['children'], $child ); 
     129                } 
     130                $child = null; 
     131 
     132                return false; 
     133        } 
     134 
     135        function remove_node( $id, &$menu ) { 
     136                foreach( $menu as $menu_item_id => &$menu_item ) { 
     137                        if ( $menu_item_id == $id ) { 
     138                                $menu_item = null; 
     139                                return true; 
     140                        } 
     141 
     142                        if ( !empty( $menu->{$menu_item_id}['children'] ) ) 
     143                                $this->remove_node( $id, $menu->{$menu_item_id}['children'] ); 
     144                } 
     145 
     146                return false; 
     147        } 
     148 
     149        function load_user_locale_translations() { 
     150                $this->need_to_change_locale = ( get_locale() != $this->user->locale ); 
     151                if ( !$this->need_to_change_locale ) return; 
     152                $this->previous_translations = get_translations_for_domain( 'default' ); 
     153                $this->adminbar_locale_filter = lambda( '$_', '$GLOBALS["wp_admin_bar"]->user->locale;' ); 
     154                unload_textdomain( 'default' ); 
     155                add_filter( 'locale', $this->adminbar_locale_filter ); 
     156                load_default_textdomain(); 
     157                $this->changed_locale = true; 
     158        } 
     159 
     160        function unload_user_locale_translations() { 
     161                global $l10n; 
     162                if ( !$this->changed_locale ) return; 
     163                remove_filter( 'locale', $this->adminbar_locale_filter ); 
     164                $l10n['default'] = &$this->previous_translations; 
     165 
     166        } 
     167} 
     168?> 
  • wp-includes/admin-bar/admin-bar-debug.php

    Property changes on: wp-includes/admin-bar/admin-bar-class.php
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
     1<?php 
     2/*** 
     3 * Debug Functions 
     4 * 
     5 * When logged in as a super admin, these functions will run to provide 
     6 * debugging information when specific super admin menu items are selected. 
     7 * 
     8 * They are not used when a regular user is logged in. 
     9 */ 
     10 
     11function wp_admin_bar_query_debug_list() { 
     12        global $wpdb; 
     13         
     14        if ( !is_super_admin() ) 
     15                return false; 
     16 
     17        $debugs = array( 
     18                'wpdb' => array( 'Queries', 'wp_admin_bar_debug_queries' ), 
     19                'memcache' => array( 'Memcache', 'wp_admin_bar_debug_memcache' ) 
     20        ); 
     21 
     22        $debugs = apply_filters( 'wp_admin_bar_debugs_list', $debugs ); 
     23 
     24?> 
     25        <script type="text/javascript"> 
     26        /* <![CDATA[ */ 
     27        var clickDebugLink = function( targetsGroupId, obj) { 
     28                var sectionDivs = document.getElementById( targetsGroupId ).childNodes; 
     29                for ( var i = 0; i < sectionDivs.length; i++ ) { 
     30                        if ( 1 != sectionDivs[i].nodeType ) { 
     31                                continue; 
     32                        } 
     33                        sectionDivs[i].style.display = 'none'; 
     34                } 
     35                document.getElementById( obj.href.substr( obj.href.indexOf( '#' ) + 1 ) ).style.display = 'block'; 
     36 
     37                for ( var i = 0; i < obj.parentNode.parentNode.childNodes.length; i++ ) { 
     38                        if ( 1 != obj.parentNode.parentNode.childNodes[i].nodeType ) { 
     39                                continue; 
     40                        } 
     41                        obj.parentNode.parentNode.childNodes[i].removeAttribute( 'class' ); 
     42                } 
     43                obj.parentNode.setAttribute( 'class', 'current' ); 
     44                return false; 
     45        }; 
     46        /* ]]> */ 
     47        </script> 
     48        <div align='left' id='querylist'> 
     49 
     50        <h1>Debugging blog #<?php echo $GLOBALS['blog_id']; ?> on <?php echo php_uname( 'n' ); ?></h1> 
     51        <div id="debug-status"> 
     52                <p class="left"></p> 
     53                <p class="right">PHP Version: <?php echo phpversion(); ?></p> 
     54        </div> 
     55        <ul class="debug-menu-links"> 
     56 
     57<?php   $current = ' class="current"'; foreach ( $debugs as $debug => $debug_output ) : ?> 
     58 
     59                <li<?php echo $current; ?>><a id="debug-menu-link-<?php echo $debug; ?>" href="#debug-menu-target-<?php echo $debug; ?>" onclick="try { return clickDebugLink( 'debug-menu-targets', this ); } catch (e) { return true; }"><?php echo $debug_output[0] ?></a></li> 
     60 
     61<?php   $current = ''; endforeach; ?> 
     62 
     63        </ul> 
     64 
     65        <div id="debug-menu-targets"> 
     66 
     67<?php   $current = ' style="display: block"'; foreach ( $debugs as $debug => $debug_output ) : ?> 
     68 
     69        <div id="debug-menu-target-<?php echo $debug; ?>" class="debug-menu-target"<?php echo $current; ?>> 
     70                <?php echo str_replace( '&nbsp;', '', call_user_func( $debug_output[1] ) ); ?> 
     71        </div> 
     72 
     73<?php   $current = ''; endforeach; ?> 
     74 
     75        </div> 
     76 
     77<?php   do_action( 'wp_admin_bar_debug' ); ?> 
     78 
     79        </div> 
     80 
     81<?php 
     82} 
     83add_action( 'wp_after_admin_bar_render', 'wp_admin_bar_query_debug_list' ); 
     84 
     85function wp_admin_bar_debug_queries() { 
     86        global $wpdb; 
     87 
     88        $queries = array(); 
     89        $out = ''; 
     90        $total_time = 0; 
     91 
     92        if ( !empty($wpdb->queries) ) { 
     93                $show_many = isset($_GET['debug_queries']); 
     94 
     95                if ( $wpdb->num_queries > 500 && !$show_many ) 
     96                        $out .= "<p>There are too many queries to show easily! <a href='" . add_query_arg( 'debug_queries', 'true' ) . "'>Show them anyway</a>.</p>"; 
     97 
     98                $out .= '<ol id="wpd-queries">'; 
     99                $first_query = 0; 
     100                $counter = 0; 
     101 
     102                foreach ( $wpdb->queries as $q ) { 
     103                        list($query, $elapsed, $debug) = $q; 
     104 
     105                        $total_time += $elapsed; 
     106 
     107                        if ( !$show_many && ++$counter > 500 ) 
     108                                continue; 
     109 
     110                        $query = nl2br(esc_html($query)); 
     111 
     112                        // $dbhname, $host, $port, $name, $tcp, $elapsed 
     113                        $out .= "<li>$query<br/><div class='qdebug'>$debug <span>#{$counter} (" . number_format(sprintf('%0.1f', $elapsed * 1000), 1, '.', ',') . "ms)</span></div></li>\n"; 
     114                } 
     115                $out .= '</ol>'; 
     116        } else { 
     117                $out .= "<p><strong>There are no queries on this page, you won the prize!!! :)</strong></p>"; 
     118        } 
     119 
     120        $query_count = '<h2><span>Total Queries:</span>' . number_format( $wpdb->num_queries ) . "</h2>\n"; 
     121        $query_time = '<h2><span>Total query time:</span>' . number_format(sprintf('%0.1f', $total_time * 1000), 1) . "ms</h2>\n"; 
     122        $memory_usage = '<h2><span>Peak Memory Used:</span>' . number_format( memory_get_peak_usage( ) ) . " bytes</h2>\n"; 
     123 
     124        $out = $query_count . $query_time . $memory_usage . $out; 
     125 
     126        return $out; 
     127} 
     128 
     129function wp_admin_bar_debug_memcache() { 
     130        global $wp_object_cache; 
     131        ob_start(); 
     132        echo "<div id='memcache-stats'>"; 
     133                $wp_object_cache->stats(); 
     134        echo "</div>"; 
     135        $out = ob_get_contents(); 
     136        ob_end_clean(); 
     137 
     138        return $out; 
     139} 
     140 
     141function is_admin_bar() { 
     142        return ( 0 === strpos($_SERVER['REQUEST_URI'], '/js/admin-bar') ); 
     143} 
     144 
     145function wp_admin_bar_lang($locale) { 
     146        if ( is_admin_bar() ) 
     147                $locale = get_locale(); 
     148        return $locale; 
     149} 
     150add_filter('locale', 'wp_admin_bar_lang'); 
     151 
     152?> 
     153 No newline at end of file 
  • wp-includes/admin-bar/admin-bar-superadmin.php

    Property changes on: wp-includes/admin-bar/admin-bar-debug.php
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
     1<?php 
     2/** 
     3 * Use the $wp_admin_bar global to add a menu for site admins and administrator controls. 
     4 */ 
     5function 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        $queries = $wpdb->num_queries; 
     12        $seconds = timer_stop(); 
     13 
     14        /* Add the main siteadmin menu item */ 
     15        $wp_admin_bar->add_menu( array( 'id' => 'queries', 'title' => "{$queries}q/{$seconds}", 'href' => 'javascript:toggle_query_list()', 'meta' => array( 'class' => 'ab-sadmin' ) ) ); 
     16 
     17        /* Add the "Super Admin" settings sub menu */ 
     18        wp_admin_bar_superadmin_settings_menu(); 
     19} 
     20add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_superadmin_menus', 1000 ); 
     21 
     22/** 
     23 * 
     24 * Use the $wp_admin_bar global to add the super admin menu, providing admin options only visible to super admins. 
     25 */ 
     26function wp_admin_bar_superadmin_settings_menu() { 
     27        global $wp_admin_bar, $current_blog, $current_user; 
     28 
     29        if ( !is_object( $wp_admin_bar ) || !is_super_admin() ) 
     30                return false; 
     31 
     32        /* Add the main superadmin menu item */ 
     33        $wp_admin_bar->add_menu( array( 'id' => 'superadmin', 'title' => '&mu;', 'href' => '', 'meta' => array( 'class' => 'ab-sadmin' ) ) ); 
     34 
     35        wp_admin_bar_build_snackmenu(); 
     36 
     37        /* Get the settings we need for the current blog */ 
     38        $matureaction = $current_blog->mature ? 'unmatureblog' : 'matureblog'; 
     39        $maturetext = $current_blog->mature ? esc_attr__('Unmark as mature') : esc_attr__('Mark as mature'); 
     40        $suspendtext = $current_blog->spam ? esc_attr('Unsuspend blog') : esc_attr('Suspend blog'); 
     41        $suspendaction = $current_blog->spam ? 'unspamblog' : 'spamblog'; 
     42        $mature_url = admin_url( "ms-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?" ) ); 
     43        $suspend_url = admin_url( "ms-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} ?" ) ); 
     44 
     45        /* Add the submenu items to the Super Admin menu */ 
     46        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Blog Dashboard' ), 'href' => admin_url(), 'position' => 10 ) ); 
     47        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Blog Options' ),  'href' => admin_url( "ms-sites.php?action=blogs&amp;searchaction=id&amp;s={$current_blog->blog_id}" ), 'position' => 30 ) ); 
     48        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => "$maturetext", 'href' => $mature_url, 'position' => 50 ) ); 
     49        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => "$suspendtext", 'href' => $suspend_url, 'position' => 80 ) ); 
     50} 
     51 
     52function wp_admin_bar_build_snackmenu() { 
     53        global $wp_admin_bar, $menu, $submenu, $pagenow; 
     54 
     55        if ( !is_object( $wp_admin_bar ) || !is_super_admin() ) 
     56                return false; 
     57 
     58        // Hide moderation count, filter removed at the bottom of this function 
     59        add_filter( 'wp_count_comments', 'wp_admin_bar_removemodcount' ); 
     60 
     61        require_once( ABSPATH . 'wp-admin/includes/admin.php' ); 
     62 
     63        // menu.php assumes it is in the global scope and relies on the $wp_taxonomies global array 
     64        $wp_taxonomies = array(); 
     65        require_once( ABSPATH . 'wp-admin/menu.php' ); 
     66 
     67        /* Add the snack menu submenu to the superadmin menu */ 
     68        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => 'Snack Menu', 'href' => '/wp-admin/' ) ); 
     69 
     70        /* Loop through the submenus and add them */ 
     71        foreach ( (array) $menu as $key => $item ) { 
     72                $admin_is_parent = false; 
     73                $submenu_as_parent = false; 
     74 
     75                if ( $submenu_as_parent && !empty($submenu[$item[2]]) ) { 
     76                        $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index. 
     77                        $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 
     78                        $menu_file = $submenu[$item[2]][0][2]; 
     79         
     80                        if ( false !== $pos = strpos($menu_file, '?') ) 
     81                                $menu_file = substr($menu_file, 0, $pos); 
     82                        if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) { 
     83                                $admin_is_parent = true; 
     84                                $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$submenu[$item[2]][0][2]}") ) ); 
     85                        } else { 
     86                                $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$submenu[$item[2]][0][2]}") ) ); 
     87                        } 
     88                } else if ( current_user_can($item[1]) ) { 
     89                        $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 
     90                        $menu_file = $item[2]; 
     91 
     92                        if ( false !== $pos = strpos($menu_file, '?') ) 
     93                                $menu_file = substr($menu_file, 0, $pos); 
     94                        if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) { 
     95                                $admin_is_parent = true; 
     96                                $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$item[2]}") ) ); 
     97                        } else { 
     98                                $wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$item[2]}") ) ); 
     99                        } 
     100                } 
     101 
     102                if ( !empty($submenu[$item[2]]) ) { 
     103                        $first = true; 
     104                        $unique_submenu = array(); 
     105                         
     106                        foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) { 
     107                                if ( !current_user_can($sub_item[1]) || in_array( $sub_item[0], $unique_submenu ) ) 
     108                                        continue; 
     109                         
     110                                $unique_submenu[] = $sub_item[0]; 
     111                                 
     112                                if ( $first ) 
     113                                        $first = false; 
     114                                 
     115                                $menu_file = $item[2]; 
     116                                if ( false !== $pos = strpos($menu_file, '?') ) 
     117                                        $menu_file = substr($menu_file, 0, $pos); 
     118                                 
     119                                $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); 
     120                                $sub_file = $sub_item[2]; 
     121                                if ( false !== $pos = strpos($sub_file, '?') ) 
     122                                        $sub_file = substr($sub_file, 0, $pos); 
     123                                 
     124                                if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) { 
     125                                        // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir 
     126                                 
     127                                        $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($menu_file); 
     128                                        if ( $parent_exists ) 
     129                                                $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$item[2]}?page={$sub_item[2]}") ) ); 
     130                                        elseif ( 'admin.php' == $pagenow || !$parent_exists ) 
     131                                                $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("admin.php?page={$sub_item[2]}") ) ); 
     132                                        else 
     133                                                $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$item[2]}?page={$sub_item[2]}") ) ); 
     134                                } else { 
     135                                        $wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$sub_item[2]}") ) ); 
     136                                } 
     137                        } 
     138                } 
     139        } 
     140 
     141        remove_filter( 'wp_count_comments', 'wp_admin_bar_removemodcount' ); 
     142} 
     143 
     144// Short circuits wp_count_comments() for the front end 
     145function wp_admin_bar_removemodcount( $stats ) { 
     146        if ( is_admin() ) 
     147                return $stats; 
     148 
     149        $stats = array( 
     150                'moderated'      => 0, 
     151                'approved'       => 0, 
     152                'spam'           => 0, 
     153                'trash'          => 0, 
     154                'post-trashed'   => 0, 
     155                'total_comments' => 0, 
     156        ); 
     157 
     158        return (object) $stats; 
     159} 
     160 
     161?> 
  • wp-includes/admin-bar/admin-bar-css.php

    Property changes on: wp-includes/admin-bar/admin-bar-superadmin.php
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
     1<?php  
     2        header( 'Content-type: text/css' ); 
     3        $proto = ( empty( $_GET['p'] ) ) ? 'http://' : 'https://'; 
     4        $text_direction =  $_GET['td']; 
     5        if ( 'ltr' == $text_direction || empty( $_GET['td'] ) ) 
     6                $sprite = $_GET['inc'] . 'images/admin-bar-sprite.png?d=08102010'; 
     7        else 
     8                $sprite = $_GET['inc'] . 'images/admin-bar-sprite-rtl.png?d=08102010'; 
     9?> 
     10 
     11#wpcombar { direction:ltr; background:#666 url(<?php echo $sprite; ?>) 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; } 
     12#wpcombar ul, #wpcombar ul li { position: relative; z-index: 99999; } 
     13#wpcombar ul li img { vertical-align: middle !important; margin-right: 8px !important; border: none !important; padding: 0 !important; } 
     14#wpcombar .quicklinks > ul > li > a { border-right: 1px solid #686868; border-left: 1px solid #808080; } 
     15#wpcombar .quicklinks > ul > li.ab-subscriptions > a, #wpcombar .quicklinks > ul > li:last-child > a { border-right: none; } 
     16#wpcombar .quicklinks > ul > li.hover > a { border-left-color: #707070; } 
     17#wpcombar a { outline: none; } 
     18#wpcombar .avatar {border:1px solid #999 !important;padding:0 !important;margin:-3px 5px 0 0 !important;vertical-align:middle;float:none;display:inline !important; } 
     19#wpcombar .menupop ul li a {color:#555 !important;text-shadow:none;font-weight:normal;white-space:nowrap;} 
     20#wpcombar .menupop a > span {background:url(<?php echo $sprite; ?>) 100% 100.4% no-repeat;padding-right:.8em;line-height: 28px;} 
     21#wpcombar .menupop ul li a > span { display: block; background:url(<?php echo $sprite; ?>) 100% 97.2% no-repeat;padding-right:1.5em;line-height: 28px;} 
     22#wpcombar .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; } 
     23#wpcombar .menupop ul li a:hover span#awaiting-mod { background: #fff; color: #888; } 
     24#wpcombar .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} 
     25html>body #wpcombar .menupop ul {background:rgba(255,255,255,0.97);border-color:rgba(0,0,0,0.1);} 
     26#wpcombar .menupop.ab-my-account ul, #wpcombar .menupop.ab-my-dash ul, #wpcombar .menupop.ab-new-post ul {min-width:140px} 
     27#wpcombar .menupop li {float:none;margin:0;padding:0;background-image:none;} 
     28#wpcombar .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;} 
     29#wpcombar .quicklinks a:hover {text-shadow:#333 0px -1px 0px;} 
     30#wpcombar li.ab-privacy { float: right; background: #333; } 
     31#wpcombar li.ab-privacy > a > span { background: none; padding: 0;  } 
     32#wpcombar li.ab-privacy span#priv-icon { display: block; text-indent: -999em; background:url(<?php echo $sprite; ?>) 40% 59.7% no-repeat; padding: 0; width: 13px; margin-right: -3px; } 
     33 
     34#wpcombar li.ab-sadmin { float: right; background: #555 } 
     35#wpcombar li.ab-sadmin ul, #wpcombar li.ab-privacy ul { right: 0; float: right; } 
     36#wpcombar li.ab-sadmin > a { font-size: 11px !important; padding: 0 7px !important; border: none !important; border-left: 1px solid #666 !important; } 
     37 
     38#wpcombar li.ab-sadmin ul a, #wpcombar li.ab-privacy a { border-right: none !important; border-left: none !important; } 
     39#wpcombar li.ab-sadmin ul li { right: 0; float: right; text-align: left; width: 100%; } 
     40#wpcombar li.ab-sadmin ul li a { padding-left: 1.75em; }  
     41#wpcombar li.ab-sadmin ul li a > span { background:url(<?php echo $sprite; ?>) 0% 101.8% no-repeat;padding-left: 1.25em; margin-left: -1.25em; line-height: 28px; padding-right: 0 !important; } 
     42#wpcombar li a.loading { background: url(</ajax-loader.gif) 10px 50% no-repeat !important; padding-left: 29px; } 
     43#wpcombar li.subscribed a strong { background:url(<?php echo $sprite; ?>) 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; } 
     44 
     45#wpcombar li:hover {background: #555 url(<?php echo $sprite; ?>) 0 -282px repeat-x;} 
     46#wpcombar li li:hover { color:#fff !important; background: #888 url(<?php echo $sprite; ?>) 0 -222px repeat-x !important;text-shadow: #666 0px -1px 0px;} 
     47#wpcombar li li:hover > a { color:#fff !important; } 
     48.quicklinks ul {list-style:none;margin:0;padding:0;text-align:left} 
     49.quicklinks ul li {float:left;margin:0} 
     50 
     51#adminbarlogin {float:left;display:inline;} 
     52 
     53#adminbarsearch {float:right; } 
     54#adminbarsearch {height: 18px;padding: 3px;} 
     55#adminbarsearch * {color: #555;font-size:12px;} 
     56#adminbarsearch label, #adminbarsearch a { height: 28px; color: #ccc; display:block;float:left;padding:3px 4px;text-shadow:0px -1px 0px #444;} 
     57#adminbarsearch a {text-decoration:underline;} 
     58#adminbarsearch a:hover {color:#fff;} 
     59 
     60#wpcombar li.ab-me:hover, #wpcombar li.ab-blog:hover { background:none;} 
     61#wpcombar li.ab-me > a, #wpcombar li.ab-blog > a { line-height: 18px !important; border: none !important; background:url(<?php echo $sprite; ?>) 100% 59.8% no-repeat; height: 28px; padding: 0 1.15em 0 0.7em; } 
     62#wpcombar li.ab-me > a.hover, #wpcombar li.ab-blog > a.hover { background-position: 67% 59.8%; } 
     63#wpcombar li.ab-me img.avatar, #wpcombar li.ab-blog img.avatar { margin: 4px 0 0 0 !important; vertical-align: middle; background: #eee; width: 16px !important; height: 16px !important; } 
     64#wpcombar li.ab-my-account a, #wpcombar li.ab-bloginfo a { border-left: none !important; padding-left: 0.7em !important; margin-top: 0 !important; } 
     65#wpcombar li.ab-my-account > ul, #wpcombar li.ab-bloginfo > ul { left: -7px; } 
     66#wpcombar ul li img { width: 16px !important; height: 16px !important; } 
     67 
     68#wpcombar 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 } 
     69 
     70#wpcombar #q { 
     71        line-height:normal !important; 
     72        width:140px !important; 
     73        margin-top:0px !important; 
     74} 
     75.adminbar-input { 
     76        display:block !important; 
     77        float:left !important; 
     78        font:12px Arial,Helvetica,sans-serif !important; 
     79        border:1px solid #626262 !important; 
     80        padding:2px 3px !important; 
     81        margin-right:3px !important; 
     82        background:#ddd url(<?php echo $sprite; ?>) top left no-repeat !important; 
     83        -webkit-border-radius:0 !important; 
     84        -khtml-border-radius:0 !important; 
     85        -moz-border-radius:0 !important; 
     86        border-radius:0 !important; 
     87        outline:none; 
     88        text-shadow:0 1px 0 #fff; 
     89} 
     90button.adminbar-button { 
     91        position:relative; 
     92        border:0; 
     93        cursor:pointer; 
     94        overflow:visible; 
     95        margin:0 !important; 
     96        float:left; 
     97        background:url(<?php echo $sprite; ?>) right -107px no-repeat; 
     98        padding:0 14px 0 0; 
     99        text-align:center; 
     100} 
     101button.adminbar-button span { 
     102        position:relative; 
     103        display:block; 
     104        white-space:nowrap; 
     105        height:19px; 
     106        background:url(<?php echo $sprite; ?>) left -69px no-repeat; 
     107        padding:3px 0 0 14px; 
     108        font:12px Arial,Helvetica,sans-serif !important; 
     109        font-weight:bold !important; 
     110        color:#444 !important; 
     111        text-shadow:0px 1px 0px #eee !important; 
     112} 
     113button.adminbar-button:active { 
     114        background-position:right -184px !important; 
     115        text-shadow:0px 1px 0px #eee !important; 
     116} 
     117button.adminbar-button:hover span { 
     118        color:#000 !important; 
     119} 
     120button.adminbar-button:active span { 
     121        background-position:left -146px !important; 
     122} 
     123button.adminbar-button::-moz-focus-inner { 
     124        border:none; 
     125} 
     126@media screen and (-webkit-min-device-pixel-ratio:0) { 
     127        button.adminbar-button span { 
     128                margin-top: -1px; 
     129        } 
     130} 
     131 
     132<?php if ( 'rtl' == $text_direction ) : ?> 
     133        #wpcombar { 
     134                direction:rtl; 
     135                font-family: Tahoma, Arial ,sans-serif; 
     136                right:0; 
     137                left:auto; 
     138        } 
     139        #wpcombar div, #wpcombar ul, #wpcombar ul li { 
     140                min-height: 0; 
     141        } 
     142        #wpcombar ul li img {  margin-left: 8px !important; margin-right: 0 !important; } 
     143        #wpcombar .quicklinks > ul > li > a { border-left: 1px solid #686868; border-right: 1px solid #808080;} 
     144        #wpcombar .quicklinks > ul > li.ab-subscriptions > a, #wpcombar .quicklinks > ul > li:last-child > a { border-left: none; border-right: 1px solid #808080;} 
     145        #wpcombar .quicklinks > ul > li.hover > a { border-right-color: #707070; border-left-color: #686868; } 
     146        #wpcombar .avatar {margin: -3px  0 0 5px !important; float:none;  } 
     147        #wpcombar .menupop a > span {background-position: 0 100.4%; padding-left:.8em;} 
     148        #wpcombar .menupop ul li a > span { background-position: 0% 97.2%; padding-right:0;padding-left:1.5em } 
     149        #wpcombar .menupop ul {right: 0; width:100%; min-width:150px;} 
     150        #wpcombar .ab-my-account ul { width:200px;} 
     151        #wpcombar .ab-my-blogs ul { width:300px;} 
     152        #wpcombar .ab-my-blogs ul ul { width:200px;} 
     153        #wpcombar .ab-subscribe ul { width:150px;} 
     154        #wpcombar .ab-bloginfo ul { width:200px;} 
     155        #wpcombar .ab-subscribe ul { width:150px;} 
     156        #wpcombar .ab-subscriptions ul { width:200px;} 
     157        #wpcombar .menupop ul li {width:auto} 
     158        #wpcombar .quicklinks a {font-family: Tahoma, Arial, Helvetica, sans-serif;} 
     159        #wpcombar li.ab-privacy { float: left; } 
     160        #wpcombar li.ab-privacy span#priv-icon { text-indent: 999em; background-position: 60% 59.7%; padding: 0; margin-right: 0; margin-left: -3px;} 
     161 
     162        #wpcombar li.ab-sadmin { float: left;  } 
     163        #wpcombar li.ab-sadmin ul, #wpcombar li.ab-privacy ul { right: auto; left: 0; float: left; } 
     164        #wpcombar li.ab-sadmin > a { border-right: 1px solid #666 !important; border-left:none !important;} 
     165 
     166        #wpcombar li.ab-sadmin ul a, #wpcombar li.ab-privacy a { border-right: none !important; border-left: none !important; } 
     167        #wpcombar li.ab-sadmin ul li { left: 0; right:auto; float: left; text-align: right;  } 
     168 
     169 
     170        #wpcombar li.ab-sadmin ul li a { padding-right: 1.75em; padding-left: 0 }  
     171        #wpcombar 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; } 
     172        #wpcombar li a.loading { background-position: right 50% !important; padding-right: 29px; padding-left: 0;} 
     173        #wpcombar li.subscribed a strong { background-position: 68% 59.8% !important;  padding: 0 0 0 16px; float: right; margin-left: 2px; } 
     174 
     175 
     176        .quicklinks ul {text-align:right} 
     177        .quicklinks ul li {float:right;} 
     178 
     179        #adminbarlogin {float:right;} 
     180 
     181        #adminbarsearch {display:none;} 
     182        #adminbarsearch label, #adminbarsearch a { float:right;} 
     183 
     184        #wpcombar li.ab-me > a, #wpcombar li.ab-blog > a { background-position:0% 59.8%; padding: 0 0.7em 0 1.15em; } 
     185        #wpcombar li.ab-me > a.hover, #wpcombar li.ab-blog > a.hover { background-position: 33% 59.8%; } 
     186        #wpcombar li.ab-my-account a, #wpcombar li.ab-bloginfo a { border-right: none !important; padding-right: 0.7em !important;  } 
     187        #wpcombar li.ab-my-account > ul, #wpcombar li.ab-bloginfo > ul { right: -7px; left:auto;} 
     188 
     189        #wpcombar ul li a strong.count { margin-right: 5px; margin-left: 0; position:static} 
     190 
     191 
     192        .adminbar-input { 
     193                float:right !important; 
     194                font-family: Tahoma, Arial,Helvetica,sans-serif !important; 
     195                margin-right:3px !important; 
     196                margin-left:0 !important; 
     197                background-position: right top !important; 
     198        } 
     199        button.adminbar-button { 
     200                float:right; 
     201                background-position: left -107px; 
     202                padding:0 0 0 14px; 
     203        } 
     204        button.adminbar-button span { 
     205                background-position: right -69px; 
     206                padding:3px 14px 0 0; 
     207                font-family: Tahoma, Arial,Helvetica,sans-serif !important; 
     208        } 
     209        button.adminbar-button:active { 
     210                background-position:left -184px !important; 
     211        } 
     212        button.adminbar-button:active span { 
     213                background-position:right -146px !important; 
     214        } 
     215<?php 
     216endif; 
     217 
     218$nobump_array = array('Silver is the New Black', 'H2', 'Green MarinŽe', 'Sweet Blossoms', 'Girl in Green', 'Dusk', 'Solipsus', 'FAQ Theme', 'Unsleepable', 'Strange Maps'); 
     219$current_theme = str_replace( '+', ' ', $_GET['t'] ); 
     220$is_admin = $_GET['a']; 
     221$is_super_admin = $_GET['sa']; 
     222 
     223if ( ( !in_array( $current_theme, $nobump_array ) || $is_admin ) && !strpos( $_SERVER['REQUEST_URI'], 'media-upload.php' ) ) : ?> 
     224        body { padding-top: 28px !important; } 
     225<?php endif; ?> 
     226 
     227<?php if ( in_array( $current_theme, array('H3', 'H4', 'The Journalist v1.9') ) ) { ?> 
     228        body { padding-top: 28px; background-position: 0px 28px; } 
     229<?php } ?> 
     230 
     231<?php if ( 'Akismet' == $current_theme ) { ?> 
     232        #zeitgeist {top: 28px;} 
     233<?php } ?> 
     234 
     235<?php if ( $is_super_admin ) : ?> 
     236        #querylist { 
     237                font-family: Arial, Tahoma, sans-serif; 
     238                display: none; 
     239                position: absolute; 
     240                top: 50px; 
     241                left: 50px; 
     242                right: 50px; 
     243                background: #fff; 
     244                padding: 20px; 
     245                -moz-box-shadow: 0 0 15px #888; 
     246                -webkit-box-shadow: 0 0 15px #888; 
     247                box-shadow: 0 0 15px #888; 
     248                z-index: 99999; 
     249                border: 10px solid #f0f0f0; 
     250                color: #000; 
     251                line-height: 150% !important; 
     252        } 
     253        #querylist pre { 
     254                font-size: 12px; 
     255                padding: 10px; 
     256        } 
     257         
     258        #querylist h1 { 
     259                font-family: georgia, times, serif; 
     260                text-align: center; 
     261                font-size: 24px; 
     262                padding: 20px 5px; 
     263                background: #eee; 
     264                color: #555; 
     265                margin: 0; 
     266        } 
     267        #querylist div#debug-status { 
     268                background: #ccc; 
     269                color: #fff; 
     270                overflow: hidden; 
     271                height: 21px; 
     272                font-size: 14px; 
     273                font-family: georgia, times, serif; 
     274                padding: 7px 15px; 
     275        } 
     276        #querylist .left { float: left; } 
     277        #querylist .right { float: right; } 
     278         
     279        #querylist h1, #querylist h2, #querylist h3 { 
     280                font-weight: normal; 
     281        } 
     282         
     283        #querylist ul.debug-menu-links { 
     284                clear: left; 
     285                background: #ccc; 
     286                padding: 10px 15px 0; 
     287                overflow: hidden; 
     288                list-style: none; 
     289                margin: 0; 
     290                padding: 0 0 0 15px; 
     291        } 
     292                #querylist ul.debug-menu-links li { 
     293                        float: left; 
     294                        margin-right: 10px; 
     295                        margin-bottom: 0 !important; 
     296                } 
     297                 
     298                #querylist ul.debug-menu-links li a { 
     299                        outline: none; 
     300                        display: block; 
     301                        padding: 5px 9px; 
     302                        margin-right: 0; 
     303                        background: #bbb; 
     304                        color: #fff !important; 
     305                        text-decoration: none !important; 
     306                        font-weight: normal; 
     307                        font-size: 12px; 
     308                        color: #555; 
     309                        -webkit-border-top-right-radius: 4px;                    
     310                        -webkit-border-top-left-radius: 4px; 
     311                        -moz-border-radius-topright: 4px; 
     312                        -moz-border-radius-topleft: 4px; 
     313                } 
     314                        #querylist ul.debug-menu-links li.current a { 
     315                                background: #fff; 
     316                                color: #555 !important; 
     317                        } 
     318         
     319        #querylist h2 { 
     320                float: left; 
     321                min-width: 150px; 
     322                border: 1px solid #eee; 
     323                padding: 5px 10px 15px; 
     324                clear: none; important; 
     325                text-align: center; 
     326                font-family: georgia, times, serif; 
     327                font-size: 28px; 
     328                margin: 15px 10px 15px 0 !important; 
     329        } 
     330                #querylist h2 span { 
     331                        font-size: 12px; 
     332                        color: #888; 
     333                        text-transform: uppercase; 
     334                        white-space: nowrap; 
     335                        display: block; 
     336                        margin-bottom: 5px; 
     337                } 
     338         
     339        #memcache-stats h2 { 
     340                border: none; 
     341                float: none; 
     342                text-align: left; 
     343                font-size: 22px; 
     344                margin-bottom: 0; 
     345        } 
     346         
     347        #memcache-stats ul.debug-menu-links { 
     348                padding: 0; 
     349                margin: 0; 
     350                background: none; 
     351        } 
     352                #memcache-stats ul.debug-menu-links li { 
     353                        float: left; 
     354                        margin-bottom: 10px !important; 
     355                        background: none !important; 
     356                        border: 1px solid #eee !important; 
     357                        color: #555 !important; 
     358                } 
     359                        #memcache-stats ul.debug-menu-links li.current a { 
     360                                background: #ccc !important; 
     361                                color: #fff !important; 
     362                                -webkit-border-top-right-radius: 0;                      
     363                                -webkit-border-top-left-radius: 0; 
     364                                -moz-border-radius-topright: 0; 
     365                                -moz-border-radius-topleft: 0; 
     366                        } 
     367                         
     368                        #memcache-stats ul.debug-menu-links li a { 
     369                                background: none; 
     370                                color: #555 !important; 
     371                                overflow: hidden; 
     372                        } 
     373         
     374        #querylist h3 { 
     375                margin-bottom: 15px; 
     376        } 
     377         
     378        #querylist ol#wpd-queries { 
     379                padding: 0 !important; 
     380                margin: 0 !important; 
     381                list-style: none; 
     382                clear: left; 
     383        } 
     384                #querylist ol#wpd-queries li { 
     385                        padding: 10px; 
     386                        background: #f0f0f0; 
     387                        margin: 0 0 10px 0; 
     388                } 
     389                        #querylist ol#wpd-queries li div.qdebug { 
     390                                background: #e8e8e8; 
     391                                margin: 10px -10px -10px -10px; 
     392                                padding: 5px 150px 5px 5px; 
     393                                font-size: 11px; 
     394                                position: relative; 
     395                                min-height: 20px; 
     396                        } 
     397                         
     398                        #querylist ol#wpd-queries li div.qdebug span { 
     399                                position: absolute; 
     400                                right: 10px; 
     401                                top: 5px; 
     402                                white-space: nowrap; 
     403                        } 
     404         
     405        #querylist a { 
     406                text-decoration: underline !important; 
     407                color: blue !important; 
     408        } 
     409        #querylist a:hover { 
     410                text-decoration: none !important; 
     411        } 
     412        #querylist .debug-menu-target { 
     413                display: none; 
     414        } 
     415         
     416        #querylist ol { 
     417                font: 12px Monaco, "Courier New", Courier, Fixed !important; 
     418                line-height: 180% !important; 
     419        } 
     420         
     421        #wpcombar #admin-bar-micro ul li { 
     422                list-style-type: none; 
     423                position: relative; 
     424                margin: 0; 
     425                padding: 0; 
     426        } 
     427        #wpcombar #admin-bar-micro ul ul, #wpcombar #admin-bar-micro #awaiting-mod, #wpcombar .ab-sadmin .count-0 { 
     428                display: none !important; 
     429        } 
     430        #wpcombar #admin-bar-micro ul li:hover > ul { 
     431                display: block; 
     432                position: absolute; 
     433                top: -1px; 
     434                left: 100%; 
     435        } 
     436        #wpcombar #admin-bar-micro li a { 
     437                display: block; 
     438                text-decoration: none; 
     439        } 
     440        #wpcombar #admin-bar-micro li li a { 
     441                background: #ddd; 
     442        } 
     443        #wpcombar #admin-bar-micro li li li a { 
     444                background: #fff; 
     445        } 
     446         
     447        <?php if ( 'rtl' == $text_direction ) : ?> 
     448         
     449                #querylist { 
     450                        direction: ltr; 
     451                } 
     452                 
     453                #wpcombar #admin-bar-micro ul li:hover > ul { 
     454                        left: auto; 
     455                        right: 100%; 
     456                } 
     457        <?php endif; ?> 
     458<?php endif; ?> 
     459 No newline at end of file 
  • wp-includes/ms-functions.php

    Property changes on: wp-includes/admin-bar/admin-bar-css.php
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    
    Property changes on: wp-includes/images/admin-bar-sprite-rtl.png
    ___________________________________________________________________
    Added: svn:mime-type
       + application/octet-stream
    
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    
    Property changes on: wp-includes/images/admin-bar-sprite.png
    ___________________________________________________________________
    Added: svn:mime-type
       + application/octet-stream
    
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    
    Property changes on: wp-includes/images/wpmini-blue.png
    ___________________________________________________________________
    Added: svn:mime-type
       + application/octet-stream
    
     
    3030        return false; 
    3131} 
    3232 
    33 function get_blogs_of_user( $id, $all = false ) { 
    34         global $wpdb; 
    35  
    36         $cache_suffix = $all ? '_all' : '_short'; 
    37         $return = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' ); 
    38         if ( $return ) 
    39                 return apply_filters( 'get_blogs_of_user', $return, $id, $all ); 
    40  
    41         $user = get_userdata( (int) $id ); 
    42         if ( !$user ) 
    43                 return false; 
    44  
    45         $blogs = $match = array(); 
    46         $prefix_length = strlen($wpdb->base_prefix); 
    47         foreach ( (array) $user as $key => $value ) { 
    48                 if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix ) 
    49                         continue; 
    50                 if ( substr($key, -12, 12) != 'capabilities' ) 
    51                         continue; 
    52                 if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) { 
    53                         if ( count( $match ) > 2 ) 
    54                                 $blog_id = $match[ 2 ]; 
    55                         else 
    56                                 $blog_id = 1; 
    57                         $blog = get_blog_details( $blog_id ); 
    58                         if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) { 
    59                                 $blogs[ $blog_id ]->userblog_id = $blog_id; 
    60                                 $blogs[ $blog_id ]->blogname            = $blog->blogname; 
    61                                 $blogs[ $blog_id ]->domain              = $blog->domain; 
    62                                 $blogs[ $blog_id ]->path                        = $blog->path; 
    63                                 $blogs[ $blog_id ]->site_id             = $blog->site_id; 
    64                                 $blogs[ $blog_id ]->siteurl             = $blog->siteurl; 
    65                         } 
    66                 } 
    67         } 
    68  
    69         wp_cache_add( 'blogs_of_user_' . $id . $cache_suffix, $blogs, 'users', 5 ); 
    70         return apply_filters( 'get_blogs_of_user', $blogs, $id, $all ); 
    71 } 
    72  
    7333function get_active_blog_for_user( $user_id ) { // get an active blog for user - either primary blog or from blogs list 
    7434        global $wpdb; 
    7535        $blogs = get_blogs_of_user( $user_id ); 
     
    366326        return $url; 
    367327} 
    368328 
    369 function is_blog_user( $blog_id = 0 ) { 
    370         global $wpdb; 
    371   
    372         $current_user = wp_get_current_user(); 
    373         if ( !$blog_id ) 
    374                 $blog_id = $wpdb->blogid; 
    375  
    376         $cap_key = $wpdb->base_prefix . $blog_id . '_capabilities'; 
    377  
    378         if ( is_array($current_user->$cap_key) && in_array(1, $current_user->$cap_key) ) 
    379                 return true; 
    380  
    381         return false; 
    382 } 
    383  
    384329function is_email_address_unsafe( $user_email ) { 
    385330        $banned_names = get_site_option( 'banned_email_domains' ); 
    386331        if ($banned_names && !is_array( $banned_names )) 
  • wp-settings.php

     
    133133require( ABSPATH . WPINC . '/widgets.php' ); 
    134134require( ABSPATH . WPINC . '/nav-menu.php' ); 
    135135require( ABSPATH . WPINC . '/nav-menu-template.php' ); 
     136require( ABSPATH . WPINC . '/admin-bar.php' ); 
    136137 
    137138// Load multisite-specific files. 
    138139if ( is_multisite() ) {