Ticket #22355: 22355.4.patch
File 22355.4.patch, 3.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/link-template.php
2679 2679 } 2680 2680 2681 2681 /** 2682 * Get URI for a theme file. 2683 * 2684 * Uses {@see get_template_directories} to first find the file, then get the 2685 * relevant URI for it. 2686 * 2687 * @since 4.1.0 2688 * 2689 * @param string $path Optional. Path relative to the theme url. 2690 * @return string Theme URL with optional path appended. 2691 */ 2692 function theme_url( $path = '' ) { 2693 $directories = get_template_directories(); 2694 $path = wp_normalize_path( $path ); 2695 $url = get_stylesheet_directory_uri(); 2696 2697 if ( $path && is_string( $path ) ) { 2698 $path = '/' . ltrim( $path, '/' ); 2699 } 2700 2701 foreach ( $directories as $directory => $base_uri ) { 2702 if ( file_exists( $directory . $path ) ) { 2703 $url = $base_uri . $path; 2704 break; 2705 } 2706 } 2707 2708 /** 2709 * Filter the URL to the theme directory. 2710 * 2711 * @since 4.1.0 2712 * 2713 * @param string $url The complete URL to the theme directory, including scheme and path. 2714 * @param string $path Path relative to the URL to the theme directory. Blank string if no path is specified. 2715 * @param array $directories The registered template directories to be relative to. 2716 */ 2717 return apply_filters( 'theme_url', $url, $path, $directories ); 2718 } 2719 2720 /** 2682 2721 * Retrieve the site url for the current network. 2683 2722 * 2684 2723 * Returns the site url with the appropriate protocol, 'https' if -
src/wp-includes/template.php
447 447 } 448 448 449 449 /** 450 * Get template directories. 451 * 452 * Gives a map of theme base directories to theme base URLs, allowing searching 453 * themes for a certain file in order. 454 * 455 * @since 4.1.0 456 * 457 * @return array Map of base directory to base URL 458 */ 459 function get_template_directories() { 460 461 $directories = array( 462 get_stylesheet_directory() => get_stylesheet_directory_uri(), 463 get_template_directory() => get_template_directory_uri(), 464 ); 465 466 /** 467 * Filter registered template directories. 468 * 469 * @since 4.1.0 470 * 471 * @param array $directories The registered template directories. 472 */ 473 return apply_filters( 'get_template_directories', $directories ); 474 } 475 476 /** 450 477 * Retrieve the name of the highest priority template file that exists. 451 478 * 452 479 * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which … … 460 487 * @return string The template filename if one is located. 461 488 */ 462 489 function locate_template($template_names, $load = false, $require_once = true ) { 463 $located = ''; 490 $located = ''; 491 $directories = array_keys( get_template_directories() ); 492 464 493 foreach ( (array) $template_names as $template_name ) { 465 494 if ( !$template_name ) 466 495 continue; 467 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { 468 $located = STYLESHEETPATH . '/' . $template_name;469 break;470 } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {471 $located = TEMPLATEPATH . '/' . $template_name;472 break;496 497 foreach ( $directories as $directory ) { 498 if ( file_exists( $directory . '/' . $template_name ) ) { 499 $located = $directory . '/' . $template_name; 500 break 2; 501 } 473 502 } 474 503 } 475 504 … … 502 531 else 503 532 require( $_template_file ); 504 533 } 505