Docs: Improve description for `comment_id_fields()`.

Rename the `$id` parameter to `$post_id` for clarity.

Props stevenlinx.
Fixes #50737.
Built from https://develop.svn.wordpress.org/trunk@48577


git-svn-id: http://core.svn.wordpress.org/trunk@48339 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-23 13:11:04 +00:00
parent 124972f2c6
commit d1b980492f
2 changed files with 31 additions and 23 deletions

View File

@ -307,6 +307,7 @@ function get_comment_author_url( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID ); $comment = get_comment( $comment_ID );
$url = ''; $url = '';
$id = 0; $id = 0;
if ( ! empty( $comment ) ) { if ( ! empty( $comment ) ) {
$author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url; $author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url;
$url = esc_url( $author_url, array( 'http', 'https' ) ); $url = esc_url( $author_url, array( 'http', 'https' ) );
@ -1555,29 +1556,29 @@ function comments_template( $file = '/comments.php', $separate_comments = false
* @param false|string $none Optional. String to display when comments have been turned off. Default false. * @param false|string $none Optional. String to display when comments have been turned off. Default false.
*/ */
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
$id = get_the_ID(); $post_id = get_the_ID();
$title = get_the_title(); $post_title = get_the_title();
$number = get_comments_number( $id ); $number = get_comments_number( $post_id );
if ( false === $zero ) { if ( false === $zero ) {
/* translators: %s: Post title. */ /* translators: %s: Post title. */
$zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title ); $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $post_title );
} }
if ( false === $one ) { if ( false === $one ) {
/* translators: %s: Post title. */ /* translators: %s: Post title. */
$one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title ); $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $post_title );
} }
if ( false === $more ) { if ( false === $more ) {
/* translators: 1: Number of comments, 2: Post title. */ /* translators: 1: Number of comments, 2: Post title. */
$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 ); $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 );
$more = sprintf( $more, number_format_i18n( $number ), $title ); $more = sprintf( $more, number_format_i18n( $number ), $post_title );
} }
if ( false === $none ) { if ( false === $none ) {
/* translators: %s: Post title. */ /* translators: %s: Post title. */
$none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $post_title );
} }
if ( 0 == $number && ! comments_open() && ! pings_open() ) { if ( 0 == $number && ! comments_open() && ! pings_open() ) {
@ -1599,9 +1600,9 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c
* @since 4.4.0 * @since 4.4.0
* *
* @param string $respond_link The default response link. * @param string $respond_link The default response link.
* @param integer $id The post ID. * @param int $post_id The post ID.
*/ */
echo apply_filters( 'respond_link', $respond_link, $id ); echo apply_filters( 'respond_link', $respond_link, $post_id );
} else { } else {
comments_link(); comments_link();
} }
@ -1910,16 +1911,16 @@ function cancel_comment_reply_link( $text = '' ) {
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param int $id Optional. Post ID. Default current post ID. * @param int $post_id Optional. Post ID. Defaults to the current post ID.
* @return string Hidden input HTML for replying to comments * @return string Hidden input HTML for replying to comments.
*/ */
function get_comment_id_fields( $id = 0 ) { function get_comment_id_fields( $post_id = 0 ) {
if ( empty( $id ) ) { if ( empty( $post_id ) ) {
$id = get_the_ID(); $post_id = get_the_ID();
} }
$replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; $replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0;
$result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; $result = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />\n";
$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n"; $result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
/** /**
@ -1927,22 +1928,29 @@ function get_comment_id_fields( $id = 0 ) {
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param string $result The HTML-formatted hidden id field comment elements. * @param string $result The HTML-formatted hidden ID field comment elements.
* @param int $id The post ID. * @param int $post_id The post ID.
* @param int $replytoid The id of the comment being replied to. * @param int $replytoid The ID of the comment being replied to.
*/ */
return apply_filters( 'comment_id_fields', $result, $id, $replytoid ); return apply_filters( 'comment_id_fields', $result, $post_id, $replytoid );
} }
/** /**
* Outputs hidden input HTML for replying to comments. * Outputs hidden input HTML for replying to comments.
* *
* Adds two hidden inputs to the comment form to identify the `comment_post_ID`
* and `comment_parent` values for threaded comments.
*
* This tag must be within the `<form>` section of the `comments.php` template.
*
* @since 2.7.0 * @since 2.7.0
* *
* @param int $id Optional. Post ID. Default current post ID. * @see get_comment_id_fields()
*
* @param int $post_id Optional. Post ID. Defaults to the current post ID.
*/ */
function comment_id_fields( $id = 0 ) { function comment_id_fields( $post_id = 0 ) {
echo get_comment_id_fields( $id ); echo get_comment_id_fields( $post_id );
} }
/** /**

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-beta3-48576'; $wp_version = '5.5-beta3-48577';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.