Remove some unnecessary abstraction introduced in [28191]. See #27985.
Built from https://develop.svn.wordpress.org/trunk@28194 git-svn-id: http://core.svn.wordpress.org/trunk@28024 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
46bdcce0eb
commit
ab041987d3
|
@ -2656,7 +2656,7 @@ function wp_enqueue_media( $args = array() ) {
|
|||
if ( did_action( 'wp_enqueue_media' ) )
|
||||
return;
|
||||
|
||||
global $content_width;
|
||||
global $content_width, $wpdb;
|
||||
|
||||
$defaults = array(
|
||||
'post' => null,
|
||||
|
@ -2695,6 +2695,21 @@ function wp_enqueue_media( $args = array() ) {
|
|||
}
|
||||
}
|
||||
|
||||
$has_audio = $wpdb->get_var( "
|
||||
SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = 'attachment'
|
||||
AND post_mime_type LIKE 'audio%'
|
||||
LIMIT 1
|
||||
" );
|
||||
$has_video = $wpdb->get_var( "
|
||||
SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = 'attachment'
|
||||
AND post_mime_type LIKE 'video%'
|
||||
LIMIT 1
|
||||
" );
|
||||
|
||||
$settings = array(
|
||||
'tabs' => $tabs,
|
||||
'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ),
|
||||
|
@ -2709,8 +2724,8 @@ function wp_enqueue_media( $args = array() ) {
|
|||
),
|
||||
'defaultProps' => $props,
|
||||
'attachmentCounts' => array(
|
||||
'audio' => wp_has_mime_type_attachments( 'audio' ) ? 1 : 0,
|
||||
'video' => wp_has_mime_type_attachments( 'video' ) ? 1 : 0
|
||||
'audio' => ( $has_audio ) ? 1 : 0,
|
||||
'video' => ( $has_video ) ? 1 : 0
|
||||
),
|
||||
'embedExts' => $exts,
|
||||
'embedMimes' => $ext_mimes,
|
||||
|
|
|
@ -2291,23 +2291,6 @@ function wp_count_attachments( $mime_type = '' ) {
|
|||
return apply_filters( 'wp_count_attachments', (object) $counts, $mime_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if at least one attachment of a particular mime-type has been uploaded
|
||||
*
|
||||
* @global wpdb $wpdb
|
||||
*
|
||||
* @since 3.9.1
|
||||
*
|
||||
* @param string $mime_type The mime-type string to check.
|
||||
*
|
||||
* @return int|null If exist, the post ID of the first found attachment.
|
||||
*/
|
||||
function wp_has_mime_type_attachments( $mime_type ) {
|
||||
global $wpdb;
|
||||
$sql = sprintf( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE '%s%%' LIMIT 1", like_escape( $mime_type ) );
|
||||
return $wpdb->get_var( $sql );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default post mime types
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue