Make WordPress Core


Ignore:
Timestamp:
03/27/2014 06:15:09 PM (11 years ago)
Author:
wonderboymusic
Message:

Move counting of attachments for audio/video to the backend, instead of using a reduce function in JS.

See #27554.

File:
1 edited

Legend:

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

    r27785 r27788  
    23812381    }
    23822382
     2383    $audio = $video = 0;
     2384    $counts = wp_count_attachments();
     2385    foreach ( $counts as $mime => $total ) {
     2386        if ( 0 === strpos( $mime, 'audio/' ) ) {
     2387            $audio += (int) $total;
     2388        } elseif ( 0 === strpos( $mime, 'video/' ) ) {
     2389            $video += (int) $total;
     2390        }
     2391    }
     2392
    23832393    $settings = array(
    23842394        'tabs'      => $tabs,
     
    23932403        ),
    23942404        'defaultProps' => $props,
    2395         'attachmentCounts' => wp_count_attachments(),
     2405        'attachmentCounts' => array(
     2406            'audio' => $audio,
     2407            'video' => $video
     2408        ),
    23962409        'embedExts'    => $exts,
    23972410        'embedMimes'   => $ext_mimes,
Note: See TracChangeset for help on using the changeset viewer.