public static function generate_json_by_post($post_ids)
 {
     $result = array();
     $result = self::start_json($post_ids);
     $filename = apply_filters('spotim_json_download_filename', sprintf('spotim-export-%s.json', date_i18n('d-m-Y_h-i', time())));
     require_once 'class-spotim-jsonpretty.php';
     $json_pretty = new SpotIM_JsonPretty();
     echo $json_pretty->prettify(json_encode($result));
     die;
 }
 public static function generate_json()
 {
     $result = array();
     $result = self::start();
     $filename = apply_filters('spotim_json_download_filename', sprintf('spotim-export-%s.json', date_i18n('d-m-Y_h-i', time())));
     // do headers
     SpotIM_Util::send_headers(array('Content-Disposition' => "attachment; filename={$filename}", 'Pragma' => 'no-cache', 'Expires' => '0', 'Content-Type' => 'application/json; charset=' . get_option('blog_charset')));
     require_once 'class-spotim-jsonpretty.php';
     $json_pretty = new SpotIM_JsonPretty();
     echo $json_pretty->prettify(json_encode($result));
     wp_die();
 }
 /**
  * Generate a JSON response given an array of data
  *
  * @since 2.1
  * @param array $data the response data
  * @return string
  */
 public function generate_response($data)
 {
     if (isset($_GET['_jsonp'])) {
         // JSONP enabled by default
         if (!apply_filters('SpotIM_api_jsonp_enabled', true)) {
             WC()->api->server->send_status(400);
             $data = array(array('code' => 'SpotIM_api_jsonp_disabled', 'message' => __('JSONP support is disabled on this site', 'wp-spotim')));
         }
         // Check for invalid characters (only alphanumeric allowed)
         if (preg_match('/\\W/', $_GET['_jsonp'])) {
             WC()->api->server->send_status(400);
             $data = array(array('code' => 'SpotIM_api_jsonp_callback_invalid', __('The JSONP callback function is invalid', 'wp-spotim')));
         }
         // see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
         WC()->api->server->header('X-Content-Type-Options', 'nosniff');
         // Prepend '/**/' to mitigate possible JSONP Flash attacks
         return '/**/' . $_GET['_jsonp'] . '(' . json_encode($data) . ')';
     }
     require_once dirname(dirname(__FILE__)) . '/class-spotim-jsonpretty.php';
     $json_pretty = new SpotIM_JsonPretty();
     return $json_pretty->prettify(json_encode($data));
 }