[wp-trac] [WordPress Trac] #19949: Make update_post_thumbnail_cache() work for any instance

WordPress Trac wp-trac at lists.automattic.com
Tue Apr 17 03:51:39 UTC 2012


#19949: Make update_post_thumbnail_cache() work for any instance
-------------------------+------------------
 Reporter:  scribu       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  3.4
Component:  Performance  |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------

Comment (by nacin):

 Just a thought:

 {{{
 class Nacin_Cache_Thumbnails_for_Queries {
    public $loops = array();
    function __construct() {
       add_action( 'loop_start', array( $this, 'loop_start' ) );
       add_action( 'loop_end', array( $this, 'loop_end' ) );
       add_action( 'begin_fetch_post_thumbnail_html', array( $this,
 'fetch_thumbnail' ) );
    }
    function loop_start( $query ) {
       array_push( $this->loops, $query );
    }
    function loop_end() {
       array_pop( $this->loops );
    }
    function fetch_thumbnail() {
        $query = end( $this->loops );
        update_post_thumbnail_cache( $query );
    }
 }
 new Nacin_Cache_Thumbnails_for_Queries;
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19949#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list