should_dispatch() ) { return $result; } $this->before_output(); /** @var array $outputters */ $outputters = $this->get_outputters( 'headers' ); foreach ( $outputters as $output ) { $output->output(); } $this->after_output(); return $result; } /** * @return void */ protected function before_output() { foreach ( (array) glob( $this->qm->plugin_path( 'output/headers/*.php' ) ) as $file ) { include_once $file; } } /** * @return bool */ public function is_active() { # If the headers have already been sent then we can't do anything about it if ( headers_sent() ) { return false; } if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) { return false; } if ( ! self::user_can_view() ) { return false; } return true; } } /** * @param array $dispatchers * @param QM_Plugin $qm * @return array */ function register_qm_dispatcher_rest( array $dispatchers, QM_Plugin $qm ) { $dispatchers['rest'] = new QM_Dispatcher_REST( $qm ); return $dispatchers; } add_filter( 'qm/dispatchers', 'register_qm_dispatcher_rest', 10, 2 );