Skip to content

Commit a035830

Browse files
committed
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
1 parent be105fd commit a035830

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/wp-content/themes/twentytwentyone/inc/template-functions.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,14 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content
387387
* Retrieve protected post password form content.
388388
*
389389
* @since Twenty Twenty-One 1.0
390+
* @since Twenty Twenty-One 1.4 Corrected parameter name for `$output`,
391+
* added the `$post` parameter.
390392
*
391-
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
393+
* @param string $output The password form HTML output.
394+
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
392395
* @return string HTML content for password form for password protected post.
393396
*/
394-
function twenty_twenty_one_password_form( $post = 0 ) {
397+
function twenty_twenty_one_password_form( $output, $post = 0 ) {
395398
$post = get_post( $post );
396399
$label = 'pwbox-' . ( empty( $post->ID ) ? wp_rand() : $post->ID );
397400
$output = '<p class="post-password-message">' . esc_html__( 'This content is password protected. Please enter a password to view.', 'twentytwentyone' ) . '</p>
@@ -400,7 +403,7 @@ function twenty_twenty_one_password_form( $post = 0 ) {
400403
';
401404
return $output;
402405
}
403-
add_filter( 'the_password_form', 'twenty_twenty_one_password_form' );
406+
add_filter( 'the_password_form', 'twenty_twenty_one_password_form', 10, 2 );
404407

405408
/**
406409
* Filters the list of attachment image attributes.

0 commit comments

Comments
 (0)