php – How can I remove a function that has been added to wordpress with add_filter?

Question

to begin with I am trying to modify a wordpress plugin.

I have created a function named fuxia_is_the_best. Then I add this function to the sanitize_title filter, with the use of this code:

add_filter('sanitize_title', 'fuxia_is_the_best');

and this add_filter function goes inside an if statement:

if ( $lama == 'green' ) {
  add_filter('sanitize_title', 'fuxia_is_the_best');
} else {
  remove_filter('sanitize_title', 'fuxia_is_the_best');
}

If you noticed I have an else statement in which I’m using the remove_filter() function.
But there goes my problem and the cause of this question in general. The remove_filter()
doesn’t actually remove the filter :/ .

Question:

  • What could have gone wrong?
  • Is there anything wrong in this php code above?

closure:
Thanks in advance for your time, you’re awesome!

0
Periklis Kakarakidis 1 year 2022-02-24T07:22:52-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse