WordPress filter hook · part of WordPress core

get_comment_text

A WordPress core filter that 17 plugins also fire themselves, running on 16K+ sites between them.

“This filter documented in wp-includes/comment-template.php”

How to use get_comment_text

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'get_comment_text', function( $comment_content ) {
	// Change $comment_content here.
	return $comment_content;
}, 10, 1 );

Argument names come from WP Tab Widget's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

17 plugins that fire get_comment_text

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WP Tab Widget icon WP Tab Widget10,000+ installs apply_filters( 'get_comment_text', $comment->comment_content ) wp-tab-widget.php:518
  2. Urvanov Syntax Highlighter icon Urvanov Syntax Highlighter3,000+ installs apply_filters( 'get_comment_text', $comment->comment_content, $comment ) class-urvanov-syntax-highlighter-plugin.php:588
  3. Simple Comment Editing icon Simple Comment Editing2,000+ installs apply_filters( 'get_comment_text', $comment_content_to_return, $comment, array() ) includes/Functions.php:84
  4. Mihdan: Ajax Edit Comments icon Mihdan: Ajax Edit Comments300+ installs apply_filters( 'get_comment_text', AECUtility::encode($comment['comment_content']) ) lib/class.ajax.php:395
  5. WP-UserAgent icon WP-UserAgent200+ installs apply_filters( 'get_comment_text', $comment->comment_content, $comment ) wp-useragent.php:197
  6. All-in-one Widget icon All-in-one Widget100+ installs apply_filters( 'get_comment_text', $comment->comment_content ) widgets/widget-tabs.php:508
  7. WP Foundation Shortcodes icon WP Foundation Shortcodes100+ installs apply_filters( 'get_comment_text', $comment->comment_content ) class.foundation_shortcodes.php:1879
  8. Comment Mail icon Comment Mail100+ installs apply_filters( 'get_comment_text', $markup, $comment, [] ) src/includes/classes/UtilsMarkup.php:772
  9. Super Related Posts icon Super Related Posts50+ installs apply_filters( 'get_comment_text', $value ) includes/output_tags.php:279
  10. Ajax Comment Preview icon Ajax Comment Preview40+ installs apply_filters( 'get_comment_text', $text ) ajax-comment-preview.php:120
  11. Expandable Dashboard Recent Comments icon Expandable Dashboard Recent Comments30+ installs apply_filters( 'get_comment_text', $comment->comment_content ) expandable-dashboard-recent-comments.php:207
  12. Ultra Community icon Ultra Community20+ installs apply_filters( 'get_comment_text', $userReviewComment->comment_content, $userReviewComment ) engine/Repository/UserRepository.php:385
  13. Vacant Line BReaker icon Vacant Line BReaker10+ installs apply_filters( 'get_comment_text', $comment->comment_content ) vacant-line-breaker.php:217
  14. WP-BigApp icon WP-BigApp10+ installs apply_filters( 'get_comment_text', $comment->comment_content, $comment ) lib/json/class-wp-json-comments.php:208
  15. AH Sidebar Box icon AH Sidebar Box10+ installs apply_filters( 'get_comment_text', $comment->comment_content ) includes/recent-comments.php:22
  16. WpApper icon WpApperFewer than 10 installs apply_filters( 'get_comment_text', $comment->comment_content, $comment ) lib/json/class-wp-json-comments.php:208
  17. User Agent Displayer icon User Agent DisplayerFewer than 10 installs apply_filters( 'get_comment_text', $comment->comment_content ) agent.php:337

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.