Make WordPress Core

Changeset 16237


Ignore:
Timestamp:
11/08/2010 05:31:00 PM (13 years ago)
Author:
ryan
Message:

Add the former contents of ms-admin.php to a right now widget for the network admin. see #14435

File:
1 edited

Legend:

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

    r16163 r16237  
    2929    if ( is_blog_admin() && current_user_can('edit_posts') )
    3030        wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
     31
     32    if ( is_network_admin() )
     33        wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
    3134
    3235    // Recent Comments Widget
     
    147150        $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
    148151    }
    149     if ( is_user_admin() )
     152   
     153    if ( is_blog_admin () )
     154        $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
     155    else if (is_network_admin() )
     156        $side_widgets = array('dashboard_primary', 'dashboard_secondary');
     157    else
    150158        $side_widgets = array();
    151     else
    152         $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
     159
    153160    $location = 'normal';
    154161    if ( in_array($widget_id, $side_widgets) )
     
    401408    do_action( 'rightnow_end' );
    402409    do_action( 'activity_box_end' );
     410}
     411
     412function wp_network_dashboard_right_now() {
     413    $actions = array();
     414    if ( current_user_can('create_sites') )
     415        $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>';
     416    if ( current_user_can('create_users') )
     417        $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
     418
     419    $c_users = get_user_count();
     420    $c_blogs = get_blog_count();
     421
     422    $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
     423    $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
     424   
     425    $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
     426
     427    if ( $actions ) {
     428        echo '<ul class="subsubsub">';
     429        foreach ( $action as $class => $action ) {
     430             $actions[ $class ] = "\t<li class='$class'>$action";
     431        }
     432        echo implode( " |</li>\n", $actions ) . "</li>\n";
     433        echo '</ul>';
     434    }
     435?>
     436    <br class="clear" />
     437
     438    <p class="youhave"><?php echo $sentence; ?></p>
     439    <?php do_action( 'wpmuadminresult', '' ); ?>
     440
     441    <form name="searchform" action="ms-users.php" method="get">
     442        <p>
     443            <input type="hidden" name="action" value="users" />
     444            <input type="text" name="s" value="" size="17" />
     445            <input class="button" type="submit" name="submit" value="<?php esc_attr_e( 'Search Users' ); ?>" />
     446        </p>
     447    </form>
     448
     449    <form name="searchform" action="ms-sites.php" method="get">
     450        <p>
     451            <input type="hidden" name="action" value="blogs" />
     452            <input type="hidden" name="searchaction" value="name" />
     453            <input type="text" name="s" value="" size="17" />
     454            <input class="button" type="submit" name="blog_name" value="<?php esc_attr_e( 'Search Sites' ); ?>" />
     455        </p>
     456    </form>
     457<?php
     458    do_action( 'mu_rightnow_end' );
     459    do_action( 'mu_activity_box_end' );
    403460}
    404461
Note: See TracChangeset for help on using the changeset viewer.