Make WordPress Core

Ticket #32264: 32264.patch

File 32264.patch, 1.2 KB (added by rhurling, 10 years ago)

Initial patch per johnbillion's suggestion

  • src/wp-includes/media.php

     
    29182918                }
    29192919        }
    29202920
    2921         $has_audio = $wpdb->get_var( "
    2922                 SELECT ID
    2923                 FROM $wpdb->posts
    2924                 WHERE post_type = 'attachment'
    2925                 AND post_mime_type LIKE 'audio%'
    2926                 LIMIT 1
    2927         " );
    2928         $has_video = $wpdb->get_var( "
    2929                 SELECT ID
    2930                 FROM $wpdb->posts
    2931                 WHERE post_type = 'attachment'
    2932                 AND post_mime_type LIKE 'video%'
    2933                 LIMIT 1
    2934         " );
     2921        if ( false === ( $has_audio = get_transient( 'has_audio' ) ) ) {
     2922                $has_audio = (bool) $wpdb->get_var( "
     2923                        SELECT ID
     2924                        FROM $wpdb->posts
     2925                        WHERE post_type = 'attachment'
     2926                        AND post_mime_type LIKE 'audio%'
     2927                        LIMIT 1
     2928                " );
     2929                set_transient( 'has_audio', $has_audio );
     2930        }
     2931        if ( false === ( $has_video = get_transient( 'has_video' ) ) ) {
     2932                $has_video = (bool) $wpdb->get_var( "
     2933                        SELECT ID
     2934                        FROM $wpdb->posts
     2935                        WHERE post_type = 'attachment'
     2936                        AND post_mime_type LIKE 'video%'
     2937                        LIMIT 1
     2938                " );
     2939                set_transient( 'has_video', $has_video );
     2940        }
    29352941        $months = $wpdb->get_results( $wpdb->prepare( "
    29362942                SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    29372943                FROM $wpdb->posts