1

As the Question states, Where is the source code that makes the "all" array grabs filters in the $wp_filter?

I have searched the whole core about any definition to this and i just could find the if ( isset($wp_filter['all']) ) .. so if there is an isset it has to be set some where ... where is the source code that makes the all array grabs filters what would set the condition if ( isset($wp_filter['all']) ) to true

1 Answer 1

1

I think you are interested in this function: _wp_call_all_hook.

File: wp-includes/plugin.php
816: /**
817:  * Call the 'all' hook, which will process the functions hooked into it.
818:  *
819:  * The 'all' hook passes all of the arguments or parameters that were used for
820:  * the hook, which this function was called for.
821:  *
822:  * This function is used internally for apply_filters(), do_action(), and
823:  * do_action_ref_array() and is not meant to be used from outside those
824:  * functions. This function does not check for the existence of the all hook, so
825:  * it will fail unless the all hook exists prior to this function call.
826:  *
827:  * @since 2.5.0
828:  * @access private
829:  *
830:  * @global array $wp_filter  Stores all of the filters
831:  *
832:  * @param array $args The collected parameters from the hook that was called.
833:  */
834: function _wp_call_all_hook($args) {
835:    global $wp_filter;
836: 
837:    $wp_filter['all']->do_all_hook( $args );
838: }

Keep in mind.

When you add a filter you write to the $wp_filter global. The same is for the actions.

File: wp-includes/plugin.php
106: function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
107:    global $wp_filter;
108:    if ( ! isset( $wp_filter[ $tag ] ) ) {
109:        $wp_filter[ $tag ] = new WP_Hook();
110:    }
111:    $wp_filter[ $tag ]->add_filter( $tag, $function_to_add, $priority, $accepted_args );
112:    return true;
113: }

In fact, actions and filters are so close: Look at this:

File: wp-includes/plugin.php
398: function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
399:    return add_filter($tag, $function_to_add, $priority, $accepted_args);
400: }
2
  • Oooooh I have spent about one month to get this answer ... you saved me man and I really thank you .. If it would be possible I should accept this answer twice.. thaaaanks Jan 3, 2017 at 20:20
  • No problem. You can check my other answer on the question you asked before this one.
    – prosti
    Jan 3, 2017 at 20:22

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.