Ticket #5662: 5662.diff
| File 5662.diff, 1.9 KB (added by , 18 years ago) |
|---|
-
wp-includes/post.php
176 176 177 177 $_post = sanitize_post($_post, $filter); 178 178 179 get_post_ancestors($_post); 180 179 181 if ( $output == OBJECT ) { 180 182 return $_post; 181 183 } elseif ( $output == ARRAY_A ) { … … 187 189 } 188 190 } 189 191 192 function get_post_ancestors (&$_post) { 193 global $wpdb; 194 $_post->ancestors = array(); 195 196 if ($_post->post_parent != 0) { 197 $id = $_post->ancestors[] = $_post->post_parent; 198 while ($ancestor = $wpdb->get_var("SELECT `post_parent` FROM $wpdb->posts WHERE ID= '{$id}' LIMIT 1")) { 199 $id = $_post->ancestors[] = $ancestor; 200 } 201 } 202 } 203 190 204 /** 191 205 * get_post_field() - Retrieve a field based on a post ID. 192 206 * … … 1724 1738 1725 1739 $pages = apply_filters('get_pages', $pages, $r); 1726 1740 1741 $ancestors = array(); 1742 foreach ($pages as $page) { 1743 if ($page->post_parent != 0) { 1744 $ancestors[$page->ID] = $page->post_parent; 1745 } 1746 } 1747 if (!empty($ancestors)) { 1748 foreach ($pages as $page) { 1749 $page->ancestors = array(); 1750 $id = $page->ID; 1751 while (isset($ancestors[$id])) { 1752 $id = $page->ancestors[] = $ancestors[$id]; 1753 } 1754 } 1755 } 1727 1756 return $pages; 1728 1757 } 1729 1758 -
wp-includes/classes.php
547 547 $indent = str_repeat("\t", $depth); 548 548 else 549 549 $indent = ''; 550 550 551 551 extract($args, EXTR_SKIP); 552 552 $css_class = 'page_item page-item-'.$page->ID; 553 553 $_current_page = get_page( $current_page ); 554 if (in_array($page->ID, $_current_page->ancestors)) { 555 $css_class .= ' current_page_ancestor '; 556 } 554 557 if ( $page->ID == $current_page ) 555 558 $css_class .= ' current_page_item '; 556 559 elseif ( $_current_page && $page->ID == $_current_page->post_parent )