WordPress.org

Make WordPress Core

Ticket #18067: post-thumbnail-template.php.diff

File post-thumbnail-template.php.diff, 944 bytes (added by TheDeadMedic, 7 years ago)
  • post-thumbnail-template.php

     
    5050/**
    5151 * Update cache for thumbnails in the current loop
    5252 *
    53  * @sicne 3.2
     53 * @since 3.2
     54 *
     55 * @param object $wp_query An instance of WP_Query with posts queried (optional)
    5456 */
    55 function update_post_thumbnail_cache() {
    56         global $wp_query;
     57function update_post_thumbnail_cache( $wp_query = null ) {
     58        if ( ! is_object( $wp_query ) || ! is_a( $wp_query, 'WP_Query' ) )
     59                $wp_query =& $GLOBALS['wp_query'];
    5760
    5861        if ( $wp_query->thumbnails_cached )
    5962                return;
     
    6467                        $thumb_ids[] = $id;
    6568        }
    6669
     70        // filter out null/zero values (we may not need to query *at all*)
     71        $thumb_ids = array_filter( $thumb_ids );
     72
    6773        if ( ! empty ( $thumb_ids ) ) {
    6874                get_posts( array(
    6975                                'update_post_term_cache' => false,