Changeset 1966 for trunk/wp-includes/template-functions-post.php
- Timestamp:
- 12/16/2004 08:02:53 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions-post.php
r1940 r1966 322 322 global $wpdb; 323 323 324 // TODO: Hierarchy.325 326 324 parse_str($args, $r); 327 if (!isset($r['sort_column'])) $r['sort_column'] = 'title'; 328 if (!isset($r['sort_order'])) $r['sort_order'] = 'asc'; 329 330 $pages = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'static' ORDER BY post_" . $r['sort_column'] . " " . $r['sort_order'] = 'asc'); 331 332 foreach ($pages as $page) { 333 echo '<li>'; 334 335 $title = apply_filters('the_title', $page->post_title); 336 337 echo '<a href="' . get_page_link($page->ID) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>'; 338 echo '</li>'; 325 if (!isset($r['child_of'])) $r['child_of'] = 0; 326 if (!isset($r['depth'])) $r['depth'] = 0; 327 if (!isset($r['show_date'])) $r['show_date'] = ''; 328 if (!isset($r['sort_column'])) $r['sort_column'] = 'post_title'; 329 if (!isset($r['sort_order'])) $r['sort_order'] = 'ASC'; 330 331 332 $exclusions = ''; 333 if (!empty($r['exclude'])) { 334 $expages = preg_split('/[\s,]+/',$r['exclude']); 335 if (count($expages)) { 336 foreach ($expages as $expage) { 337 $exclusions .= ' AND ID <> ' . intval($expage) . ' '; 338 } 339 } 340 } 341 342 $option_dates = ''; 343 if (! empty($r['show_date'])) { 344 if ('modified' == $r['show_date']) 345 $option_dates = ",UNIX_TIMESTAMP(post_modified) AS ts"; 346 else 347 $option_dates = ",UNIX_TIMESTAMP(post_date) AS ts"; 348 } 349 350 $post_parent = ''; 351 if ($r['child_of']) { 352 $post_parent = ' AND post_parent=' . $r['child_of'] . ' '; 353 } 354 $pages = $wpdb->get_results("SELECT " . 355 "ID, post_title,post_parent " . 356 "$option_dates " . 357 "FROM $wpdb->posts " . 358 "WHERE post_status = 'static' " . 359 "$post_parent" . 360 "$exclusions " . 361 "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']); 362 $page_tree = Array(); 363 foreach($pages as $page) { 364 $page_tree[$page->ID]['title'] = $page->post_title; 365 366 if(!empty($r['show_date'])) { 367 $page_tree[$page->ID]['ts'] = $page->ts; 368 } 369 $page_tree[$page->post_parent]['children'][] = $page->ID; 370 } 371 page_level_out($r['child_of'],$page_tree, $r); 372 } 373 374 function page_level_out($parent, $page_tree, $args, $depth = 0) { 375 if($depth) 376 $indent = join(array_fill(0,$depth,"\t")); 377 378 foreach($page_tree[$parent]['children'] as $page_id) { 379 $cur_page = $page_tree[$page_id]; 380 $title = $cur_page['title']; 381 echo $indent . '<li><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>'; 382 if(isset($cur_page['ts'])) { 383 $format = get_settings('date_format'); 384 if(isset($args['date_format'])) 385 $format = $args['date_format']; 386 echo " " . gmdate($format,$cur_page['ts']); 387 } 388 echo "\n"; 389 390 if(isset($cur_page['children']) && is_array($cur_page['children'])) { 391 echo "$indent<ul>\n"; 392 $new_depth = $depth + 1; 393 394 if(!$args['depth'] || $depth < ($args['depth']-1)) { 395 page_level_out($page_id,$page_tree, $args, $new_depth); 396 } 397 echo "$indent</ul>\n"; 398 } 399 echo "$indent</li>\n"; 400 339 401 } 340 402 }
Note: See TracChangeset
for help on using the changeset viewer.