Changeset 25312
- Timestamp:
- 09/10/2013 03:01:10 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
src/wp-includes/general-template.php (modified) (3 diffs)
-
src/wp-includes/post.php (modified) (1 diff)
-
src/wp-includes/query.php (modified) (2 diffs)
-
src/wp-includes/template.php (modified) (1 diff)
-
tests/phpunit/tests/query/conditionals.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r25310 r25312 580 580 // If there's a post type archive 581 581 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 ); 583 586 if ( ! $post_type_object->has_archive ) 584 587 $title = post_type_archive_title( '', false ); … … 707 710 return; 708 711 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 ); 710 717 $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name ); 711 718 … … 1690 1697 } 1691 1698 } 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 ); 1693 1704 $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name ); 1694 1705 $href = get_post_type_archive_feed_link( $post_type_obj->name ); -
trunk/src/wp-includes/post.php
r25292 r25312 1058 1058 function get_post_type_object( $post_type ) { 1059 1059 global $wp_post_types; 1060 1061 if ( is_array( $post_type ) )1062 $post_type = reset( $post_type );1063 1060 1064 1061 if ( empty($wp_post_types[$post_type]) ) -
trunk/src/wp-includes/query.php
r25311 r25312 3077 3077 } 3078 3078 } 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 ); 3080 3083 } elseif ( $this->is_posts_page ) { 3081 3084 $page_for_posts = get_option('page_for_posts'); … … 3153 3156 return (bool) $this->is_post_type_archive; 3154 3157 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 ); 3156 3162 3157 3163 return in_array( $post_type_object->name, (array) $post_types ); -
trunk/src/wp-includes/template.php
r25310 r25312 81 81 */ 82 82 function 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 ); 84 88 if ( ! $obj->has_archive ) 85 89 return ''; -
trunk/tests/phpunit/tests/query/conditionals.php
r25292 r25312 700 700 $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); 701 701 $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' ) ) );704 702 705 703 add_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) ); … … 708 706 $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); 709 707 $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 ) ) );712 708 713 709 remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) );
Note: See TracChangeset
for help on using the changeset viewer.