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); }
public function setup() { CS_Shortcode_Preserver::init(); $this->magic_hooks = new Cornerstone_Magic_Hooks(); $this->add_elements(); $this->register_elements(); }
<?php // Raw Content // ============================================================================= function x_shortcode_raw_content($atts, $content = null) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => ''), $atts, 'x_raw_content')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-raw-content ' . esc_attr($class) : 'x-raw-content'; $style = $style != '' ? 'style="' . $style . '"' : ''; $output = "<div {$id} class=\"{$class}\" {$style}>" . do_shortcode($content) . '</div>'; return $output; } add_shortcode('x_raw_content', 'x_shortcode_raw_content'); CS_Shortcode_Preserver::preserve('x_raw_content');
<?php // Code // ============================================================================= function x_shortcode_code($atts, $content = null) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'sanitize' => ''), $atts, 'x_code')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-code ' . esc_attr($class) : 'x-code'; $style = $style != '' ? 'style="' . $style . '"' : ''; $sanitize = $sanitize == 'false' ? 'false' : 'true'; $content = $sanitize == 'true' ? htmlspecialchars($content) : $content; $output = "<pre {$id} class=\"{$class}\" {$style}><code>{$content}</code></pre>"; return $output; } add_shortcode('x_code', 'x_shortcode_code'); CS_Shortcode_Preserver::preserve('x_code');
/** * Instance accessor. If instance doesn't exist, we'll initialize the class. * @return object CS_Shortcode_Preserver::$instance */ public static function instance() { if (!isset(self::$instance)) { self::$instance = new CS_Shortcode_Preserver(); } return self::$instance; }