Make WordPress Core

Ticket #12989: 12989.2.diff

File 12989.2.diff, 1.7 KB (added by scribu, 15 years ago)

Check 'any' post_type

  • wp-includes/post.php

     
    39903990 * @uses update_postmeta_cache()
    39913991 *
    39923992 * @param array $posts Array of Post objects
     3993 * @param string $post_type The post type of the posts in $posts
    39933994 */
    3994 function update_post_caches(&$posts) {
     3995function update_post_caches(&$posts, $post_type = 'post') {
    39953996        // No point in doing all this work if we didn't match any posts.
    39963997        if ( !$posts )
    39973998                return;
     
    39994000        update_post_cache($posts);
    40004001
    40014002        $post_ids = array();
     4003        foreach ( $posts as $post )
     4004                $post_ids[] = $post->ID;
    40024005
    4003         for ($i = 0; $i < count($posts); $i++)
    4004                 $post_ids[] = $posts[$i]->ID;
     4006        if ( empty($post_type) )
     4007                $post_type = 'post';
    40054008
    4006         update_object_term_cache($post_ids, 'post');
     4009        if ( !is_array($post_type) && 'any' != $post_type )
     4010                update_object_term_cache($post_ids, $post_type);
    40074011
    40084012        update_postmeta_cache($post_ids);
    40094013}
  • wp-includes/query.php

     
    16261626                if ( !isset($q['suppress_filters']) )
    16271627                        $q['suppress_filters'] = false;
    16281628
     1629                if ( !isset($q['cache_results']) )
     1630                        $q['cache_results'] = true;
     1631
    16291632                if ( !isset($q['post_type']) ) {
    16301633                        if ( $this->is_search )
    16311634                                $q['post_type'] = 'any';
     
    25042507                        $this->posts[$i] = sanitize_post($this->posts[$i], 'raw');
    25052508                }
    25062509
    2507                 update_post_caches($this->posts);
     2510                if ( $q['cache_results'] )
     2511                        update_post_caches($this->posts, $post_type);
    25082512
    25092513                if ($this->post_count > 0) {
    25102514                        $this->post = $this->posts[0];