| 1096 | * Retrieve the URI of the highest priority template file that exists. |
| 1097 | * |
| 1098 | * Searches in the stylesheet directory before the template directory so themes |
| 1099 | * which inherit from a parent theme can just overload one file. |
| 1100 | * |
| 1101 | * @since 3.3 |
| 1102 | * |
| 1103 | * @param string|array $template_names Template file(s) to search for, in order. |
| 1104 | * @return string The URI of the file if one is located. |
| 1105 | */ |
| 1106 | function locate_template_uri( $template_names ) { |
| 1107 | $located = ''; |
| 1108 | foreach ( (array) $template_names as $template_name ) { |
| 1109 | if ( !$template_name ) |
| 1110 | continue; |
| 1111 | if ( file_exists(get_stylesheet_directory() . '/' . $template_name)) { |
| 1112 | $located = get_stylesheet_directory_uri() . '/' . $template_name; |
| 1113 | break; |
| 1114 | } else if ( file_exists(get_template_directory() . '/' . $template_name) ) { |
| 1115 | $located = get_template_directory_uri() . '/' . $template_name; |
| 1116 | break; |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | return $located; |
| 1121 | } |
| 1122 | |
| 1123 | /** |