функция
since 3.0.0
get_comment_id_fields()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_comment_id_fields( int|WP_Post|null $post = null ): string
Описание
Получает HTML скрытых полей ввода для ответа на комментарии.
Параметры
$post
int|WP_Post|null
необязательный
= null
Запись, для которой отображается комментарий.
По умолчанию — текущая глобальная запись.
Возвращаемое значение
string
Исходный код
wp-includes/comment-template.php:2046
function get_comment_id_fields( $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return '';
}
$post_id = $post->ID;
$reply_to_id = _get_comment_reply_id( $post_id );
$comment_id_fields = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />\n";
$comment_id_fields .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$reply_to_id' />\n";
/**
* Filters the returned comment ID fields.
*
* @since 3.0.0
*
* @param string $comment_id_fields The HTML-formatted hidden ID field comment elements.
* @param int $post_id The post ID.
* @param int $reply_to_id The ID of the comment being replied to.
*/
return apply_filters( 'comment_id_fields', $comment_id_fields, $post_id, $reply_to_id );
}
История изменений
| Версия | Описание |
|---|---|
| 6.2.0 | Renamed $post_id to $post and added WP_Post support. |
| 3.0.0 | Introduced. |

