I have a filter that's being applied, but I can't find a corresponding call to add_filter(). Is there any other way it could be added?

Specifically: I'm trying to maintain/make some changes to a Wordpress plugin (privately developed, and the original developer is not available to contact), and for my current change, I've traced the execution path I'm looking at to the call:

$output = apply_filters('<plugin_name>-output-block', $output, $my_args);

However I cannot for the life of me find where the filter is being defined. I've grepped through the plugin's entire codebase for "<plugin_name>-output-block" and nothing. I've also grepped for every instance of "add_filter" in case it's being called with the filter name in a variable... and still nothing. As far as I can determine, the filter is never being added.

(I am aware of the functionality where you can use apply_filters() to simply define a new hook on the fly, but I don't think that's what's happening here (or at least is not the only thing); if I comment out that line, the output definitely breaks... so there's existing functionality behind there that's being called.)

So: is there another way that the filter could be being added? A mechanism other than add_filter()? Could it be added under a different name and then renamed somewhere? What am I missing?

  • Are you sure that line changes the value of $output to something other than '<plugin_name>-output-block'' ?
    – mozboz
    Jul 28, 2020 at 10:16

1 Answer 1


I've grepped through the plugin's entire codebase for "<plugin_name>-output-block" and nothing.

(Revised answer) Actually, you could just deactivate all other plugins and/or switch to a default (and unmodified) theme like the Twenty Twenty theme to see whether the issue is caused by another plugin or the active theme. But even so, I hope the following helps.

is there another way that the filter could be being added? A mechanism other than add_filter()?

Basically, that's the only proper way of registering a callback for a certain filter hook.

However, the callback can also be registered by calling add_action() instead of add_filter() (add_action() is just a wrapper for add_filter()), so try searching for that in the active theme and your plugin if necessary. For example, using regular expression (RegEx), try searching for add_(filter|action).+output\-block in the theme/plugin files (PHP files).

And although unlikely, you can also try searching in the theme for $wp_filter (which points to $GLOBALS['wp_filter']) in case it's accessed directly to register the filter callback...

Quick & Easy (but tricky) way without manually searching in the theme/plugin files: Use Query Monitor (QM) with do_action()

(Well, you'd still need to search, but it would be much easier.)

I'm in no way affiliated with QM, neither the plugin nor its author(s), but QM can help you find the code which hooks to the <plugin_name>-output-block hook.

  1. In your plugin, temporarily use do_action() and not apply_filters():

    $output = do_action('<plugin_name>-output-block', $output, $my_args);       // use this
    //$output = apply_filters('<plugin_name>-output-block', $output, $my_args); // not this

    But since you said, "if I comment out that line, the output definitely breaks", then you may have to uncomment the second line above. But then, doing so means that all the hook callbacks will be called at least twice, so try first with the second line commented out.

  2. Then just click on the "Hooks & Actions" item in the QM admin toolbar menu and select the "block" hook from the drop-down menu in the left side:

    enter image description here

  • Thanks Sally. I'm still chasing the issue down -- haven't resolved it yet, but your suggestion of Query Monitor was helpful in several ways. It is turning out to be a great tool! Even though I haven't actually yet gotten to the root of my problem (I have several other things I'm simultaneously working on), I'm accepting the answer based on its general utility.
    – mrputter
    Jul 31, 2020 at 22:13
  • Perhaps the revised answer helps you more? But if not, then if you want, I can help you further by trying the plugin and checking its code. Let me know.
    – Sally CJ
    Aug 3, 2020 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.