Make WordPress Core

Changeset 25312


Ignore:
Timestamp:
09/10/2013 03:01:10 AM (10 years ago)
Author:
wonderboymusic
Message:

Move checks for post_type being an array inline. See [25291], [25292], #18614.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r25310 r25312  
    580580    // If there's a post type archive
    581581    if ( is_post_type_archive() ) {
    582         $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
     582        $post_type = get_query_var( 'post_type' );
     583        if ( is_array( $post_type ) )
     584            $post_type = reset( $post_type );
     585        $post_type_object = get_post_type_object( $post_type );
    583586        if ( ! $post_type_object->has_archive )
    584587            $title = post_type_archive_title( '', false );
     
    707710        return;
    708711
    709     $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
     712    $post_type = get_query_var( 'post_type' );
     713    if ( is_array( $post_type ) )
     714        $post_type = reset( $post_type );
     715
     716    $post_type_obj = get_post_type_object( $post_type );
    710717    $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
    711718
     
    16901697        }
    16911698    } elseif ( is_post_type_archive() ) {
    1692         $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
     1699        $post_type = get_query_var( 'post_type' );
     1700        if ( is_array( $post_type ) )
     1701            $post_type = reset( $post_type );
     1702
     1703        $post_type_obj = get_post_type_object( $post_type );
    16931704        $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
    16941705        $href = get_post_type_archive_feed_link( $post_type_obj->name );
  • trunk/src/wp-includes/post.php

    r25292 r25312  
    10581058function get_post_type_object( $post_type ) {
    10591059    global $wp_post_types;
    1060 
    1061     if ( is_array( $post_type ) )
    1062         $post_type = reset( $post_type );
    10631060
    10641061    if ( empty($wp_post_types[$post_type]) )
  • trunk/src/wp-includes/query.php

    r25311 r25312  
    30773077            }
    30783078        } elseif ( $this->is_post_type_archive ) {
    3079             $this->queried_object = get_post_type_object( $this->get('post_type') );
     3079            $post_type = $this->get( 'post_type' );
     3080            if ( is_array( $post_type ) )
     3081                $post_type = reset( $post_type );
     3082            $this->queried_object = get_post_type_object( $post_type );
    30803083        } elseif ( $this->is_posts_page ) {
    30813084            $page_for_posts = get_option('page_for_posts');
     
    31533156            return (bool) $this->is_post_type_archive;
    31543157
    3155         $post_type_object = get_post_type_object( $this->get( 'post_type' ) );
     3158        $post_type = $this->get( 'post_type' );
     3159        if ( is_array( $post_type ) )
     3160            $post_type = reset( $post_type );
     3161        $post_type_object = get_post_type_object( $post_type );
    31563162
    31573163        return in_array( $post_type_object->name, (array) $post_types );
  • trunk/src/wp-includes/template.php

    r25310 r25312  
    8181 */
    8282function get_post_type_archive_template() {
    83     $obj = get_post_type_object( get_query_var( 'post_type' ) );
     83    $post_type = get_query_var( 'post_type' );
     84    if ( is_array( $post_type ) )
     85        $post_type = reset( $post_type );
     86   
     87    $obj = get_post_type_object( $post_type );
    8488    if ( ! $obj->has_archive )
    8589        return '';
  • trunk/tests/phpunit/tests/query/conditionals.php

    r25292 r25312  
    700700        $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' );
    701701        $this->assertEquals( get_queried_object(), get_post_type_object( $cpt_name ) );
    702         $this->assertEquals( get_queried_object(), get_post_type_object( array( $cpt_name ) ) );
    703         $this->assertEquals( get_queried_object(), get_post_type_object( array( $cpt_name, 'post' ) ) );
    704702
    705703        add_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) );
     
    708706        $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' );
    709707        $this->assertEquals( get_queried_object(), get_post_type_object( 'post' ) );
    710         $this->assertEquals( get_queried_object(), get_post_type_object( array( 'post' ) ) );
    711         $this->assertEquals( get_queried_object(), get_post_type_object( array( 'post', $cpt_name ) ) );
    712708
    713709        remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) );
Note: See TracChangeset for help on using the changeset viewer.