gde_output_json

Output/download requested JSON data.

Description

gde_output_json( $json, (constant) $save = false, (string) $file = '' ); 

Parameters (3)

0. $json
The json.
1. $save — Optional. (constant) => false
The save.
2. $file — Optional. (string) => ''
The file.

Usage

  1. if ( !function_exists( 'gde_output_json' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/libs/lib-service.php'; 
  3.  
  4. // The json. 
  5. $json = null; 
  6.  
  7. // The save. 
  8. $save = false; 
  9.  
  10. // The file. 
  11. $file = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = gde_output_json($json, $save, $file); 
  15.  

Defined (1)

The function is defined in the following location(s).

/libs/lib-service.php  
  1. function gde_output_json( $json, $save = false, $file = '' ) { 
  2. if ( $save && ! empty( $file ) ) { 
  3. header('Content-disposition: attachment; filename=' . $file . '.json' ); 
  4. header('Content-type: application/json'); 
  5. echo $json; 
  6. exit;