public static function doAction($tag, $arg = '') { $args = func_get_args(); $args = array_slice($args, 1); if (self::$type === HookMock::WP_MOCK) { \WP_Mock::onAction($tag)->react($args); } if (self::$type === HookMock::TRUE_HOOKS) { $relatedHooks = self::getRelatedHooks($tag, 'actions'); foreach ($relatedHooks as $hook) { $fn = $hook['fn']; $acceptedArgs = $hook['args']; call_user_func_array($fn, array_slice($args, 0, $acceptedArgs)); } } }
/** * Execute functions hooked on a specific action hook. * * @param string $tag The name of the action to be executed. * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. * * @return null Will return null if $tag does not exist in $wp_filter array */ function do_action($tag, $arg = '') { $args = func_get_args(); $args = array_slice($args, 1); return \WP_Mock::onAction($tag)->react($args); }