Make WordPress Core

Ticket #20345: 20345.3.patch

File 20345.3.patch, 2.4 KB (added by SergeyBiryukov, 13 years ago)
  • wp-admin/includes/class-wp-media-list-table.php

     
    130130                $posts_columns['icon'] = '';
    131131                /* translators: column name */
    132132                $posts_columns['title'] = _x( 'File', 'column name' );
    133                 $posts_columns['author'] = __( 'Author' );
    134                 //$posts_columns['tags'] = _x( 'Tags', 'column name' );
     133                if ( _get_user_count() > 1 )
     134                        $posts_columns['author'] = __( 'Author' );
    135135                /* translators: column name */
    136136                if ( !$this->detached ) {
    137137                        $posts_columns['parent'] = _x( 'Attached to', 'column name' );
  • wp-admin/includes/class-wp-posts-list-table.php

     
    266266                /* translators: manage posts column name */
    267267                $posts_columns['title'] = _x( 'Title', 'column name' );
    268268
    269                 if ( post_type_supports( $post_type, 'author' ) )
     269                $total_users = isset( $_POST['total_users'] ) ? (int) $_POST['total_users'] : _get_user_count();
     270                if ( post_type_supports( $post_type, 'author' ) && $total_users > 1 )
    270271                        $posts_columns['author'] = __( 'Author' );
    271272
    272273                if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) )
     
    10431044                        } ?>
    10441045                        <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
    10451046                        <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
     1047                        <input type="hidden" name="total_users" value="<?php echo esc_attr( _get_user_count() ); ?>" />
    10461048                        <span class="error" style="display:none"></span>
    10471049                        <br class="clear" />
    10481050                </p>
  • wp-includes/functions.php

     
    36933693        }
    36943694}
    36953695
     3696/**
     3697 * Retrieve the total number of users in the DB.
     3698 *
     3699 * @since 3.4.0
     3700 * @access private
     3701 *
     3702 * @return int Number of users.
     3703 */
     3704function _get_user_count() {
     3705        global $wpdb;
     3706
     3707        if ( ! $user_count = wp_cache_get( 'user_count', 'users' ) ) {
     3708                $user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" );
     3709                wp_cache_add( 'user_count', $user_count, 'users' );
     3710        }
     3711
     3712        return $user_count;
     3713}