diff --git a/wp-includes/template-functions-post.php b/wp-includes/template-functions-post.php index a5240ed6c5..d6e14b70c9 100644 --- a/wp-includes/template-functions-post.php +++ b/wp-includes/template-functions-post.php @@ -308,18 +308,20 @@ function &get_pages($args = '') { function wp_list_pages($args = '') { parse_str($args, $r); - if (!isset($r['depth'])) $r['depth'] = 0; - if (!isset($r['show_date'])) $r['show_date'] = ''; - if (!isset($r['child_of'])) $r['child_of'] = 0; + if ( !isset($r['depth']) ) $r['depth'] = 0; + if ( !isset($r['show_date']) ) $r['show_date'] = ''; + if ( !isset($r['child_of']) ) $r['child_of'] = 0; if ( !isset($r['title_li']) ) $r['title_li'] = __('Pages'); - + if ( !isset($r['echo']) ) $r['echo'] = 1; + + $output = ''; // Query pages. $pages = & get_pages($args); if ( $pages ) : if ( $r['title_li'] ) - echo ''; endif; + + if ( $r['echo'] ) + echo $output; + else + return $output; } -function _page_level_out($parent, $page_tree, $args, $depth = 0) { +function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) { global $wp_query; $queried_obj = $wp_query->get_queried_object(); + $output = ''; + if($depth) $indent = str_repeat("\t", $depth); //$indent = join('', array_fill(0,$depth,"\t")); @@ -373,13 +382,13 @@ function _page_level_out($parent, $page_tree, $args, $depth = 0) { $css_class .= ' current_page_item'; } - echo $indent . '
  • ' . $title . ''; + $output .= $indent . '
  • ' . $title . ''; if(isset($cur_page['ts'])) { $format = get_settings('date_format'); if(isset($args['date_format'])) $format = $args['date_format']; - echo " " . mysql2date($format,$cur_page['ts']); + $output .= " " . mysql2date($format, $cur_page['ts']); } echo "\n"; @@ -387,13 +396,17 @@ function _page_level_out($parent, $page_tree, $args, $depth = 0) { $new_depth = $depth + 1; if(!$args['depth'] || $depth < ($args['depth']-1)) { - echo "$indent\n"; + $output .= "$indent\n"; } } - echo "$indent
  • \n"; + $output .= "$indent\n"; } + if ( $echo ) + echo $output; + else + return $output; } ?>