comment_form_title()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
comment_form_title( string|false $no_reply_text = false, string|false $reply_text = false, bool $link_to_parent = true, int|WP_Post|null $post = null )
Описание
Влияет только на пользователей с отключённым JavaScript.
{@internal Глобальная переменная $comment должна присутствовать, чтобы шаблонные теги имели доступ к текущему комментарию. См. https://core.trac.wordpress.org/changeset/36512.}
Оригинал (английский)
Only affects users with JavaScript disabled.
{@internal The $comment global must be present to allow template tags access to the current comment. See https://core.trac.wordpress.org/changeset/36512.}
Параметры
$no_reply_text
string|false
необязательный
= false
$reply_text
string|false
необязательный
= false
$link_to_parent
bool
необязательный
= true
$post
int|WP_Post|null
необязательный
= null
Исходный код
wp-includes/comment-template.php:2113
function comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true, $post = null ) {
global $comment;
if ( false === $no_reply_text ) {
$no_reply_text = __( 'Leave a Reply' );
}
if ( false === $reply_text ) {
/* translators: %s: Author of the comment being replied to. */
$reply_text = __( 'Leave a Reply to %s' );
}
$post = get_post( $post );
if ( ! $post ) {
echo $no_reply_text;
return;
}
$reply_to_id = _get_comment_reply_id( $post->ID );
if ( 0 === $reply_to_id ) {
echo $no_reply_text;
return;
}
// Sets the global so that template tags can be used in the comment form.
$comment = get_comment( $reply_to_id );
if ( $link_to_parent ) {
$comment_author = sprintf(
'<a href="#comment-%1$s">%2$s</a>',
get_comment_ID(),
get_comment_author( $reply_to_id )
);
} else {
$comment_author = get_comment_author( $reply_to_id );
}
printf( $reply_text, $comment_author );
}
История изменений
| Версия | Описание |
|---|---|
| 6.2.0 | Added the $post parameter. |
| 2.7.0 | Introduced. |

