我认为您对该功能感兴趣:_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: }
请记住添加过滤器时,会将其写入
$wp_filter
全球的动作也是如此。
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: }
事实上,操作和过滤器非常接近:看看这个:
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: }