Make WordPress Core

Ticket #10230: patch.post.php

File patch.post.php, 1.4 KB (added by arakeis, 15 years ago)
Line 
1Index: post.php
2===================================================================
3--- post.php    (révision 12156)
4+++ post.php    (copie de travail)
5@@ -2341,11 +2341,15 @@
6  * @param array $pages List of pages' objects.
7  * @return array
8  */
9-function &get_page_children($page_id, $pages) {
10+function &get_page_children($page_id, $pages, $number=0) {
11        $page_list = array();
12+       $number_count = 0;
13        foreach ( (array) $pages as $page ) {
14-               if ( $page->post_parent == $page_id ) {
15+               if ( $page->post_parent == $page_id && $number==0 ||  $page->post_parent == $page_id && $number_count < $number) {
16                        $page_list[] = $page;
17+                       if ( $number != 0)
18+                               $number_count+=1;
19+                       
20                        if ( $children = get_page_children($page->ID, $pages) )
21                                $page_list = array_merge($page_list, $children);
22                }
23@@ -2552,7 +2556,7 @@
24        $query .= $author_query;
25        $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
26 
27-       if ( !empty($number) )
28+       if ( !empty($number) && $child_of == 0 )
29                $query .= ' LIMIT ' . $offset . ',' . $number;
30 
31        $pages = $wpdb->get_results($query);
32@@ -2571,8 +2575,11 @@
33        // Update cache.
34        update_page_cache($pages);
35 
36-       if ( $child_of || $hierarchical )
37+       if ( ($child_of || $hierarchical) && $number > 0 ) {
38+               $pages = & get_page_children($child_of, $pages, $number);
39+       } elseif ( ($child_of || $hierarchical) && $number == 0) {
40                $pages = & get_page_children($child_of, $pages);
41+       }
42 
43        if ( !empty($exclude_tree) ) {
44                $exclude = (int) $exclude_tree;