Make WordPress Core

Ticket #18302: 18302.13.diff

File 18302.13.diff, 1.5 KB (added by georgestephanis, 12 years ago)
  • wp-includes/link-template.php

     
    24372437                echo $before, $link, $after;
    24382438        }
    24392439}
     2440
     2441/**
     2442 * Retrieve the url of a file in the theme.
     2443 *
     2444 * Searches in the stylesheet directory before the template directory so themes
     2445 * which inherit from a parent theme can just override one file.
     2446 *
     2447 * @since 3.6.0
     2448 *
     2449 * @param string $file File to search for in the stylesheet directory.
     2450 * @return string The URL of the file.
     2451 */
     2452function theme_file_uri( $file = '' ) {
     2453        $file = ltrim( $file, '/' );
     2454
     2455        if ( empty( $file ) ) {
     2456                $url = get_stylesheet_directory_uri();
     2457        } elseif( is_child_theme() && file_exists( get_stylesheet_directory() . "/$file" ) {
     2458                $url = get_stylesheet_directory_uri() . "/$file";
     2459        } else {
     2460                $url = get_template_directory_uri() . "/$file";
     2461        }
     2462
     2463        return apply_filters( 'theme_url', $url, $file );
     2464}
     2465
     2466/**
     2467 * Retrieve the url of a file in the parent theme.
     2468 *
     2469 * @since 3.6.0
     2470 *
     2471 * @param string $file File to return the url for in the template directory.
     2472 * @return string The URL of the file.
     2473 */
     2474function parent_theme_file_uri( $file = '' ) {
     2475        $file = ltrim( $file, '/' );
     2476
     2477        if ( empty( $file ) ) {
     2478                $url = get_template_directory_uri();
     2479        } else {
     2480                $url = get_template_directory_uri() . "/$file";
     2481        }
     2482
     2483        return apply_filters( 'parent_theme_url', $url, $file );
     2484}