WordPress.org

Make WordPress Core

Changeset 47366


Ignore:
Timestamp:
02/25/2020 05:32:34 PM (22 months ago)
Author:
SergeyBiryukov
Message:

Comments: Restore the fourth parameter of comments_number() as $post_id, for consistency with get_comments_number_text().

The parameter was previously used as the number of comments, marked as deprecated in [5101].

Given that it's been deprecated for the last 13 years, it should be safe to undeprecate and repurpose it for a cleaner function signature, instead of adding a fifth parameter.

Follow-up to [47276].

Fixes #48772.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r47287 r47366  
    871871 *
    872872 * @since 0.71
    873  * @since 5.4.0 Added the `$post_id` parameter.
     873 * @since 5.4.0 The `$deprecated` parameter was changed to `$post_id`.
    874874 *
    875875 * @param string      $zero       Optional. Text for no comments. Default false.
    876876 * @param string      $one        Optional. Text for one comment. Default false.
    877877 * @param string      $more       Optional. Text for more than one comment. Default false.
    878  * @param string      $deprecated Not used.
    879878 * @param int|WP_Post $post_id    Optional. Post ID or WP_Post object. Default is the global `$post`.
    880879 */
    881 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $post_id = 0 ) {
    882     if ( ! empty( $deprecated ) ) {
    883         _deprecated_argument( __FUNCTION__, '1.3.0' );
    884     }
     880function comments_number( $zero = false, $one = false, $more = false, $post_id = 0 ) {
    885881    echo get_comments_number_text( $zero, $one, $more, $post_id );
    886882}
  • trunk/tests/phpunit/tests/comment/template.php

    r47276 r47366  
    4141
    4242        $this->assertEquals( sprintf( _n( '%s Comment', '%s Comments', 6 ), '6' ), $comments_number_text );
     43
     44        ob_start();
     45        comments_number( false, false, false, $post_id );
     46        $comments_number_text = ob_get_clean();
     47
     48        $this->assertEquals( sprintf( _n( '%s Comment', '%s Comments', 6 ), '6' ), $comments_number_text );
     49
    4350    }
    4451
Note: See TracChangeset for help on using the changeset viewer.