%s', wp_kses_post( sprintf( __( 'Template file %s not found.' ), '' . esc_html( $template_file ) . '' ) ) ); } } /** * Locates ACB templates. * * Works similar to `locate_template`, but allows specifying a path outside of themes * and allows to be called when STYLESHEET_PATH has not been set yet. Handy for async. * * @param string|array $template_names Templates to locate. * @param string $path (Optional) Path to located the templates first. * * @return string */ function abc_locate_template( $template_names, $path = '' ) { $path = apply_filters( 'acb_template_path', $path ); $stylesheet_path = get_template_directory(); $template_path = get_stylesheet_directory(); $located = ''; foreach ( (array) $template_names as $template_name ) { if ( !$template_name ) { continue; } if ( ! empty( $path ) && file_exists( $path . '/' . $template_name ) ) { $located = $path . '/' . $template_name; } elseif ( file_exists($stylesheet_path . '/' . $template_name)) { $located = $stylesheet_path . '/' . $template_name; break; } elseif ( file_exists($template_path . '/' . $template_name) ) { $located = $template_path . '/' . $template_name; break; } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { $located = ABSPATH . WPINC . '/theme-compat/' . $template_name; break; } } return $located; }