функция
since 6.2.0
_get_comment_reply_id()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
_get_comment_reply_id( int|WP_Post|null $post = null ): int
Описание
Получает идентификатор комментария, на который отвечают, из $_GET[‘replytocom’].
Параметры
$post
int|WP_Post|null
необязательный
= null
Запись, для которой отображается комментарий.
По умолчанию — текущая глобальная запись.
Возвращаемое значение
int
Исходный код
wp-includes/comment-template.php:2165
function _get_comment_reply_id( $post = null ) {
$post = get_post( $post );
if ( ! $post || ! isset( $_GET['replytocom'] ) || ! is_numeric( $_GET['replytocom'] ) ) {
return 0;
}
$reply_to_id = (int) $_GET['replytocom'];
/*
* Validate the comment.
* Bail out if it does not exist, is not approved, or its
* `comment_post_ID` does not match the given post ID.
*/
$comment = get_comment( $reply_to_id );
if (
! $comment instanceof WP_Comment ||
0 === (int) $comment->comment_approved ||
$post->ID !== (int) $comment->comment_post_ID
) {
return 0;
}
return $reply_to_id;
}
История изменений
| Версия | Описание |
|---|---|
| 6.2.0 | Introduced. |

