hooks[] = array( 'action', $hook, $component, $callback, $priority, $accepted_args ); } /** * Add filter. * * @param string $hook Value. * @param object $component Value. * @param string $callback Value. * @param int $priority Value. * @param int $accepted_args Value. */ public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { $this->hooks[] = array( 'filter', $hook, $component, $callback, $priority, $accepted_args ); } /** * Registers every collected hook once, then clears the queue * so calling run() twice cannot duplicate hooks. * * @return void */ public function run() { foreach ( $this->hooks as $hook ) { list( $type, $name, $component, $callback, $priority, $args ) = $hook; $function = ( 'action' === $type ) ? 'add_action' : 'add_filter'; $function( $name, array( $component, $callback ), $priority, $args ); } $this->hooks = array(); } }