Index: wp-includes/template.php
===================================================================
--- wp-includes/template.php	(revision 35304)
+++ wp-includes/template.php	(working copy)
@@ -502,15 +502,30 @@
  */
 function locate_template($template_names, $load = false, $require_once = true ) {
 	$located = '';
+	$locations = array(
+		get_stylesheet_directory(),
+		get_template_directory()
+	);
+
+	/**
+	 * Filter the possible template locations.
+	 *
+	 * @since unknown
+	 *
+	 * @param array $locations Possible template locations.
+	 */
+	$locations = apply_filters( 'template_locations', $locations );
+
 	foreach ( (array) $template_names as $template_name ) {
 		if ( !$template_name )
 			continue;
-		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
-			$located = STYLESHEETPATH . '/' . $template_name;
-			break;
-		} elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
-			$located = TEMPLATEPATH . '/' . $template_name;
-			break;
+
+		foreach ( (array) $locations as $location ) {
+			$template_name = trailingslashit( $location ) . $template_name;
+			if ( file_exists( $template_name ) {
+				$located = $template_name;
+				break 2;
+			}
 		}
 	}
 
