is_ajax() public static method

public static is_ajax ( )
Beispiel #1
0
 public function after_output()
 {
     # flush once, because we're nice
     if (QM_Util::is_ajax() and ob_get_length()) {
         ob_flush();
     }
 }
 public function output()
 {
     if (!QM_Util::is_ajax()) {
         return;
     }
     $data = $this->collector->get_data();
     if (empty($data['errors'])) {
         return;
     }
     $count = 0;
     foreach ($data['errors'] as $type => $errors) {
         foreach ($errors as $key => $error) {
             $count++;
             # @TODO we should calculate the component during process() so we don't need to do it
             # separately in each output.
             $component = $error->trace->get_component();
             $output_error = array('type' => $error->type, 'message' => wp_strip_all_tags($error->message), 'file' => $error->file, 'line' => $error->line, 'stack' => $error->trace->get_stack(), 'component' => $component->name);
             header(sprintf('X-QM-Error-%d: %s', $count, json_encode($output_error)));
         }
     }
     header(sprintf('X-QM-Errors: %d', $count));
 }
Beispiel #3
0
 public function is_active()
 {
     if (!QM_Util::is_ajax()) {
         return false;
     }
     if (!$this->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;
 }