WordPress.org

Make WordPress Core

Changeset 48577


Ignore:
Timestamp:
07/23/2020 01:09:50 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Docs: Improve description for comment_id_fields().

Rename the $id parameter to $post_id for clarity.

Props stevenlinx.
Fixes #50737.

File:
1 edited

Legend:

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

    r48473 r48577  
    308308    $url     = '';
    309309    $id      = 0;
     310
    310311    if ( ! empty( $comment ) ) {
    311312        $author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url;
     
    15561557 */
    15571558function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
    1558     $id     = get_the_ID();
    1559     $title = get_the_title();
    1560     $number = get_comments_number( $id );
     1559    $post_id    = get_the_ID();
     1560    $post_title = get_the_title();
     1561    $number     = get_comments_number( $post_id );
    15611562
    15621563    if ( false === $zero ) {
    15631564        /* translators: %s: Post title. */
    1564         $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title );
     1565        $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $post_title );
    15651566    }
    15661567
    15671568    if ( false === $one ) {
    15681569        /* translators: %s: Post title. */
    1569         $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title );
     1570        $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $post_title );
    15701571    }
    15711572
     
    15731574        /* translators: 1: Number of comments, 2: Post title. */
    15741575        $more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number );
    1575         $more = sprintf( $more, number_format_i18n( $number ), $title );
     1576        $more = sprintf( $more, number_format_i18n( $number ), $post_title );
    15761577    }
    15771578
    15781579    if ( false === $none ) {
    15791580        /* translators: %s: Post title. */
    1580         $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title );
     1581        $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $post_title );
    15811582    }
    15821583
     
    16001601         *
    16011602         * @param string $respond_link The default response link.
    1602          * @param integer $id The post ID.
     1603         * @param int    $post_id      The post ID.
    16031604         */
    1604         echo apply_filters( 'respond_link', $respond_link, $id );
     1605        echo apply_filters( 'respond_link', $respond_link, $post_id );
    16051606    } else {
    16061607        comments_link();
     
    19111912 * @since 3.0.0
    19121913 *
    1913  * @param int $id Optional. Post ID. Default current post ID.
    1914  * @return string Hidden input HTML for replying to comments
    1915  */
    1916 function get_comment_id_fields( $id = 0 ) {
    1917     if ( empty( $id ) ) {
    1918         $id = get_the_ID();
     1914 * @param int $post_id Optional. Post ID. Defaults to the current post ID.
     1915 * @return string Hidden input HTML for replying to comments.
     1916 */
     1917function get_comment_id_fields( $post_id = 0 ) {
     1918    if ( empty( $post_id ) ) {
     1919        $post_id = get_the_ID();
    19191920    }
    19201921
    19211922    $replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0;
    1922     $result    = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
     1923    $result    = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />\n";
    19231924    $result   .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
    19241925
     
    19281929     * @since 3.0.0
    19291930     *
    1930      * @param string $result    The HTML-formatted hidden id field comment elements.
    1931      * @param int    $id        The post ID.
    1932      * @param int    $replytoid The id of the comment being replied to.
    1933      */
    1934     return apply_filters( 'comment_id_fields', $result, $id, $replytoid );
     1931     * @param string $result    The HTML-formatted hidden ID field comment elements.
     1932     * @param int    $post_id   The post ID.
     1933     * @param int    $replytoid The ID of the comment being replied to.
     1934     */
     1935    return apply_filters( 'comment_id_fields', $result, $post_id, $replytoid );
    19351936}
    19361937
     
    19381939 * Outputs hidden input HTML for replying to comments.
    19391940 *
     1941 * Adds two hidden inputs to the comment form to identify the `comment_post_ID`
     1942 * and `comment_parent` values for threaded comments.
     1943 *
     1944 * This tag must be within the `<form>` section of the `comments.php` template.
     1945 *
    19401946 * @since 2.7.0
    19411947 *
    1942  * @param int $id Optional. Post ID. Default current post ID.
    1943  */
    1944 function comment_id_fields( $id = 0 ) {
    1945     echo get_comment_id_fields( $id );
     1948 * @see get_comment_id_fields()
     1949 *
     1950 * @param int $post_id Optional. Post ID. Defaults to the current post ID.
     1951 */
     1952function comment_id_fields( $post_id = 0 ) {
     1953    echo get_comment_id_fields( $post_id );
    19461954}
    19471955
Note: See TracChangeset for help on using the changeset viewer.