is_page == true) { $params['current'] = $wp_query->post->ID; } if($params['current'] == -1 && $params['show_root'] != 0) { $params['current'] = 0; } // Query pages. $pages = get_pages($args); if ( $pages ) { // Now loop over all pages that were selected $page_tree = Array(); $parent_page_id = null; $parents= Array(); $is_home_modified = 0; foreach($pages as $page) { // set the title for the current page $page_tree[$page->ID]['title'] = $page->post_title; $page_tree[$page->ID]['parent'] = $page->post_parent; //next line added as a lookup for password $page_tree[$page->ID]['post_password'] = $page->post_password; //check for page called home to set it to current if at index if($params['current'] == 0 && $page->post_title == $params['home']) { $params['current'] = $page->ID; $params["is_home_modified"] = 1; } // set the selected date for the current page // depending on the query arguments this is either // the createtion date or the modification date // as a unix timestamp. It will also always be in the // ts field. if (! empty($params['show_date'])) { if ('modified' == $params['show_date']) $page_tree[$page->ID]['ts'] = $page->time_modified; else $page_tree[$page->ID]['ts'] = $page->time_created; } // The tricky bit!! // Using the parent ID of the current page as the // array index we set the current page as a child of that page. // We can now start looping over the $page_tree array // with any ID which will output the page links from that ID downwards. $page_tree[$page->post_parent]['children'][] = $page->ID; if( $params['current'] == $page->ID) { if($page->post_parent != 0 || $params['show_root'] == true) $parents[] = $page->post_parent; } } $len = count($parents); for($i = 0; $i < $len ; $i++) { $parent_page_id = $parents[$i]; $parent_page = $page_tree[$parent_page_id]; if(isset($parent_page['parent']) && !in_array($parent_page['parent'], $parents)) { if($parent_page['parent'] != 0 || $params['show_root'] == true) { $parents[] = $parent_page['parent']; $len += 1; if( $len >= 2 && $params['show_all_parents'] == 0) { break; } } } } $parents = array_reverse($parents); $level = 0; $parent_out = false; if( $params['show_parents'] == true ) { $r = output_parents($params, $parents, $page_tree); $level = $r['level']; $parent_out = $r['parent_out']; } if($params['show_children'] == false ) { return; } if( is_array($page_tree[$params['current']]['children']) === true ) { $level += 1; if( $params['depth'] == -1 || $level <= $params['depth']) { $css_class = 'level' . $level; if( $params['list_tag'] == true || $parent_out == true) echo "