Where is the source code that makes the “all” array grabs filters in the $wp_filter?

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: }

Leave a Comment