diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/general-template.php --- a/wp/wp-includes/general-template.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-includes/general-template.php Tue Dec 15 13:49:49 2020 +0100 @@ -16,19 +16,26 @@ * "special". * * @since 1.5.0 + * @since 5.5.0 A return value was added. + * @since 5.5.0 The `$args` parameter was added. * * @param string $name The name of the specialised header. + * @param array $args Optional. Additional arguments passed to the header template. + * Default empty array. + * @return void|false Void on success, false if the template does not exist. */ -function get_header( $name = null ) { +function get_header( $name = null, $args = array() ) { /** * Fires before the header template file is loaded. * * @since 2.1.0 - * @since 2.8.0 $name parameter added. + * @since 2.8.0 The `$name` parameter was added. + * @since 5.5.0 The `$args` parameter was 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 $args Additional arguments passed to the header template. */ - do_action( 'get_header', $name ); + do_action( 'get_header', $name, $args ); $templates = array(); $name = (string) $name; @@ -38,7 +45,9 @@ $templates[] = 'header.php'; - locate_template( $templates, true ); + if ( ! locate_template( $templates, true, true, $args ) ) { + return false; + } } /** @@ -51,19 +60,26 @@ * "special". * * @since 1.5.0 + * @since 5.5.0 A return value was added. + * @since 5.5.0 The `$args` parameter was added. * * @param string $name The name of the specialised footer. + * @param array $args Optional. Additional arguments passed to the footer template. + * Default empty array. + * @return void|false Void on success, false if the template does not exist. */ -function get_footer( $name = null ) { +function get_footer( $name = null, $args = array() ) { /** * Fires before the footer template file is loaded. * * @since 2.1.0 - * @since 2.8.0 $name parameter added. + * @since 2.8.0 The `$name` parameter was added. + * @since 5.5.0 The `$args` parameter was 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 $args Additional arguments passed to the footer template. */ - do_action( 'get_footer', $name ); + do_action( 'get_footer', $name, $args ); $templates = array(); $name = (string) $name; @@ -73,7 +89,9 @@ $templates[] = 'footer.php'; - locate_template( $templates, true ); + if ( ! locate_template( $templates, true, true, $args ) ) { + return false; + } } /** @@ -86,19 +104,26 @@ * "special". * * @since 1.5.0 + * @since 5.5.0 A return value was added. + * @since 5.5.0 The `$args` parameter was added. * * @param string $name The name of the specialised sidebar. + * @param array $args Optional. Additional arguments passed to the sidebar template. + * Default empty array. + * @return void|false Void on success, false if the template does not exist. */ -function get_sidebar( $name = null ) { +function get_sidebar( $name = null, $args = array() ) { /** * Fires before the sidebar template file is loaded. * * @since 2.2.0 - * @since 2.8.0 $name parameter added. + * @since 2.8.0 The `$name` parameter was added. + * @since 5.5.0 The `$args` parameter was 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 $args Additional arguments passed to the sidebar template. */ - do_action( 'get_sidebar', $name ); + do_action( 'get_sidebar', $name, $args ); $templates = array(); $name = (string) $name; @@ -108,7 +133,9 @@ $templates[] = 'sidebar.php'; - locate_template( $templates, true ); + if ( ! locate_template( $templates, true, true, $args ) ) { + return false; + } } /** @@ -128,11 +155,16 @@ * "special". * * @since 3.0.0 + * @since 5.5.0 A return value was added. + * @since 5.5.0 The `$args` parameter was added. * * @param string $slug The slug name for the generic template. * @param string $name The name of the specialised template. + * @param array $args Optional. Additional arguments passed to the template. + * Default empty array. + * @return void|false Void on success, false if the template does not exist. */ -function get_template_part( $slug, $name = null ) { +function get_template_part( $slug, $name = null, $args = array() ) { /** * Fires before the specified template part file is loaded. * @@ -140,11 +172,13 @@ * for the generic template part. * * @since 3.0.0 + * @since 5.5.0 The `$args` parameter was added. * * @param string $slug The slug name for the generic template. * @param string|null $name The name of the specialized template. + * @param array $args Additional arguments passed to the template. */ - do_action( "get_template_part_{$slug}", $slug, $name ); + do_action( "get_template_part_{$slug}", $slug, $name, $args ); $templates = array(); $name = (string) $name; @@ -158,14 +192,18 @@ * Fires before a template part is loaded. * * @since 5.2.0 + * @since 5.5.0 The `$args` parameter was added. * * @param string $slug The slug name for the generic template. * @param string $name The name of the specialized template. * @param string[] $templates Array of template files to search for, in order. + * @param array $args Additional arguments passed to the template. */ - do_action( 'get_template_part', $slug, $name, $templates ); - - locate_template( $templates, true, false ); + do_action( 'get_template_part', $slug, $name, $templates, $args ); + + if ( ! locate_template( $templates, true, false, $args ) ) { + return false; + } } /** @@ -186,7 +224,7 @@ * search. To give a few examples of what it can be used for. * * @since 2.7.0 - * @since 5.2.0 The $args array parameter was added in place of an $echo boolean flag. + * @since 5.2.0 The `$args` array parameter was added in place of an `$echo` boolean flag. * * @param array $args { * Optional. Array of display arguments. @@ -196,7 +234,7 @@ * multiple search forms on the same page and improve * accessibility. Default empty. * } - * @return string|void String when the $echo param is false. + * @return void|string Void if 'echo' argument is true, search form HTML if 'echo' is false. */ function get_search_form( $args = array() ) { /** @@ -204,10 +242,13 @@ * * @since 2.7.0 as 'get_search_form' action. * @since 3.6.0 + * @since 5.5.0 The `$args` parameter was added. * * @link https://core.trac.wordpress.org/ticket/19321 + * + * @param array $args The array of arguments for building the search form. */ - do_action( 'pre_get_search_form' ); + do_action( 'pre_get_search_form', $args ); $echo = true; @@ -246,16 +287,19 @@ * Filters the HTML format of the search form. * * @since 3.6.0 + * @since 5.5.0 The `$args` parameter was added. * * @param string $format The type of markup to use in the search form. * Accepts 'html5', 'xhtml'. + * @param array $args The array of arguments for building the search form. */ - $format = apply_filters( 'search_form_format', $format ); + $format = apply_filters( 'search_form_format', $format, $args ); $search_form_template = locate_template( 'searchform.php' ); - if ( '' != $search_form_template ) { + + if ( '' !== $search_form_template ) { ob_start(); - require( $search_form_template ); + require $search_form_template; $form = ob_get_clean(); } else { // Build a string containing an aria-label to use for the search form. @@ -268,7 +312,8 @@ */ $aria_label = ''; } - if ( 'html5' == $format ) { + + if ( 'html5' === $format ) { $form = '