<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16098] trunk/wp-includes: Kill the admin-bar directory.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16098">16098</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-10-30 06:40:04 +0000 (Sat, 30 Oct 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Kill the admin-bar directory. see <a href="http://trac.wordpress.org/ticket/14772">#14772</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesadminbarphp">trunk/wp-includes/admin-bar.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpincludesclasswpadminbarphp">trunk/wp-includes/class-wp-admin-bar.php</a></li>
<li><a href="#trunkwpincludesmsadminbarphp">trunk/wp-includes/ms-admin-bar.php</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li>trunk/wp-includes/admin-bar/</li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar.php (16097 => 16098)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar.php        2010-10-30 06:14:15 UTC (rev 16097)
+++ trunk/wp-includes/admin-bar.php        2010-10-30 06:40:04 UTC (rev 16098)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         /* Load the admin bar class code ready for instantiation */
</span><del>-        require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' );
</del><ins>+        require( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
</ins><span class="cx">
</span><span class="cx">         /* Instantiate the admin bar */
</span><span class="cx">         $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
</span></span></pre></div>
<a id="trunkwpincludesclasswpadminbarphpfromrev16091trunkwpincludesadminbaradminbarclassphp"></a>
<div class="copfile"><h4>Copied: trunk/wp-includes/class-wp-admin-bar.php (from rev 16091, trunk/wp-includes/admin-bar/admin-bar-class.php) (0 => 16098)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-admin-bar.php         (rev 0)
+++ trunk/wp-includes/class-wp-admin-bar.php        2010-10-30 06:40:04 UTC (rev 16098)
</span><span class="lines">@@ -0,0 +1,233 @@
</span><ins>+<?php
+class WP_Admin_Bar {
+        var $changed_locale = false;
+        var $menu;
+        var $need_to_change_locale = false;
+        var $proto = 'http://';
+        var $user;
+
+        function initialize() {
+                /* Only load super admin menu code if the logged in user is a super admin */
+                if ( is_super_admin() ) {
+                        require( ABSPATH . WPINC . '/ms-admin-bar.php' );
+                }
+
+                /* Set the protocol used throughout this code */
+                if ( is_ssl() )
+                        $this->proto = 'https://';
+
+                $this->user = new stdClass;
+                $this->menu = new stdClass;
+
+                /* Populate settings we need for the menu based on the current user. */
+                $this->user->blogs = get_blogs_of_user( get_current_user_id() );
+                if ( is_multisite() ) {
+                        $this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
+                        $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
+                        $this->user->account_domain = $this->user->domain;
+                } else {
+                        $this->user->active_blog = $this->user->blogs[get_current_blog_id()];
+                        $this->user->domain = trailingslashit( home_url() );
+                        $this->user->account_domain = $this->user->domain;
+                }
+                $this->user->locale = get_locale();
+
+                add_action( 'wp_head', 'wp_admin_bar_header' );
+                add_action( 'wp_head', 'wp_admin_body_style');
+
+                add_action( 'admin_head', 'wp_admin_bar_header' );
+                add_action( 'admin_head', 'wp_admin_body_style');
+
+                wp_enqueue_script( 'admin-bar' );
+                wp_enqueue_style( 'admin-bar' );
+
+                if ( is_super_admin() ) {
+                        wp_enqueue_style( 'super-admin-bar' );
+                }
+                
+                do_action( 'admin_bar_init' );
+        }
+
+        function add_menu( $args = array() ) {
+                $defaults = array(
+                        'title' => false,
+                        'href' => false,
+                        'parent' => false, // false for a root menu, pass the ID value for a submenu of that menu.
+                        'id' => false, // defaults to a sanitized title value.
+                        'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '' );
+                );
+
+                $r = wp_parse_args( $args, $defaults );
+                extract( $r, EXTR_SKIP );
+
+                if ( empty( $title ) )
+                        return false;
+
+                /* Make sure we have a valid ID */
+                if ( empty( $id ) )
+                        $id = esc_attr( sanitize_title( trim( $title ) ) );
+
+                if ( ! empty( $parent ) ) {
+                        /* Add the menu to the parent item */
+                        $child = array( 'id' => $id, 'title' => $title, 'href' => $href );
+
+                        if ( ! empty( $meta ) )
+                                $child['meta'] = $meta;
+
+                        $this->add_node( $parent, $this->menu, $child );
+                } else {
+                        /* Add the menu item */
+                        $this->menu->{$id} = array( 'title' => $title, 'href' => $href );
+
+                        if ( ! empty( $meta ) )
+                                $this->menu->{$id}['meta'] = $meta;
+                }
+        }
+
+        function remove_menu( $id ) {
+                return $this->remove_node( $id, $this->menu );
+        }
+
+        function render() {
+                ?>
+                <div id="wpadminbar" class="snap_nopreview no-grav">
+                        <div class="quicklinks">
+                                <ul>
+                                        <?php foreach ( (array) $this->menu as $id => $menu_item ) : ?>
+                                                <?php $this->recursive_render( $id, $menu_item ) ?>
+                                        <?php endforeach; ?>
+                                </ul>
+                        </div>
+
+                        <div id="adminbarsearch-wrap">
+                                <form action="<?php echo home_url(); ?>" method="get" id="adminbarsearch">
+                                        <input class="adminbar-input" name="s" id="adminbar-search" type="text" title="<?php esc_attr_e( 'Search' ); ?>" value="" maxlength="150" />
+                                        <button type="submit" class="adminbar-button"><span><?php _e('Search'); ?></span></button>
+                                </form>
+                        </div>
+                </div>
+
+                <?php
+                /* Wipe the menu, might reduce memory usage, but probably not. */
+                $this->menu = null;
+        }
+
+        /* Helpers */
+        function recursive_render( $id, &$menu_item ) { ?>
+                <?php $menuclass = ( ! empty( $menu_item['children'] ) ) ? 'menupop ' : ''; ?>
+
+                <li class="<?php echo $menuclass . "ab-$id" ?><?php
+                        if ( ! empty( $menu_item['meta']['class'] ) ) :
+                                echo ' ' . $menu_item['meta']['class'];
+                        endif;
+                ?>">
+                        <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;
+                        if ( ! empty( $menu_item['meta']['target'] ) ) :
+                                ?> target="<?php echo $menu_item['meta']['target']; ?>"<?php
+                        endif;
+                        
+                        ?>><?php
+                        
+                        if ( ! empty( $menuclass ) ) :
+                                ?><span><?php
+                        endif;
+                        
+                        echo $menu_item['title'];
+                        
+                        if ( ! empty( $menuclass ) ) :
+                                ?></span><?php
+                        endif;
+                        
+                        ?></a>
+
+                        <?php if ( ! empty( $menu_item['children'] ) ) : ?>
+                        <ul>
+                                <?php foreach ( $menu_item['children'] as $child_id => $child_menu_item ) : ?>
+                                        <?php $this->recursive_render( $child_id, $child_menu_item ); ?>
+                                <?php endforeach; ?>
+                        </ul>
+                        <?php endif; ?>
+
+                        <?php if ( ! empty( $menu_item['meta']['html'] ) ) : ?>
+                                <?php echo $menu_item['meta']['html']; ?>
+                        <?php endif; ?>
+                </li><?php
+        }
+
+        function add_node( $parent_id, &$menu, $child ) {
+                foreach( $menu as $id => &$menu_item ) {
+                        if ( $parent_id == $id ) {
+                                $menu->{$parent_id}['children']->{$child['id']} = $child;
+                                $child = null;
+                                return true;
+                        }
+
+                        if ( ! empty( $menu->{$id}['children'] ) )
+                                $this->add_node( $parent_id, $menu->{$id}['children'], $child );
+                }
+                
+                $child = null;
+
+                return false;
+        }
+
+        function add_menus() {
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_me_separator', 10 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_account_menu', 20 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_blogs_menu', 30 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 40 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_new_content_menu', 50 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_comments_menu', 60 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_appearance_menu', 70 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_updates_menu', 80 );
+                add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_shortlink_menu', 90 );
+
+                if ( is_multisite() && is_super_admin() && function_exists('wp_admin_bar_superadmin_settings_menu') )
+                        add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_superadmin_settings_menu', 1000 );
+
+                do_action('add_admin_bar_menus');
+        }
+
+        function remove_node( $id, &$menu ) {
+                foreach( $menu as $menu_item_id => &$menu_item ) {
+                        if ( $menu_item_id == $id ) {
+                                $menu_item = null;
+                                return true;
+                        }
+
+                        if ( ! empty( $menu->{$menu_item_id}['children'] ) )
+                                $this->remove_node( $id, $menu->{$menu_item_id}['children'] );
+                }
+
+                return false;
+        }
+
+        // TODO: Convert to a core feature for multisite or remove
+        function load_user_locale_translations() {
+                $this->need_to_change_locale = ( get_locale() != $this->user->locale );
+                if ( ! $this->need_to_change_locale )
+                        return;
+                /*
+                $this->previous_translations = get_translations_for_domain( 'default' );
+                $this->adminbar_locale_filter = lambda( '$_', '$GLOBALS["wp_admin_bar"]->user->locale;' );
+                unload_textdomain( 'default' );
+                add_filter( 'locale', $this->adminbar_locale_filter );
+                load_default_textdomain();
+                $this->changed_locale = true;
+                */
+        }
+
+        function unload_user_locale_translations() {
+                global $l10n;
+                if ( ! $this->changed_locale )
+                        return;
+                /*
+                remove_filter( 'locale', $this->adminbar_locale_filter );
+                $l10n['default'] = &$this->previous_translations;
+                */
+        }
+}
+?>
</ins></span></pre></div>
<a id="trunkwpincludesmsadminbarphpfromrev16091trunkwpincludesadminbaradminbarsuperadminphp"></a>
<div class="copfile"><h4>Copied: trunk/wp-includes/ms-admin-bar.php (from rev 16091, trunk/wp-includes/admin-bar/admin-bar-superadmin.php) (0 => 16098)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-admin-bar.php         (rev 0)
+++ trunk/wp-includes/ms-admin-bar.php        2010-10-30 06:40:04 UTC (rev 16098)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<?php
+
+/**
+ *
+ * Use the $wp_admin_bar global to add the super admin menu, providing admin options only visible to super admins.
+ */
+function wp_admin_bar_superadmin_settings_menu() {
+        global $wp_admin_bar, $current_blog, $current_user;
+
+        /* Add the main superadmin menu item */
+        $wp_admin_bar->add_menu( array( 'id' => 'superadmin', 'title' => '&mu;', 'href' => '', 'meta' => array( 'class' => 'ab-sadmin' ), ) );
+
+        /* Get the settings we need for the current site */
+        $matureaction = $current_blog->mature ? 'unmatureblog' : 'matureblog';
+        $maturetext_confirm = $current_blog->mature ?
+                sprintf(
+                        esc_attr__( 'Are you sure you want to unmark %s as mature?' ),
+                        $current_blog->domain
+                ) :
+                sprintf(
+                        esc_attr__( 'Are you sure you want to mark %s as mature?' ),
+                        $current_blog->domain
+                );
+
+        $suspendaction = $current_blog->spam ? 'unspamblog' : 'spamblog';
+        $suspendtext_confirm = $current_blog->spam ?
+                sprintf(
+                        esc_attr__( 'Are you sure you want to unsuspend site %s?' ),
+                        $current_blog->domain
+                ) :
+                sprintf(
+                        esc_attr__( 'Are you sure you want to suspend site %s?' ),
+                        $current_blog->domain
+                );
+                
+        $mature_url = network_admin_url( "edit.php?action=confirm&amp;action2={$matureaction}&amp;id={$current_blog->blog_id}&amp;msg=" . urlencode( $maturetext_confirm ) );
+        $suspend_url = network_admin_url( "edit.php?action=confirm&amp;action2={$suspendaction}&amp;id={$current_blog->blog_id}&amp;msg=" . urlencode( $suspendtext_confirm ) );
+
+        /* Add the submenu items to the Super Admin menu */
+        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Network Admin' ), 'href' => network_admin_url(), 'position' => 5, ) );
+        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Site Admin' ), 'href' => admin_url(), 'position' => 10, ) );
+        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Site Options' ), 'href' => network_admin_url( "site-info.php?id={$current_blog->blog_id}" ), 'position' => 30, ) );
+        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => ( $current_blog->mature ? __('Unmark as mature') : __('Mark as mature') ), 'href' => $mature_url, 'position' => 50, ) );
+        $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => ( $current_blog->spam ? __('Unsuspend site') : __('Suspend site') ), 'href' => $suspend_url, 'position' => 80, ) );
+}
+
+?>
</ins></span></pre>
</div>
</div>
</body>
</html>