<!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>[15878] trunk/wp-admin: Dashboard widgets in the network admin.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15878">15878</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-10-21 10:06:17 +0000 (Thu, 21 Oct 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Dashboard widgets in the network admin. props PeteMall. see <a href="http://trac.wordpress.org/ticket/15163">#15163</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesdashboardphp">trunk/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunkwpadminnetworkindexphp">trunk/wp-admin/network/index.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpadminnetworkindexextraphp">trunk/wp-admin/network/index-extra.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesdashboardphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/dashboard.php (15877 => 15878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/dashboard.php        2010-10-20 22:44:15 UTC (rev 15877)
+++ trunk/wp-admin/includes/dashboard.php        2010-10-21 10:06:17 UTC (rev 15878)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // WP Plugins Widget
</span><del>-        if ( is_blog_admin() && current_user_can( 'install_plugins' ) )
</del><ins>+        if ( ( is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) ) )
</ins><span class="cx">                 wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
</span><span class="cx">
</span><span class="cx">         // QuickPress Widget
</span><span class="lines">@@ -100,10 +100,14 @@
</span><span class="cx">         wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
</span><span class="cx">
</span><span class="cx">         // Hook to register new widgets
</span><del>-        do_action( 'wp_dashboard_setup' );
-
</del><span class="cx">         // Filter widget order
</span><del>-        $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
</del><ins>+        if ( is_network_admin() ) {
+                do_action( 'wp_network_dashboard_setup' );
+                $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
+        } else {
+                do_action( 'wp_dashboard_setup' );
+                $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
+        }
</ins><span class="cx">
</span><span class="cx">         foreach ( $dashboard_widgets as $widget_id ) {
</span><span class="cx">                 $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
</span></span></pre></div>
<a id="trunkwpadminnetworkindexextraphp"></a>
<div class="addfile"><h4>Added: trunk/wp-admin/network/index-extra.php (0 => 15878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/index-extra.php         (rev 0)
+++ trunk/wp-admin/network/index-extra.php        2010-10-21 10:06:17 UTC (rev 15878)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+<?php
+
+require_once( './admin.php' );
+
+require( '../index-extra.php' );
</ins></span></pre></div>
<a id="trunkwpadminnetworkindexphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/index.php (15877 => 15878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/index.php        2010-10-20 22:44:15 UTC (rev 15877)
+++ trunk/wp-admin/network/index.php        2010-10-21 10:06:17 UTC (rev 15878)
</span><span class="lines">@@ -7,15 +7,19 @@
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+/** Load WordPress Bootstrap */
</ins><span class="cx"> require_once( './admin.php' );
</span><span class="cx">
</span><ins>+/** Load WordPress dashboard API */
+require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
+
</ins><span class="cx"> if ( !is_multisite() )
</span><span class="cx">         wp_die( __( 'Multisite support is not enabled.' ) );
</span><span class="cx">
</span><span class="cx"> if ( ! current_user_can( 'manage_network' ) )
</span><span class="cx">         wp_die( __( 'You do not have permission to access this page.' ) );
</span><span class="cx">
</span><del>-$title = __( 'Network Admin' );
</del><ins>+$title = __( 'Network Dashboard' );
</ins><span class="cx"> $parent_file = 'index.php';
</span><span class="cx">
</span><span class="cx"> add_contextual_help($current_screen,
</span><span class="lines">@@ -28,49 +32,29 @@
</span><span class="cx">         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
</span><span class="cx"> );
</span><span class="cx">
</span><del>-require_once( '../admin-header.php' );
</del><ins>+wp_dashboard_setup();
</ins><span class="cx">
</span><del>-$c_users = get_user_count();
-$c_blogs = get_blog_count();
</del><ins>+wp_enqueue_script( 'dashboard' );
+wp_admin_css( 'dashboard' );
+add_thickbox();
</ins><span class="cx">
</span><del>-$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
-$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
</del><ins>+add_screen_option('layout_columns', array('max' => 4, 'default' => 2) );
</ins><span class="cx">
</span><del>-$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
</del><ins>+require_once( '../admin-header.php' );
+
</ins><span class="cx"> ?>
</span><span class="cx">
</span><span class="cx"> <div class="wrap">
</span><del>-        <?php screen_icon(); ?>
-        <h2><?php echo esc_html( $title ); ?></h2>
</del><ins>+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
</ins><span class="cx">
</span><del>-        <ul class="subsubsub">
-        <li><a href="sites.php#form-add-site"><?php _e( 'Create a New Site' ); ?></a> |</li>
-        <li><a href="users.php#form-add-user"><?php _e( 'Create a New User' ); ?></a></li>
-        </ul>
-        <br class="clear" />
</del><ins>+<div id="dashboard-widgets-wrap">
</ins><span class="cx">
</span><del>-        <p class="youhave"><?php echo $sentence; ?></p>
-        <?php do_action( 'wpmuadminresult', '' ); ?>
</del><ins>+<?php wp_dashboard(); ?>
</ins><span class="cx">
</span><del>-        <form name="searchform" action="users.php" method="get">
-                <p>
-                        <input type="hidden" name="action" value="users" />
-                        <input type="text" name="s" value="" size="17" />
-                        <input class="button" type="submit" name="submit" value="<?php esc_attr_e( 'Search Users' ); ?>" />
-                </p>
-        </form>
</del><ins>+<div class="clear"></div>
+</div><!-- dashboard-widgets-wrap -->
</ins><span class="cx">
</span><del>-        <form name="searchform" action="sites.php" method="get">
-                <p>
-                        <input type="hidden" name="action" value="blogs" />
-                        <input type="hidden" name="searchaction" value="name" />
-                        <input type="text" name="s" value="" size="17" />
-                        <input class="button" type="submit" name="blog_name" value="<?php esc_attr_e( 'Search Sites' ); ?>" />
-                </p>
-        </form>
</del><ins>+</div><!-- wrap -->
</ins><span class="cx">
</span><del>-        <?php do_action( 'mu_rightnow_end' ); ?>
-        <?php do_action( 'mu_activity_box_end' ); ?>
-</div>
-
</del><span class="cx"> <?php include( '../admin-footer.php' ); ?>
</span></span></pre>
</div>
</div>
</body>
</html>