Changeset 42343 for trunk/src/wp-includes/template.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/template.php
r40964 r42343 24 24 $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); 25 25 26 if ( empty( $templates ) ) 27 $templates = array("{$type}.php"); 26 if ( empty( $templates ) ) { 27 $templates = array( "{$type}.php" ); 28 } 28 29 29 30 /** … … 76 77 */ 77 78 function get_index_template() { 78 return get_query_template( 'index');79 return get_query_template( 'index' ); 79 80 } 80 81 … … 92 93 */ 93 94 function get_404_template() { 94 return get_query_template( '404');95 return get_query_template( '404' ); 95 96 } 96 97 … … 113 114 114 115 if ( count( $post_types ) == 1 ) { 115 $post_type = reset( $post_types );116 $post_type = reset( $post_types ); 116 117 $templates[] = "archive-{$post_type}.php"; 117 118 } … … 135 136 function get_post_type_archive_template() { 136 137 $post_type = get_query_var( 'post_type' ); 137 if ( is_array( $post_type ) ) 138 if ( is_array( $post_type ) ) { 138 139 $post_type = reset( $post_type ); 140 } 139 141 140 142 $obj = get_post_type_object( $post_type ); … … 336 338 */ 337 339 function get_date_template() { 338 return get_query_template( 'date');340 return get_query_template( 'date' ); 339 341 } 340 342 … … 370 372 */ 371 373 function get_front_page_template() { 372 $templates = array( 'front-page.php');374 $templates = array( 'front-page.php' ); 373 375 374 376 return get_query_template( 'front_page', $templates ); … … 404 406 */ 405 407 function get_page_template() { 406 $id = get_queried_object_id();408 $id = get_queried_object_id(); 407 409 $template = get_page_template_slug(); 408 $pagename = get_query_var( 'pagename');410 $pagename = get_query_var( 'pagename' ); 409 411 410 412 if ( ! $pagename && $id ) { 411 413 // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object 412 414 $post = get_queried_object(); 413 if ( $post ) 415 if ( $post ) { 414 416 $pagename = $post->post_name; 415 } 416 417 $templates = array(); 418 if ( $template && 0 === validate_file( $template ) ) 417 } 418 } 419 420 $templates = array(); 421 if ( $template && 0 === validate_file( $template ) ) { 419 422 $templates[] = $template; 423 } 420 424 if ( $pagename ) { 421 425 $pagename_decoded = urldecode( $pagename ); … … 425 429 $templates[] = "page-{$pagename}.php"; 426 430 } 427 if ( $id ) 431 if ( $id ) { 428 432 $templates[] = "page-{$id}.php"; 433 } 429 434 $templates[] = 'page.php'; 430 435 … … 445 450 */ 446 451 function get_search_template() { 447 return get_query_template( 'search');452 return get_query_template( 'search' ); 448 453 } 449 454 … … 499 504 } 500 505 501 $templates[] = "single.php";506 $templates[] = 'single.php'; 502 507 503 508 return get_query_template( 'single', $templates ); … … 541 546 } 542 547 543 $templates[] = "embed.php";548 $templates[] = 'embed.php'; 544 549 545 550 return get_query_template( 'embed', $templates ); … … 627 632 * @return string The template filename if one is located. 628 633 */ 629 function locate_template( $template_names, $load = false, $require_once = true ) {634 function locate_template( $template_names, $load = false, $require_once = true ) { 630 635 $located = ''; 631 636 foreach ( (array) $template_names as $template_name ) { 632 if ( ! $template_name )637 if ( ! $template_name ) { 633 638 continue; 634 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { 639 } 640 if ( file_exists( STYLESHEETPATH . '/' . $template_name ) ) { 635 641 $located = STYLESHEETPATH . '/' . $template_name; 636 642 break; 637 } elseif ( file_exists( TEMPLATEPATH . '/' . $template_name) ) {643 } elseif ( file_exists( TEMPLATEPATH . '/' . $template_name ) ) { 638 644 $located = TEMPLATEPATH . '/' . $template_name; 639 645 break; … … 644 650 } 645 651 646 if ( $load && '' != $located ) 652 if ( $load && '' != $located ) { 647 653 load_template( $located, $require_once ); 654 } 648 655 649 656 return $located;
Note: See TracChangeset
for help on using the changeset viewer.