Make WordPress Core

Ticket #19590: 19590.2.patch

File 19590.2.patch, 6.4 KB (added by SergeyBiryukov, 13 years ago)
  • wp-admin/includes/dashboard.php

     
    7575                wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
    7676
    7777        // QuickPress Widget
    78         if ( is_blog_admin() && current_user_can('edit_posts') )
     78        if ( is_blog_admin() && current_user_can( 'edit_posts' ) && post_type_exists( 'post' ) )
    7979                wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
    8080
    8181        // Recent Drafts
    82         if ( is_blog_admin() && current_user_can('edit_posts') )
     82        if ( is_blog_admin() && current_user_can( 'edit_posts' ) && post_type_exists( 'post' ) )
    8383                wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
    8484
    8585        // Primary feed (Dev Blog) Widget
     
    248248function wp_dashboard_right_now() {
    249249        global $wp_registered_sidebars;
    250250
    251         $num_posts = wp_count_posts( 'post' );
    252         $num_pages = wp_count_posts( 'page' );
     251        if ( post_type_exists( 'post' ) )
     252                $num_posts = wp_count_posts( 'post' );
    253253
    254         $num_cats  = wp_count_terms('category');
     254        if ( post_type_exists( 'page' ) )
     255                $num_pages = wp_count_posts( 'page' );
    255256
    256         $num_tags = wp_count_terms('post_tag');
     257        if ( taxonomy_exists( 'category' ) )
     258                $num_cats = wp_count_terms( 'category' );
    257259
     260        if ( taxonomy_exists( 'post_tag' ) )
     261                $num_tags = wp_count_terms( 'post_tag' );
     262
    258263        $num_comm = wp_count_comments( );
    259264
    260265        echo "\n\t".'<div class="table table_content">';
     
    262267        echo "\n\t".'<tr class="first">';
    263268
    264269        // Posts
    265         $num = number_format_i18n( $num_posts->publish );
    266         $text = _n( 'Post', 'Posts', intval($num_posts->publish) );
    267         if ( current_user_can( 'edit_posts' ) ) {
    268                 $num = "<a href='edit.php'>$num</a>";
    269                 $text = "<a href='edit.php'>$text</a>";
     270        if ( post_type_exists( 'post' ) ) {
     271                $num = number_format_i18n( $num_posts->publish );
     272                $text = _n( 'Post', 'Posts', intval($num_posts->publish) );
     273                if ( current_user_can( 'edit_posts' ) ) {
     274                        $num = "<a href='edit.php'>$num</a>";
     275                        $text = "<a href='edit.php'>$text</a>";
     276                }
     277                echo '<td class="first b b-posts">' . $num . '</td>';
     278                echo '<td class="t posts">' . $text . '</td>';
     279
     280                echo '</tr><tr>';
    270281        }
    271         echo '<td class="first b b-posts">' . $num . '</td>';
    272         echo '<td class="t posts">' . $text . '</td>';
    273 
    274         echo '</tr><tr>';
    275282        /* TODO: Show status breakdown on hover
    276283        if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can
    277284                $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( _n( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
     
    290297        */
    291298
    292299        // Pages
    293         $num = number_format_i18n( $num_pages->publish );
    294         $text = _n( 'Page', 'Pages', $num_pages->publish );
    295         if ( current_user_can( 'edit_pages' ) ) {
    296                 $num = "<a href='edit.php?post_type=page'>$num</a>";
    297                 $text = "<a href='edit.php?post_type=page'>$text</a>";
     300        if ( post_type_exists( 'page' ) ) {
     301                $num = number_format_i18n( $num_pages->publish );
     302                $text = _n( 'Page', 'Pages', $num_pages->publish );
     303                if ( current_user_can( 'edit_pages' ) ) {
     304                        $num = "<a href='edit.php?post_type=page'>$num</a>";
     305                        $text = "<a href='edit.php?post_type=page'>$text</a>";
     306                }
     307                echo '<td class="first b b_pages">' . $num . '</td>';
     308                echo '<td class="t pages">' . $text . '</td>';
     309
     310                echo '</tr><tr>';
    298311        }
    299         echo '<td class="first b b_pages">' . $num . '</td>';
    300         echo '<td class="t pages">' . $text . '</td>';
    301312
    302         echo '</tr><tr>';
     313        // Categories
     314        if ( taxonomy_exists( 'category' ) ) {
     315                $num = number_format_i18n( $num_cats );
     316                $text = _n( 'Category', 'Categories', $num_cats );
     317                if ( current_user_can( 'manage_categories' ) ) {
     318                        $num = "<a href='edit-tags.php?taxonomy=category'>$num</a>";
     319                        $text = "<a href='edit-tags.php?taxonomy=category'>$text</a>";
     320                }
     321                echo '<td class="first b b-cats">' . $num . '</td>';
     322                echo '<td class="t cats">' . $text . '</td>';
    303323
    304         // Categories
    305         $num = number_format_i18n( $num_cats );
    306         $text = _n( 'Category', 'Categories', $num_cats );
    307         if ( current_user_can( 'manage_categories' ) ) {
    308                 $num = "<a href='edit-tags.php?taxonomy=category'>$num</a>";
    309                 $text = "<a href='edit-tags.php?taxonomy=category'>$text</a>";
     324                echo '</tr><tr>';
    310325        }
    311         echo '<td class="first b b-cats">' . $num . '</td>';
    312         echo '<td class="t cats">' . $text . '</td>';
    313326
    314         echo '</tr><tr>';
     327        // Tags
     328        if ( taxonomy_exists( 'post_tag' ) ) {
     329                $num = number_format_i18n( $num_tags );
     330                $text = _n( 'Tag', 'Tags', $num_tags );
     331                if ( current_user_can( 'manage_categories' ) ) {
     332                        $num = "<a href='edit-tags.php'>$num</a>";
     333                        $text = "<a href='edit-tags.php'>$text</a>";
     334                }
     335                echo '<td class="first b b-tags">' . $num . '</td>';
     336                echo '<td class="t tags">' . $text . '</td>';
    315337
    316         // Tags
    317         $num = number_format_i18n( $num_tags );
    318         $text = _n( 'Tag', 'Tags', $num_tags );
    319         if ( current_user_can( 'manage_categories' ) ) {
    320                 $num = "<a href='edit-tags.php'>$num</a>";
    321                 $text = "<a href='edit-tags.php'>$text</a>";
     338                echo "</tr>";
    322339        }
    323         echo '<td class="first b b-tags">' . $num . '</td>';
    324         echo '<td class="t tags">' . $text . '</td>';
    325340
    326         echo "</tr>";
    327341        do_action('right_now_content_table_end');
    328342        echo "\n\t</table>\n\t</div>";
    329343
     
    546560
    547561                <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>
    548562
     563                <?php if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) : ?>
    549564                <h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
    550565                <div class="input-text-wrap">
    551566                        <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
    552567                </div>
     568                <?php endif; ?>
    553569
    554570                <p class="submit">
    555571                        <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
  • wp-includes/taxonomy.php

     
    16511651 *
    16521652 * @param string $taxonomy Taxonomy name
    16531653 * @param array|string $args Overwrite defaults. See get_terms()
    1654  * @return int How many terms are in $taxonomy
     1654 * @return int|WP_Error How many terms are in $taxonomy. WP_Error if $taxonomy does not exist.
    16551655 */
    16561656function wp_count_terms( $taxonomy, $args = array() ) {
    16571657        $defaults = array('hide_empty' => false);