| 2064 | * Retrieve the url of the template file. |
| 2065 | * |
| 2066 | * Searches in the stylesheet directory before the template directory so themes |
| 2067 | * which inherit from a parent theme can just overload one file. |
| 2068 | * |
| 2069 | * @since 3.5 |
| 2070 | * |
| 2071 | * @param string $template_names Template file to search for. |
| 2072 | * @return string The URI of the file if one is located. |
| 2073 | */ |
| 2074 | function theme_url( $file = '' ) { |
| 2075 | $file = ltrim( $file, '/' ); |
| 2076 | |
| 2077 | if ( empty( $file ) || ( false !== strpos( $file, '..' ) ) ) { |
| 2078 | $url = get_stylesheet_directory_uri(); |
| 2079 | } elseif ( is_child_theme() && file_exists( trailingslashit( get_stylesheet_directory() ) . $file ) ) { |
| 2080 | $url = trailingslashit( get_stylesheet_directory_uri() ) . $file; |
| 2081 | } else { |
| 2082 | $url = trailingslashit( get_template_directory_uri() ) . $file; |
| 2083 | } |
| 2084 | |
| 2085 | return apply_filters( 'theme_url', $url, $file ); |
| 2086 | } |
| 2087 | |
| 2088 | /** |