Walker_Comment::filter_comment_text() WordPress Method

The Walker_Comment::filter_comment_text() method is used to filter the text of a comment. The text of the comment is passed through the 'comment_text' filter before being displayed.

Walker_Comment::filter_comment_text( string $comment_text, WP_Comment|null $comment ) #

Filters the comment text.


Description

Removes links from the pending comment’s text if the commenter did not consent to the comment cookies.


Top ↑

Parameters

$comment_text

(string)(Required)Text of the current comment.

$comment

(WP_Comment|null)(Required)The comment object. Null if not found.


Top ↑

Return

(string) Filtered text of the current comment.


Top ↑

Source

File: wp-includes/class-walker-comment.php

	public function filter_comment_text( $comment_text, $comment ) {
		$commenter          = wp_get_current_commenter();
		$show_pending_links = ! empty( $commenter['comment_author'] );

		if ( $comment && '0' == $comment->comment_approved && ! $show_pending_links ) {
			$comment_text = wp_kses( $comment_text, array() );
		}

		return $comment_text;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.4.2Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.