Changeset 31730
- Timestamp:
- 03/11/2015 08:45:17 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-posts-list-table.php
r31513 r31730 87 87 } 88 88 89 /** 90 * Sets whether the table layout should be hierarchical or not. 91 * 92 * @since 4.2.0 93 * 94 * @param bool $display Whether the table layout should be hierarchical. 95 */ 96 public function set_hierarchical_display( $display ) { 97 $this->hierarchical_display = $display; 98 } 99 89 100 public function ajax_user_can() { 90 101 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); … … 96 107 $avail_post_stati = wp_edit_posts_query(); 97 108 98 $this-> hierarchical_display =( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );109 $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] ); 99 110 100 111 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; … … 479 490 $start = ( $pagenum - 1 ) * $per_page; 480 491 $end = $start + $per_page; 492 $to_display = array(); 481 493 482 494 foreach ( $pages as $page ) { … … 485 497 486 498 if ( $count >= $start ) { 487 echo "\t"; 488 $this->single_row( $page, $level ); 499 $to_display[$page->ID] = $level; 489 500 } 490 501 … … 492 503 493 504 if ( isset( $children_pages ) ) 494 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );505 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); 495 506 } 496 507 … … 503 514 504 515 if ( $count >= $start ) { 505 echo "\t"; 506 $this->single_row( $op, 0 ); 516 $to_display[$op->ID] = 0; 507 517 } 508 518 … … 510 520 } 511 521 } 522 } 523 524 $ids = array_keys( $to_display ); 525 _prime_post_caches( $ids ); 526 527 if ( ! isset( $GLOBALS['post'] ) ) { 528 $GLOBALS['post'] = array_shift( $ids ); 529 } 530 531 foreach ( $to_display as $page_id => $level ) { 532 echo "\t"; 533 $this->single_row( $page_id, $level ); 512 534 } 513 535 } … … 518 540 * 519 541 * @since 3.1.0 (Standalone function exists since 2.6.0) 542 * @since 4.2.0 Added the `$to_display` parameter. 520 543 * 521 544 * @param array $children_pages … … 525 548 * @param int $pagenum 526 549 * @param int $per_page 550 * @param array $to_display list of pages to be displayed 527 551 */ 528 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {552 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { 529 553 530 554 if ( ! isset( $children_pages[$parent] ) ) … … 544 568 $my_parent = $page->post_parent; 545 569 while ( $my_parent ) { 546 $my_parent = get_post( $my_parent ); 570 // Get the ID from the list or the attribute if my_parent is an object 571 $parent_id = $my_parent; 572 if ( is_object( $my_parent ) ) { 573 $parent_id = $my_parent->ID; 574 } 575 576 $my_parent = get_post( $parent_id ); 547 577 $my_parents[] = $my_parent; 548 578 if ( !$my_parent->post_parent ) … … 552 582 $num_parents = count( $my_parents ); 553 583 while ( $my_parent = array_pop( $my_parents ) ) { 554 echo "\t"; 555 $this->single_row( $my_parent, $level - $num_parents ); 584 $to_display[$my_parent->ID] = $level - $num_parents; 556 585 $num_parents--; 557 586 } … … 559 588 560 589 if ( $count >= $start ) { 561 echo "\t"; 562 $this->single_row( $page, $level ); 590 $to_display[$page->ID] = $level; 563 591 } 564 592 565 593 $count++; 566 594 567 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );595 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); 568 596 } 569 597 … … 580 608 581 609 $global_post = get_post(); 610 611 $post = get_post( $post ); 612 582 613 $GLOBALS['post'] = $post; 583 614 setup_postdata( $post ); -
trunk/src/wp-admin/includes/post.php
r31681 r31730 1040 1040 $query['posts_per_page'] = -1; 1041 1041 $query['posts_per_archive_page'] = -1; 1042 $query['fields'] = 'id=>parent'; 1042 1043 } 1043 1044
Note: See TracChangeset
for help on using the changeset viewer.