| 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 | $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 | /** |