WordPress.org

Make WordPress Core

Ticket #18302: 18302.theme_url.diff

File 18302.theme_url.diff, 1.2 KB (added by georgestephanis, 9 years ago)

Moving function from themes to link-template along with related plugins_url() content_url() and such

  • 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                if ( !$template_name )
     2077                        continue;
     2078                if ( file_exists( get_stylesheet_directory() . '/' . $template_name ) ) {
     2079                        $located = get_stylesheet_directory_uri() . '/' . $template_name;
     2080                        break;
     2081                } elseif ( file_exists( get_template_directory() . '/' . $template_name ) ) {
     2082                        $located = get_template_directory_uri() . '/' . $template_name;
     2083                        break;
     2084                }
     2085        }
     2086
     2087        return $located;
     2088}
     2089
     2090/**
    20622091 * Retrieve the site url for the current network.
    20632092 *
    20642093 * Returns the site url with the appropriate protocol, 'https' if