Media: Improve filters that allow overriding slow media queries.
As a follow-up to [40382], this commit makes the following improvements: - Make the filter names more specific. - Fix the inline documentation (use `@param` instead of `@return). - Use `null ===` instead of `is_null` to avoid extra function calls. - Rename the `$has_audio` and `$has_video` variables now that they actually represent something slightly different. See #31071. git-svn-id: https://develop.svn.wordpress.org/trunk@40421 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5fcfb9b247
commit
11d450f47e
@ -3333,11 +3333,11 @@ function wp_enqueue_media( $args = array() ) {
|
|||||||
*
|
*
|
||||||
* @link https://core.trac.wordpress.org/ticket/31071
|
* @link https://core.trac.wordpress.org/ticket/31071
|
||||||
*
|
*
|
||||||
* @return bool|null Whether to show the button, or `null` for default behavior.
|
* @param bool|null Whether to show the button, or `null` for default behavior.
|
||||||
*/
|
*/
|
||||||
$has_audio = apply_filters( 'media_has_audio', null );
|
$show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', null );
|
||||||
if ( is_null( $has_audio ) ) {
|
if ( null === $show_audio_playlist ) {
|
||||||
$has_audio = $wpdb->get_var( "
|
$show_audio_playlist = $wpdb->get_var( "
|
||||||
SELECT ID
|
SELECT ID
|
||||||
FROM $wpdb->posts
|
FROM $wpdb->posts
|
||||||
WHERE post_type = 'attachment'
|
WHERE post_type = 'attachment'
|
||||||
@ -3358,11 +3358,11 @@ function wp_enqueue_media( $args = array() ) {
|
|||||||
*
|
*
|
||||||
* @link https://core.trac.wordpress.org/ticket/31071
|
* @link https://core.trac.wordpress.org/ticket/31071
|
||||||
*
|
*
|
||||||
* @return bool|null Whether to show the button, or `null` for default behavior.
|
* @param bool|null Whether to show the button, or `null` for default behavior.
|
||||||
*/
|
*/
|
||||||
$has_video = apply_filters( 'media_has_video', null );
|
$show_video_playlist = apply_filters( 'media_library_show_video_playlist', null );
|
||||||
if ( is_null( $has_video ) ) {
|
if ( null === $show_video_playlist ) {
|
||||||
$has_video = $wpdb->get_var( "
|
$show_video_playlist = $wpdb->get_var( "
|
||||||
SELECT ID
|
SELECT ID
|
||||||
FROM $wpdb->posts
|
FROM $wpdb->posts
|
||||||
WHERE post_type = 'attachment'
|
WHERE post_type = 'attachment'
|
||||||
@ -3383,11 +3383,11 @@ function wp_enqueue_media( $args = array() ) {
|
|||||||
*
|
*
|
||||||
* @link https://core.trac.wordpress.org/ticket/31071
|
* @link https://core.trac.wordpress.org/ticket/31071
|
||||||
*
|
*
|
||||||
* @return array|null An array of objects with `month` and `year`
|
* @param array|null An array of objects with `month` and `year`
|
||||||
* properties, or `null` (or any other non-array value)
|
* properties, or `null` (or any other non-array value)
|
||||||
* for default behavior.
|
* for default behavior.
|
||||||
*/
|
*/
|
||||||
$months = apply_filters( 'media_months', null );
|
$months = apply_filters( 'media_library_months_with_files', null );
|
||||||
if ( ! is_array( $months ) ) {
|
if ( ! is_array( $months ) ) {
|
||||||
$months = $wpdb->get_results( $wpdb->prepare( "
|
$months = $wpdb->get_results( $wpdb->prepare( "
|
||||||
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||||
@ -3414,14 +3414,14 @@ function wp_enqueue_media( $args = array() ) {
|
|||||||
),
|
),
|
||||||
'defaultProps' => $props,
|
'defaultProps' => $props,
|
||||||
'attachmentCounts' => array(
|
'attachmentCounts' => array(
|
||||||
'audio' => ( $has_audio ) ? 1 : 0,
|
'audio' => ( $show_audio_playlist ) ? 1 : 0,
|
||||||
'video' => ( $has_video ) ? 1 : 0
|
'video' => ( $show_video_playlist ) ? 1 : 0,
|
||||||
),
|
),
|
||||||
'embedExts' => $exts,
|
'embedExts' => $exts,
|
||||||
'embedMimes' => $ext_mimes,
|
'embedMimes' => $ext_mimes,
|
||||||
'contentWidth' => $content_width,
|
'contentWidth' => $content_width,
|
||||||
'months' => $months,
|
'months' => $months,
|
||||||
'mediaTrash' => MEDIA_TRASH ? 1 : 0
|
'mediaTrash' => MEDIA_TRASH ? 1 : 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
$post = null;
|
$post = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user