Make WordPress Core

Ticket #18302: 18302.theme_url.2.diff

File 18302.theme_url.2.diff, 1.3 KB (added by georgestephanis, 12 years ago)

Added in ltrim( $file, '/' ); to account for theme authors using it as theme_url( '/images/logo.gif' );

  • wp-includes/link-template.php

     
    20592059}
    20602060
    20612061/**
     2062 * Retrieve the url of the highest priority template file that exists.
     2063 *
     2064 * Searches in the stylesheet directory before the template directory so themes
     2065 * which inherit from a parent theme can just overload one file.
     2066 *
     2067 * @since 3.5
     2068 *
     2069 * @param string|array $template_names Template file(s) to search for, in order.
     2070 * @return string The URI of the file if one is located.
     2071 */
     2072function theme_url( $template_names ) {
     2073        $located = null;
     2074
     2075        foreach ( (array) $template_names as $template_name ) {
     2076                $template_name = ltrim( $template_name, '/' );
     2077                if ( ! $template_name )
     2078                        continue;
     2079                if ( file_exists( get_stylesheet_directory() . '/' . $template_name ) ) {
     2080                        $located = get_stylesheet_directory_uri() . '/' . $template_name;
     2081                        break;
     2082                } elseif ( file_exists( get_template_directory() . '/' . $template_name ) ) {
     2083                        $located = get_template_directory_uri() . '/' . $template_name;
     2084                        break;
     2085                }
     2086        }
     2087
     2088        return $located;
     2089}
     2090
     2091/**
    20622092 * Retrieve the site url for the current network.
    20632093 *
    20642094 * Returns the site url with the appropriate protocol, 'https' if