WordPress.org

Make WordPress Core

Ticket #4351: walker-page-tree-diff.txt

File walker-page-tree-diff.txt, 713 bytes (added by ev3rywh3re, 7 years ago)

Patch for Walker_Page to add UL class current_page_tree

Line 
1Index: wp-includes/classes.php
2===================================================================
3--- wp-includes/classes.php     (revision 5571)
4+++ wp-includes/classes.php     (working copy)
5@@ -491,9 +491,12 @@
6        var $tree_type = 'page';
7        var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
8 
9-       function start_lvl($output, $depth) {
10+       function start_lvl($output, $depth, $current_page) {
11                $indent = str_repeat("\t", $depth);
12-               $output .= "\n$indent<ul>\n";
13+               $_current_page = get_page( $current_page );
14+               $output .= "\n$indent<ul";
15+               if ( $depth == 1 && $_current_page->post_parent != 0 ) $output .= ' class="current_page_tree"';
16+               $output .= ">\n";
17                return $output;
18        }