示例#1
0
 /**
  * function to return Json response for all Palette/Editor elements
  *
  * @since	 2.0.0
  *
  * @return	JSON data   
  *
  * @param	  Post data [action],[category] 
  */
 public function get_pallete_elements()
 {
     if (isset($_POST['category']) && $_POST['category'] == 'Palette') {
         //if pallete required
         try {
             header("Content-Type: application/json");
             $palette = new Palette();
             $elements = $palette->to_JSON();
             echo $elements;
         } catch (Exception $e) {
             echo '{"error":{"text":' . $e->getMessage() . '}}';
         }
     } else {
         //if editor elements required
         try {
             header("Content-Type: application/json");
             $instance = $_POST['instance'];
             $editor = new Editor($instance);
             $elements = $editor->to_JSON();
             echo $elements;
         } catch (Exception $e) {
             echo '{"error":{"text":' . $e->getMessage() . '}}';
         }
     }
     exit;
 }