Index: src/wp-includes/general-template.php
===================================================================
--- src/wp-includes/general-template.php	(revision 40994)
+++ src/wp-includes/general-template.php	(working copy)
@@ -16,19 +16,23 @@
  * "special".
  *
  * @since 1.5.0
+ * @since 4.9.0 `$params` parameter added.
  *
- * @param string $name The name of the specialised header.
+ * @param string $name    The name of the specialised header.
+ * @param array  $params  Additional arguments passed to the header template.
  */
-function get_header( $name = null ) {
+function get_header( $name = null, $params = array() ) {
 	/**
 	 * Fires before the header template file is loaded.
 	 *
 	 * @since 2.1.0
 	 * @since 2.8.0 $name parameter added.
+	 * @since 4.9.0 `$params` parameter added.
 	 *
-	 * @param string|null $name Name of the specific header file to use. null for the default header.
+	 * @param string|null $name    Name of the specific header file to use. null for the default header.
+	 * @param array       $params  Additional arguments passed to the header template.
 	 */
-	do_action( 'get_header', $name );
+	do_action( 'get_header', $name, $params );
 
 	$templates = array();
 	$name = (string) $name;
@@ -38,7 +42,7 @@
 
 	$templates[] = 'header.php';
 
-	locate_template( $templates, true );
+	locate_template( $templates, true, true, $params );
 }
 
 /**
@@ -51,19 +55,23 @@
  * "special".
  *
  * @since 1.5.0
+ * @since 4.9.0 `$params` parameter added.
  *
- * @param string $name The name of the specialised footer.
+ * @param string $name    The name of the specialised footer.
+ * @param array  $params  Additional arguments passed to the footer template.
  */
-function get_footer( $name = null ) {
+function get_footer( $name = null, $params = array() ) {
 	/**
 	 * Fires before the footer template file is loaded.
 	 *
 	 * @since 2.1.0
 	 * @since 2.8.0 $name parameter added.
+	 * @since 4.9.0 `$params` parameter added.
 	 *
-	 * @param string|null $name Name of the specific footer file to use. null for the default footer.
+	 * @param string|null $name    Name of the specific footer file to use. null for the default footer.
+	 * @param array       $params  Additional arguments passed to the header template.
 	 */
-	do_action( 'get_footer', $name );
+	do_action( 'get_footer', $name, $params );
 
 	$templates = array();
 	$name = (string) $name;
@@ -73,7 +81,7 @@
 
 	$templates[]    = 'footer.php';
 
-	locate_template( $templates, true );
+	locate_template( $templates, true, true, $params );
 }
 
 /**
@@ -86,19 +94,23 @@
  * "special".
  *
  * @since 1.5.0
+ * @since 4.9.0 `$params` parameter added.
  *
- * @param string $name The name of the specialised sidebar.
+ * @param string $name    The name of the specialised sidebar.
+ * @param array  $params  Additional arguments passed to the sidebar template.
  */
-function get_sidebar( $name = null ) {
+function get_sidebar( $name = null, $params = array() ) {
 	/**
 	 * Fires before the sidebar template file is loaded.
 	 *
 	 * @since 2.2.0
 	 * @since 2.8.0 $name parameter added.
+	 * @since 4.9.0 `$params` parameter added.
 	 *
-	 * @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.
+	 * @param string|null $name    Name of the specific sidebar file to use. null for the default sidebar.
+	 * @param array       $params  Additional arguments passed to the sidebar template.
 	 */
-	do_action( 'get_sidebar', $name );
+	do_action( 'get_sidebar', $name, $params );
 
 	$templates = array();
 	$name = (string) $name;
@@ -107,7 +119,7 @@
 
 	$templates[] = 'sidebar.php';
 
-	locate_template( $templates, true );
+	locate_template( $templates, true, true, $params );
 }
 
 /**
@@ -127,11 +139,13 @@
  * "special".
  *
  * @since 3.0.0
+ * @since 4.9.0 `$params` parameter added.
  *
- * @param string $slug The slug name for the generic template.
- * @param string $name The name of the specialised template.
+ * @param string $slug   The slug name for the generic template.
+ * @param string $name   The name of the specialised template.
+ * @param array  $params Additional arguments passed to the template.
  */
-function get_template_part( $slug, $name = null ) {
+function get_template_part( $slug, $name = null, $params = array() ) {
 	/**
 	 * Fires before the specified template part file is loaded.
 	 *
@@ -139,11 +153,13 @@
 	 * for the generic template part.
 	 *
 	 * @since 3.0.0
-	 *
-	 * @param string      $slug The slug name for the generic template.
-	 * @param string|null $name The name of the specialized template.
+	 * @since 4.9.0 `$params` parameter added 
+	 * 
+	 * @param string      $slug   The slug name for the generic template.
+	 * @param string|null $name   The name of the specialized template.
+	 * @param array       $params Additional arguments passed to the template.
 	 */
-	do_action( "get_template_part_{$slug}", $slug, $name );
+	do_action( "get_template_part_{$slug}", $slug, $name, $params );
 
 	$templates = array();
 	$name = (string) $name;
@@ -152,7 +168,7 @@
 
 	$templates[] = "{$slug}.php";
 
-	locate_template($templates, true, false);
+	locate_template($templates, true, false, $params);
 }
 
 /**
@@ -173,11 +189,13 @@
  * search. To give a few examples of what it can be used for.
  *
  * @since 2.7.0
- *
- * @param bool $echo Default to echo and not return the form.
+ * @since 4.9.0 `$params` parameter added.
+ * 
+ * @param bool   $echo   Default to echo and not return the form.
+ * @param array  $params Additional arguments passed to the template.
  * @return string|void String when $echo is false.
  */
-function get_search_form( $echo = true ) {
+function get_search_form( $echo = true, $params = array() ) {
 	/**
 	 * Fires before the search form is retrieved, at the start of get_search_form().
 	 *
@@ -185,8 +203,10 @@
 	 * @since 3.6.0
 	 *
 	 * @link https://core.trac.wordpress.org/ticket/19321
+	 * 
+	 * @param array  $params Additional arguments passed to the template.
 	 */
-	do_action( 'pre_get_search_form' );
+	do_action( 'pre_get_search_form', $params );
 
 	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
 
@@ -231,8 +251,9 @@
 	 * @since 2.7.0
 	 *
 	 * @param string $form The search form HTML output.
+	 * @param array  $params Additional arguments passed to the template.
 	 */
-	$result = apply_filters( 'get_search_form', $form );
+	$result = apply_filters( 'get_search_form', $form, $params );
 
 	if ( null === $result )
 		$result = $form;
Index: src/wp-includes/template.php
===================================================================
--- src/wp-includes/template.php	(revision 40994)
+++ src/wp-includes/template.php	(working copy)
@@ -620,13 +620,15 @@
  * so that themes which inherit from a parent theme can just overload one file.
  *
  * @since 2.7.0
+ * @since 4.9.0 `$params` parameter added.
  *
  * @param string|array $template_names Template file(s) to search for, in order.
  * @param bool         $load           If true the template file will be loaded if it is found.
  * @param bool         $require_once   Whether to require_once or require. Default true. Has no effect if $load is false.
+ * @param array        $params         Additional arguments passed to the template.
  * @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, $params = array() ) {
 	$located = '';
 	foreach ( (array) $template_names as $template_name ) {
 		if ( !$template_name )
@@ -644,7 +646,7 @@
 	}
 
 	if ( $load && '' != $located )
-		load_template( $located, $require_once );
+		load_template( $located, $require_once, $params );
 
 	return $located;
 }
@@ -657,6 +659,7 @@
  * also available.
  *
  * @since 1.5.0
+ * @since 4.9.0 `$params` parameter added.
  *
  * @global array      $posts
  * @global WP_Post    $post
@@ -672,8 +675,9 @@
  *
  * @param string $_template_file Path to template file.
  * @param bool   $require_once   Whether to require_once or require. Default true.
+ * @param array  $params         Additional arguments passed to the template.
  */
-function load_template( $_template_file, $require_once = true ) {
+function load_template( $_template_file, $require_once = true, $params = array() ) {
 	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 ) ) {
Index: tests/phpunit/tests/general/template.php
===================================================================
--- tests/phpunit/tests/general/template.php	(revision 40927)
+++ tests/phpunit/tests/general/template.php	(working copy)
@@ -611,4 +611,12 @@
 
 		$this->assertSame( $expected, $result );
 	}
+
+	/**
+	 * @ticket 21676
+	 */
+	function test_load_template_with_params () {
+		load_template( DIR_TESTDATA . '/themedir1/theme1/header.php', false, array( 'foo' => 'baz' ) );
+		$this->expectOutputString( '{"foo":"baz"}' );
+	}
 }
Index: tests/phpunit/data/themedir1/theme1/header.php
===================================================================
--- tests/phpunit/data/themedir1/theme1/header.php	(revision 0)
+++ tests/phpunit/data/themedir1/theme1/header.php	(revision 0)
@@ -0,0 +1,2 @@
+<?php 
+echo json_encode($params);
