public function setup()
 {
     CS_Shortcode_Preserver::init();
     $this->magic_hooks = new Cornerstone_Magic_Hooks();
     $this->add_elements();
     $this->register_elements();
 }
 public function ajax_handler($data)
 {
     CS_Shortcode_Preserver::init();
     if ($this->sandbox_the_content) {
         CS_Shortcode_Preserver::sandbox('cs_render_the_content');
     }
     add_filter('cs_preserve_shortcodes_no_wrap', '__return_true');
     $this->orchestrator = $this->plugin->component('Element_Orchestrator');
     $this->orchestrator->load_elements();
     $this->mk1 = new Cornerstone_Legacy_Renderer($this->plugin->component('Legacy_Elements'));
     global $post;
     if (!isset($data['post_id']) || !($post = get_post((int) $data['post_id']))) {
         wp_send_json_error(array('message' => 'post_id not set'));
     }
     setup_postdata($post);
     $this->enqueue_extractor = $this->plugin->loadComponent('Enqueue_Extractor');
     $this->enqueue_extractor->start();
     if (isset($data['raw_markup'])) {
         $this->raw_markup = (bool) $data['raw_markup'];
     }
     if (!isset($data['batch'])) {
         wp_send_json_error(array('message' => 'No element data recieved'));
     }
     $jobs = $this->batch($data['batch']);
     $scripts = $this->enqueue_extractor->get_scripts();
     if (is_wp_error($jobs)) {
         wp_send_json_error(array('message' => $jobs->get_error_message()));
     }
     $result = array('jobs' => $jobs, 'scripts' => $scripts);
     //Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         return wp_send_json_success($result);
     }
     return @wp_send_json_success($result);
 }