| 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 | */ |
| 2072 | function 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 | /** |