Title: Walker_Comment::filter_comment_text
Published: August 11, 2020
Last modified: August 20, 2026

---

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

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#wp--skip-link--target)

Filters the comment text.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#parameters)󠁿

 `$comment_text`stringrequired

Text of the current comment.

`$comment`[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
|nullrequired

The comment object. Null if not found.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#return)󠁿

 string Filtered text of the current comment.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#source)󠁿

    ```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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-walker-comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-walker-comment.php#L277)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-walker-comment.php#L277-L286)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_kses()](https://developer.wordpress.org/reference/functions/wp_kses/)`wp-includes/kses.php` |

Filters text content and strips out disallowed HTML.

  | 
| [wp_get_current_commenter()](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/)`wp-includes/comment.php` |

Gets current commenter’s name, email, and URL.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.4.2](https://developer.wordpress.org/reference/since/5.4.2/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwalker_comment%2Ffilter_comment_text%2F)
before being able to contribute a note or feedback.