Override a function defined in wp-includes/comment-template.php

I need to override the function get_cancel_comment_reply_link or cancel_comment_reply_link that are defined in

wp-includes/comment-template.php

These functions are not listed in pluggable.php.

How can I override them from my theme's functions.php?

I tried

remove_filter('get_cancel_comment_reply_link', 'cancel_comment_reply_link');
add_filter('get_cancel_comment_reply_link', function($text='') { return ''; }, 1, 1);

without success.

Topic functions actions php filters pluggable Wordpress

Category Web


If you look at the end of the function get_cancel_comment_reply_link( $text = '' ) in the file wp-includes/comment-template.php, you see the filter cancel_comment_reply_link.

return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );

It may work.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.