Make WordPress Core


Ignore:
Timestamp:
04/23/2014 10:04:03 PM (12 years ago)
Author:
johnbillion
Message:

Avoid an expensive attachment counting query on the post editing screen. See #27985, for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r28182 r28191  
    26962696    }
    26972697
    2698     $audio = $video = 0;
    2699     $counts = (array) wp_count_attachments();
    2700     foreach ( $counts as $mime => $total ) {
    2701         if ( 0 === strpos( $mime, 'audio/' ) ) {
    2702             $audio += (int) $total;
    2703         } elseif ( 0 === strpos( $mime, 'video/' ) ) {
    2704             $video += (int) $total;
    2705         }
    2706     }
    2707 
    27082698    $settings = array(
    27092699        'tabs'      => $tabs,
     
    27202710        'defaultProps' => $props,
    27212711        'attachmentCounts' => array(
    2722             'audio' => $audio,
    2723             'video' => $video
     2712            'audio' => wp_has_mime_type_attachments( 'audio' ) ? 1 : 0,
     2713            'video' => wp_has_mime_type_attachments( 'video' ) ? 1 : 0
    27242714        ),
    27252715        'embedExts'    => $exts,
Note: See TracChangeset for help on using the changeset viewer.