Make WordPress Core

Changeset 11131


Ignore:
Timestamp:
04/29/2009 11:30:07 PM (15 years ago)
Author:
azaozz
Message:

Hide widget count when no sidebars defined, props scribu, fixes #8035

File:
1 edited

Legend:

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

    r11109 r11131  
    195195
    196196function wp_dashboard_right_now() {
     197    global $wp_registered_sidebars;
     198
    197199    $num_posts = wp_count_posts( 'post' );
    198200    $num_pages = wp_count_posts( 'page' );
     
    316318    echo "\n\t".'<div class="versions">';
    317319    $ct = current_theme_info();
    318     $sidebars_widgets = wp_get_sidebars_widgets();
    319     $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 );
    320     $num = number_format_i18n( $num_widgets );
    321 
     320   
    322321    echo "\n\t<p>";
    323     if ( current_user_can( 'switch_themes' ) ) {
    324         echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
    325         printf(_n('Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $ct->title, $num);
     322    if ( !empty($wp_registered_sidebars) ) {
     323        $sidebars_widgets = wp_get_sidebars_widgets();
     324        $num_widgets = 0;
     325        foreach ( (array) $sidebars_widgets as $k => $v ) {
     326            if ( 'wp_inactive_widgets' == $k )
     327                continue;
     328            if ( is_array($v) )
     329                $num_widgets = $num_widgets + count($v);
     330        }
     331        $num = number_format_i18n( $num_widgets );
     332
     333        if ( current_user_can( 'switch_themes' ) ) {
     334            echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
     335            printf(_n('Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $ct->title, $num);
     336        } else {
     337            printf(_n('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $ct->title, $num);
     338        }
    326339    } else {
    327         printf(_n('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $ct->title, $num);
    328     }
    329 
     340        if ( current_user_can( 'switch_themes' ) ) {
     341            echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
     342            printf('Theme <span class="b"><a href="themes.php">%1$s</a></span>', $ct->title);
     343        } else {
     344            printf('Theme <span class="b">%1$s</span>', $ct->title);
     345        }
     346    }
    330347    echo '</p>';
    331348
Note: See TracChangeset for help on using the changeset viewer.