From a03583016041f569fa1f4b816d98f21bdaf5cf51 Mon Sep 17 00:00:00 2001 From: David Baumwald Date: Tue, 11 May 2021 18:24:38 +0000 Subject: [PATCH] Bundled Theme: Update `twenty_twenty_one_password_form` function to actually use a `$post` parameter. The `twentytwentyone` filtered `the_password_form` with a `twenty_twenty_one_password_form` callback that, by default, passed only one parameter that was assumed to be the post or post ID. However, the first parameter for `the_password_form` is the filtered output value. This fix updates both the filter reference and callback to use two parameters: `$output` and `$post`. Props burhandodhy, mukesh27. Fixes #53091. git-svn-id: https://develop.svn.wordpress.org/trunk@50841 602fd350-edb4-49c9-b593-d223f7449a82 --- .../themes/twentytwentyone/inc/template-functions.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wp-content/themes/twentytwentyone/inc/template-functions.php b/src/wp-content/themes/twentytwentyone/inc/template-functions.php index 4e5fcd6abe..d84ef38d09 100644 --- a/src/wp-content/themes/twentytwentyone/inc/template-functions.php +++ b/src/wp-content/themes/twentytwentyone/inc/template-functions.php @@ -387,11 +387,14 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content * Retrieve protected post password form content. * * @since Twenty Twenty-One 1.0 + * @since Twenty Twenty-One 1.4 Corrected parameter name for `$output`, + * added the `$post` parameter. * - * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. + * @param string $output The password form HTML output. + * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return string HTML content for password form for password protected post. */ -function twenty_twenty_one_password_form( $post = 0 ) { +function twenty_twenty_one_password_form( $output, $post = 0 ) { $post = get_post( $post ); $label = 'pwbox-' . ( empty( $post->ID ) ? wp_rand() : $post->ID ); $output = '

' . esc_html__( 'This content is password protected. Please enter a password to view.', 'twentytwentyone' ) . '

@@ -400,7 +403,7 @@ function twenty_twenty_one_password_form( $post = 0 ) { '; return $output; } -add_filter( 'the_password_form', 'twenty_twenty_one_password_form' ); +add_filter( 'the_password_form', 'twenty_twenty_one_password_form', 10, 2 ); /** * Filters the list of attachment image attributes.