Changeset 27755
- Timestamp:
- 03/26/2014 10:46:16 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-template.php
r27682 r27755 1010 1010 1011 1011 global $wp_query; 1012 if ( is_page() || is_attachment() || $wp_query->is_posts_page ) 1013 $current_page = $wp_query->get_queried_object_id(); 1012 if ( is_page() || is_attachment() || $wp_query->is_posts_page ) { 1013 $current_page = get_queried_object_id(); 1014 } elseif ( is_singular() ) { 1015 $queried_object = get_queried_object(); 1016 if ( is_post_type_hierarchical( $queried_object->post_type ) ) { 1017 $current_page = $queried_object->ID; 1018 } 1019 } 1020 1014 1021 $output .= walk_page_tree($pages, $r['depth'], $current_page, $r); 1015 1022 -
trunk/tests/phpunit/tests/post/getPages.php
r25975 r27755 212 212 $this->assertEqualSets( array( $page_1, $page_2, $page_4, $page_3 ), wp_list_pluck( $pages, 'ID' ) ); 213 213 } 214 215 function test_wp_list_pages_classes() { 216 $type = 'taco'; 217 register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) ); 218 219 $posts = $this->factory->post->create_many( 2, array( 'post_type' => $type ) ); 220 $post_id = reset( $posts ); 221 222 $this->go_to( "/?p=$post_id&post_type=$type" ); 223 224 $this->assertEquals( $post_id, get_queried_object_id() ); 225 226 $output = wp_list_pages( array( 227 'echo' => false, 228 'title_li' => '', 229 'post_type' => $type 230 ) ); 231 232 $this->assertNotEmpty( $output ); 233 $this->assertEquals( 2, substr_count( $output, 'class="page_item ' ) ); 234 $this->assertContains( 'current_page_item', $output ); 235 $this->assertEquals( 1, substr_count( $output, 'current_page_item' ) ); 236 237 _unregister_post_type( $type ); 238 } 214 239 }
Note: See TracChangeset
for help on using the changeset viewer.