Index: wp-includes/template.php
===================================================================
--- wp-includes/template.php	(revision 38082)
+++ wp-includes/template.php	(working copy)
@@ -510,16 +510,42 @@
  * @param bool         $require_once   Whether to require_once or require. Default true. Has no effect if $load is false.
  * @return string The template filename if one is located.
  */
-function locate_template($template_names, $load = false, $require_once = true ) {
+function locate_template( $template_names, $load = false, $require_once = true ) {
 	$located = '';
 	foreach ( (array) $template_names as $template_name ) {
-		if ( !$template_name )
+		if ( ! $template_name ) {
 			continue;
-		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
-			$located = STYLESHEETPATH . '/' . $template_name;
+		}
+
+		/**
+		 * Filters the path to the stylesheet directory used by load_template.
+		 *
+		 * Allows user to override STYLESHEETPATH. Useful in contexts where this
+		 * context is not defined, such as oEmbed or Public API.
+		 *
+		 * @since 4.7.0
+		 *
+		 * @param string $template path to the stylesheet directory
+		 */
+		$stylesheet_path = apply_filters( 'stylesheet_path', STYLESHEETPATH );
+
+		/**
+		 * Filters the path to the template directory used by load_template.
+		 *
+		 * Allows user to override TEMPLATEPATH. Useful in contexts where this
+		 * context is not defined, such as oEmbed or Public API.
+		 *
+		 * @since 4.7.0
+		 *
+		 * @param string $template path to the template directory
+		 */
+		$template_path = apply_filters( 'template_path', TEMPLATEPATH );
+
+		if ( file_exists( $stylesheet_path . '/' . $template_name ) ) {
+			$located = $stylesheet_path . '/' . $template_name;
 			break;
-		} elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
-			$located = TEMPLATEPATH . '/' . $template_name;
+		} 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;
@@ -527,8 +553,9 @@
 		}
 	}
 
-	if ( $load && '' != $located )
+	if ( $load && '' !== $located ) {
 		load_template( $located, $require_once );
+	}
 
 	return $located;
 }
