Changeset 8624
- Timestamp:
- 08/12/2008 08:18:05 PM (16 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r8600 r8624 5 5 function get_header() { 6 6 do_action( 'get_header' ); 7 if ( file_exists( STYLESHEETPATH . '/header.php') ) 8 load_template( STYLESHEETPATH . '/header.php'); 9 elseif ( file_exists( TEMPLATEPATH . '/header.php') ) 10 load_template( TEMPLATEPATH . '/header.php'); 11 else 7 if ('' == locate_template(array('header.php'), true)) 12 8 load_template( get_theme_root() . '/default/header.php'); 13 9 } … … 16 12 function get_footer() { 17 13 do_action( 'get_footer' ); 18 if ( file_exists( STYLESHEETPATH . '/footer.php') ) 19 load_template( STYLESHEETPATH . '/footer.php'); 20 elseif ( file_exists( TEMPLATEPATH . '/footer.php') ) 21 load_template( TEMPLATEPATH . '/footer.php'); 22 else 14 if ('' == locate_template(array('footer.php'), true)) 23 15 load_template( get_theme_root() . '/default/footer.php'); 24 16 } … … 27 19 function get_sidebar( $name = null ) { 28 20 do_action( 'get_sidebar' ); 29 if ( isset($name) && file_exists( STYLESHEETPATH . "/sidebar-{$name}.php") ) 30 load_template( STYLESHEETPATH . "/sidebar-{$name}.php"); 31 elseif ( isset($name) && file_exists( TEMPLATEPATH . "/sidebar-{$name}.php") ) 32 load_template( TEMPLATEPATH . "/sidebar-{$name}.php"); 33 elseif ( file_exists( STYLESHEETPATH . '/sidebar.php') ) 34 load_template( STYLESHEETPATH . '/sidebar.php'); 35 elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') ) 36 load_template( TEMPLATEPATH . '/sidebar.php'); 37 else 21 22 $templates = array(); 23 if ( isset($name) ) 24 $templates[] = "sidebar-{$name}.php"; 25 26 $templates[] = "sidebar.php"; 27 28 if ('' == locate_template($templates, true)) 38 29 load_template( get_theme_root() . '/default/sidebar.php'); 39 30 } -
trunk/wp-includes/theme.php
r8600 r8624 1 1 <?php 2 /* 2 /** 3 * @package WordPress 4 * @subpackage Themes 5 * @since 0.0 3 6 * Theme/template/stylesheet functions. 4 7 */ 5 6 8 function get_stylesheet() { 7 9 return apply_filters('stylesheet', get_option('stylesheet')); … … 347 349 348 350 function get_query_template($type) { 349 $template = '';350 351 $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); 351 if ( file_exists(STYLESHEETPATH . "/{$type}.php") ) 352 $template = STYLESHEETPATH . "/{$type}.php"; 353 elseif ( file_exists(TEMPLATEPATH . "/{$type}.php") ) 354 $template = TEMPLATEPATH . "/{$type}.php"; 355 356 return apply_filters("{$type}_template", $template); 352 return apply_filters("{$type}_template", locate_template(array("{$type}.php"))); 357 353 } 358 354 … … 370 366 371 367 function get_category_template() { 372 $template = ''; 373 if ( file_exists(STYLESHEETPATH . "/category-" . absint( get_query_var('cat') ) . '.php') ) 374 $template = STYLESHEETPATH . "/category-" . absint( get_query_var('cat') ) . '.php'; 375 elseif ( file_exists(TEMPLATEPATH . "/category-" . absint( get_query_var('cat') ) . '.php') ) 376 $template = TEMPLATEPATH . "/category-" . absint( get_query_var('cat') ) . '.php'; 377 elseif ( file_exists(STYLESHEETPATH . "/category.php") ) 378 $template = STYLESHEETPATH . "/category.php"; 379 elseif ( file_exists(TEMPLATEPATH . "/category.php") ) 380 $template = TEMPLATEPATH . "/category.php"; 381 368 $template =locate_template(array("category-" . absint( get_query_var('cat') ) . '.php',"category.php")); 382 369 return apply_filters('category_template', $template); 383 370 } 384 371 385 372 function get_tag_template() { 386 $template = ''; 387 if ( file_exists(STYLESHEETPATH . "/tag-" . get_query_var('tag') . '.php') ) 388 $template = STYLESHEETPATH . "/tag-" . get_query_var('tag') . '.php'; 389 elseif ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') ) 390 $template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php'; 391 elseif ( file_exists(STYLESHEETPATH . "/tag.php") ) 392 $template = STYLESHEETPATH . "/tag.php"; 393 elseif ( file_exists(TEMPLATEPATH . "/tag.php") ) 394 $template = TEMPLATEPATH . "/tag.php"; 395 373 $template = locate_template(array("tag-" . absint( get_query_var('tag') ) . '.php',"tag.php")); 396 374 return apply_filters('tag_template', $template); 397 375 } 398 376 399 377 function get_taxonomy_template() { 400 $template = '';401 378 $taxonomy = get_query_var('taxonomy'); 402 379 $term = get_query_var('term'); 403 if ( $taxonomy && $term && file_exists(STYLESHEETPATH . "/taxonomy-$taxonomy-$term.php") ) 404 $template = STYLESHEETPATH . "/taxonomy-$taxonomy-$term.php"; 405 elseif ( $taxonomy && $term && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php") ) 406 $template = TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php"; 407 elseif ( $taxonomy && file_exists(STYLESHEETPATH . "/taxonomy-$taxonomy.php") ) 408 $template = STYLESHEETPATH . "/taxonomy-$taxonomy.php"; 409 elseif ( $taxonomy && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy.php") ) 410 $template = TEMPLATEPATH . "/taxonomy-$taxonomy.php"; 411 elseif ( file_exists(STYLESHEETPATH . "/taxonomy.php") ) 412 $template = STYLESHEETPATH . "/taxonomy.php"; 413 elseif ( file_exists(TEMPLATEPATH . "/taxonomy.php") ) 414 $template = TEMPLATEPATH . "/taxonomy.php"; 415 380 381 $templates = array(); 382 if ( $taxonomy && $term ) 383 $templates[] = "taxonomy-$taxonomy-$term.php"; 384 if ( $taxonomy ) 385 $templates[] = "taxonomy-$taxonomy.php"; 386 387 $templates[] = "taxonomy.php"; 388 389 $template = locate_template($templates); 416 390 return apply_filters('taxonomy_template', $template); 417 391 } … … 422 396 423 397 function get_home_template() { 424 $template = ''; 425 426 if ( file_exists(STYLESHEETPATH . "/home.php") ) 427 $template = STYLESHEETPATH . "/home.php"; 428 elseif ( file_exists(TEMPLATEPATH . "/home.php") ) 429 $template = TEMPLATEPATH . "/home.php"; 430 elseif ( file_exists(STYLESHEETPATH . "/index.php") ) 431 $template = STYLESHEETPATH . "/index.php"; 432 elseif ( file_exists(TEMPLATEPATH . "/index.php") ) 433 $template = TEMPLATEPATH . "/index.php"; 434 398 $template = locate_template(array('home.php','index.php')); 435 399 return apply_filters('home_template', $template); 436 400 } … … 445 409 $template = ''; 446 410 447 if ( !empty($template) && !validate_file($template) && file_exists(STYLESHEETPATH . "/$template") ) 448 $template = STYLESHEETPATH . "/$template"; 449 elseif ( !empty($template) && !validate_file($template) && file_exists(TEMPLATEPATH . "/$template") ) 450 $template = TEMPLATEPATH . "/$template"; 451 elseif ( file_exists(STYLESHEETPATH . "/page.php") ) 452 $template = STYLESHEETPATH . "/page.php"; 453 elseif ( file_exists(TEMPLATEPATH . "/page.php") ) 454 $template = TEMPLATEPATH . "/page.php"; 455 else 456 $template = ''; 457 458 return apply_filters('page_template', $template); 411 $templates = array(); 412 if ( !empty($template) && !validate_file($template) ) 413 $templates[] = $template; 414 415 $templates[] = "page.php"; 416 417 return apply_filters('page_template', locate_template($templates)); 459 418 } 460 419 … … 485 444 486 445 function get_comments_popup_template() { 487 if ( file_exists( STYLESHEETPATH . '/comments-popup.php') ) 488 $template = STYLESHEETPATH . '/comments-popup.php'; 489 elseif ( file_exists( TEMPLATEPATH . '/comments-popup.php') ) 490 $template = TEMPLATEPATH . '/comments-popup.php'; 491 else 446 $template = locate_template(array("comments-popup.php")); 447 if ('' == $template) 492 448 $template = get_theme_root() . '/default/comments-popup.php'; 493 449 494 450 return apply_filters('comments_popup_template', $template); 451 } 452 453 /** 454 * Returns the name of the highest priority template file that exists 455 * 456 * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which 457 * inherit from a parent theme can just overload one file. 458 * @since 2.7 459 * 460 * @param array $template_names Array of template files to search for in priority order 461 * @param bool $load If true the template file will be loaded if it is found. 462 * @return string The template filename if one is located. 463 */ 464 function locate_template($template_names, $load = false) { 465 if (!is_array($template_names)) 466 return ''; 467 468 $located = ''; 469 foreach($template_names as $template_name) { 470 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { 471 $located = STYLESHEETPATH . '/' . $template_name; 472 break; 473 } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) { 474 $located = TEMPLATEPATH . '/' . $template_name; 475 break; 476 } 477 } 478 479 if ($load && '' != $located) 480 load_template($located); 481 482 return $located; 495 483 } 496 484
Note: See TracChangeset
for help on using the changeset viewer.