From 87ae97a740624244d7f27d197ece40efe5166426 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 21 Apr 2005 00:49:15 +0000 Subject: [PATCH] Add echo option to wp_list_pages() and subordinates. http://mosquito.wordpress.org/view.php?id=1270 Props: MC_incubus git-svn-id: http://svn.automattic.com/wordpress/trunk@2566 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template-functions-post.php | 41 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) 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; } ?>