Index: src/wp-includes/template.php
===================================================================
--- src/wp-includes/template.php	(revision 31311)
+++ src/wp-includes/template.php	(working copy)
@@ -494,12 +494,54 @@
 function load_template( $_template_file, $require_once = true ) {
 	global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
 
-	if ( is_array( $wp_query->query_vars ) )
+	/**
+	 * Filter whether to preempt loading the given template file.
+	 *
+	 * Passing a truthy value to the filter will effectively short-circuit loading
+	 * of the template file, returning the given value instead.
+	 *
+	 * @since 4.2.0
+	 *
+	 * @param bool   $load Whether to load the given template file.
+	 * @param string $_template_file Template file to load.
+	 * @param bool   $require_once   Whether to use `require_once` (true) or `require` (false) to load
+	 *                               the template file.
+	 */
+	$pre = apply_filters( 'pre_load_template', false, $_template_file, $require_once );
+
+	if ( false !== $pre ) {
+		return $pre;
+	}
+
+	if ( is_array( $wp_query->query_vars ) ) {
 		extract( $wp_query->query_vars, EXTR_SKIP );
+	}
 
-	if ( $require_once )
+	/**
+	 * Fires immediately before a template file is loaded.
+	 *
+	 * @since 4.2.0
+	 *
+	 * @param string $_template_file Template file to load.
+	 * @param bool   $require_once   Whether to use `require_once` (true) or `require` (false) to load
+	 *                               the template file.
+	 */
+	do_action( 'load_template_pre_require', $_template_file, $require_once );
+
+	if ( $require_once ) {
 		require_once( $_template_file );
-	else
+	} else {
 		require( $_template_file );
+	}
+
+	/**
+	 * Fires immediately after a template file is loaded.
+	 *
+	 * @since 4.2.0
+	 *
+	 * @param string $_template_file Template file to load.
+	 * @param bool   $require_once   Whether to use `require_once` (true) or `require` (false) to load
+	 *                               the template file.
+	 */
+	do_action( 'load_template_post_require', $_template_file, $require_once );
 }
-
