should_dispatch() ) { return; } $this->before_output(); foreach ( $this->get_outputters( 'headers' ) as $id => $output ) { $output->output(); } $this->after_output(); } /** * @return void */ protected function before_output() { foreach ( (array) glob( $this->qm->plugin_path( 'output/headers/*.php' ) ) as $file ) { require_once $file; } } /** * @return void */ protected function after_output() { # flush once, because we're nice if ( ob_get_length() ) { ob_flush(); } } /** * @return bool */ public function is_active() { if ( ! QM_Util::is_ajax() ) { return false; } if ( ! self::user_can_view() ) { return false; } # If the headers have already been sent then we can't do anything about it if ( headers_sent() ) { return false; } # Don't process if the minimum required actions haven't fired: if ( is_admin() ) { if ( ! did_action( 'admin_init' ) ) { return false; } } else { if ( ! did_action( 'wp' ) ) { return false; } } return true; } } /** * @param array $dispatchers * @param QM_Plugin $qm * @return array */ function register_qm_dispatcher_ajax( array $dispatchers, QM_Plugin $qm ) { $dispatchers['ajax'] = new QM_Dispatcher_AJAX( $qm ); return $dispatchers; } add_filter( 'qm/dispatchers', 'register_qm_dispatcher_ajax', 10, 2 );