Changeset 25292
- Timestamp:
- 09/06/2013 11:38:51 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r25271 r25292 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 ); 1060 1063 1061 1064 if ( empty($wp_post_types[$post_type]) ) -
trunk/src/wp-includes/template-loader.php
r25291 r25292 27 27 if ( is_404() && $template = get_404_template() ) : 28 28 elseif ( is_search() && $template = get_search_template() ) : 29 elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :30 elseif ( is_tax() && $template = get_taxonomy_template() ) :31 29 elseif ( is_front_page() && $template = get_front_page_template() ) : 32 30 elseif ( is_home() && $template = get_home_template() ) : 31 elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) : 32 elseif ( is_tax() && $template = get_taxonomy_template() ) : 33 33 elseif ( is_attachment() && $template = get_attachment_template() ) : 34 34 remove_filter('the_content', 'prepend_attachment'); -
trunk/tests/phpunit/tests/query/conditionals.php
r25291 r25292 684 684 ) ); 685 685 } 686 687 function test_post_type_array() { 688 delete_option( 'rewrite_rules' ); 689 690 $cpt_name = 'thearray'; 691 register_post_type( $cpt_name, array( 692 'taxonomies' => array( 'post_tag', 'category' ), 693 'rewrite' => true, 694 'has_archive' => true, 695 'public' => true 696 ) ); 697 $this->factory->post->create( array( 'post_type' => $cpt_name ) ); 698 699 $this->go_to( "/$cpt_name/" ); 700 $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); 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 705 add_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) ); 706 707 $this->go_to( "/$cpt_name/" ); 708 $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); 709 $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 713 remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) ); 714 } 715 716 function pre_get_posts_with_type_array( &$query ) { 717 $query->set( 'post_type', array( 'post', 'thearray' ) ); 718 } 686 719 }
Note: See TracChangeset
for help on using the changeset viewer.