public function run_ajax() {
    global $wp_query;

    if ( $wp_query->get("no-admin-ajax") ) {
      // Constant for plugins to know that we are on an AJAX request
      define("DOING_AJAX", true);

      // If we don't have an action, do nothing
      if ( ! isset( $_REQUEST["action"] ) ) {
          die(0);
      }

      // Escape the parameter to prevent disastrous things
      $action = esc_attr( $_REQUEST["action"] );

      // Run customized no-admin-ajax methods with action "no-admin-ajax/before"
      do_action( "no-admin-ajax/before" );

      // Run customized no-admin-ajax methods for specific ajax actions with "no-admin-ajax/before/{action}"
      do_action( "no-admin-ajax/before/". $action );

      // Same headers as WordPress normal AJAX routine sends
      $default_headers = array(
        "Content-Type: text/html; charset=" . get_option( "blog_charset" ),
        "X-Robots-Tag: noindex"
      );

      // Filter to customize the headers sent by ajax calls
      $headers = apply_filters( "no-admin-ajax/headers", $default_headers );

      // Send the headers to the user
      if ( is_array( $headers ) && count( $headers ) > 0 ) {
        foreach ( $headers as $header ) {
          @header( $header );
        }
      }

      send_nosniff_header();
      nocache_headers();

      // Run the actions
      if(is_user_logged_in()) {
          do_action( "wp_ajax_" . $action );
      }
      else {
          do_action( "wp_ajax_nopriv_" . $action );
      }

      die(0);
    }
  }