Changeset 39599
- Timestamp:
- 12/14/2016 03:42:58 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-template.php
r38951 r39599 1632 1632 */ 1633 1633 function is_page_template( $template = '' ) { 1634 if ( ! is_singular() ) { 1635 return false; 1636 } 1637 1634 1638 $page_template = get_page_template_slug( get_queried_object_id() ); 1635 1639 -
trunk/tests/phpunit/tests/query/conditionals.php
r39095 r39599 1075 1075 1076 1076 /** 1077 * @ticket 39211 1078 */ 1079 function test_is_page_template_not_singular() { 1080 global $wpdb; 1081 1082 // We need a non-post that shares an ID with a post assigned a template. 1083 $user_id = self::factory()->user->create(); 1084 if ( ! get_post( $user_id ) ) { 1085 $post_id = self::factory()->post->create( array( 'post_type' => 'post' ) ); 1086 $wpdb->update( $wpdb->posts, array( 'ID' => $user_id ), array( 'ID' => $post_id ), array( '%d' ) ); 1087 } 1088 1089 update_post_meta( $user_id, '_wp_page_template', 'example.php' ); 1090 1091 // Verify that the post correctly reports having a template. 1092 $this->go_to( get_post_permalink( $user_id ) ); 1093 $this->assertInstanceOf( 'WP_Post', get_queried_object() ); 1094 $this->assertTrue( is_page_template( 'example.php' ) ); 1095 1096 // Verify that the non-post with a matching ID does not report having a template. 1097 $this->go_to( get_author_posts_url( $user_id ) ); 1098 $this->assertInstanceOf( 'WP_User', get_queried_object() ); 1099 $this->assertFalse( is_page_template( 'example.php' ) ); 1100 } 1101 1102 /** 1077 1103 * @ticket 35902 1078 1104 */
Note: See TracChangeset
for help on using the changeset viewer.