2

Savvy WordPress user here, or at least trying to be. I have the hang of hooks and filters with the code in WP's plugin.php

The only thing I cannot seem to understand is the $merged_filters global. The value for a tag is unset when a filter or action is added.

However, when an action or filter is executed, the $merged_filters[$tag] value is set to "true".

What is the purpose of this?

Thank you

1
  • Check if this helps...
    – brasofilo
    Commented Mar 11, 2013 at 13:05

1 Answer 1

1

For those of you who may be wondering what this does - I have figured it out.

When a new function is added to an action/filter hook, it is added at the end of the array. However, WordPress specifies that those functions are to be executed by priority.

When a function is added, merged_filters is used to keep track of whether functions for a hook have been sorted by priority or not. merged_filters is checked on do_action/apply_filters to determine whether the functions should be sorted (by priority) or not before the hook is executed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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