コード例 #1
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"));
    if (!is_array($page_tree[$parent]['children'])) {
        return false;
    }
    foreach ($page_tree[$parent]['children'] as $page_id) {
        $cur_page = $page_tree[$page_id];
        $title = $cur_page['title'];
        $css_class = 'page_item';
        if ($page_id == $queried_obj->ID) {
            $css_class .= ' current_page_item';
        }
        $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';
        if (isset($cur_page['ts'])) {
            $format = get_settings('date_format');
            if (isset($args['date_format'])) {
                $format = $args['date_format'];
            }
            $output .= " " . mysql2date($format, $cur_page['ts']);
        }
        if (isset($cur_page['children']) && is_array($cur_page['children'])) {
            $new_depth = $depth + 1;
            if (!$args['depth'] || $depth < $args['depth'] - 1) {
                $output .= "{$indent}<ul>\n";
                $output .= _page_level_out($page_id, $page_tree, $args, $new_depth, false);
                $output .= "{$indent}</ul>\n";
            }
        }
        $output .= "{$indent}</li>\n";
    }
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
コード例 #2
0
function _page_level_out($parent, $page_tree, $args, $depth = 0) {
	global $wp_query;

	$queried_obj = $wp_query->get_queried_object();

	if($depth)
		$indent = str_repeat("\t", $depth);
	//$indent = join('', array_fill(0,$depth,"\t"));

	foreach($page_tree[$parent]['children'] as $page_id) {
		$cur_page = $page_tree[$page_id];
		$title = $cur_page['title'];

		$css_class = 'page_item';
		if( $page_id == $queried_obj->ID) {
			$css_class .= ' current_page_item';
		}

		echo $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';

		if(isset($cur_page['ts'])) {
			$format = get_settings('date_format');
			if(isset($args['date_format']))
				$format = $args['date_format'];
			echo " " . gmdate($format,$cur_page['ts']);
		}
		echo "\n";

		if(isset($cur_page['children']) && is_array($cur_page['children'])) {
			$new_depth = $depth + 1;

			if(!$args['depth'] || $depth < ($args['depth']-1)) {
				echo "$indent<ul>\n";
				_page_level_out($page_id,$page_tree, $args, $new_depth);
				echo "$indent</ul>\n";
			}
		}
		echo "$indent</li>\n";
	}
}