[wp-trac] [WordPress Trac] #53091: [Twenty Twenty-One] Incorrect use of `the_password_form` filter argument

WordPress Trac noreply at wordpress.org
Mon Apr 26 17:59:15 UTC 2021


#53091: [Twenty Twenty-One] Incorrect use of `the_password_form` filter argument
------------------------------------+----------------------------
 Reporter:  burhandodhy             |       Owner:  davidbaumwald
     Type:  defect (bug)            |      Status:  accepted
 Priority:  normal                  |   Milestone:  5.7.2
Component:  Bundled Theme           |     Version:  5.6
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+----------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:10 davidbaumwald]:
 > With [50791] in place, what would you like to see done on this ticket?

 Good question :) My initial thought was option 1, since we want the theme
 to remain compatible with WP 5.6 and 5.7.

 But it looks like if we set a default value for `$post`, that would also
 be compatible with older WP versions:
 {{{
 /**
  * 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 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( $output, $post = 0 ) {
         $post   = get_post( $post );
         ...
         return $output;
 }
 add_filter( 'the_password_form', 'twenty_twenty_one_password_form', 10, 2
 );
 }}}

 So both options are technically interchangeable. I guess option 2 might be
 a bit cleaner, as it keeps the current behavior on WP 5.6 and 5.7, and
 offers better compatibility with WP 5.8.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53091#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list