Ejemplo n.º 1
0
 public function get_form_preview()
 {
     global $post;
     add_filter('caldera_forms_render_form_element', array($this, 'set_preview_form_element'));
     $post = get_post((int) $_POST['post_id']);
     if (isset($_POST['atts']['named']['id'])) {
         $form = $_POST['atts']['named']['id'];
     } elseif (isset($_POST['atts']['named']['name'])) {
         $form = $_POST['atts']['named']['name'];
     }
     add_filter('caldera_forms_get_form-' . $form, array($this, 'set_preview_get_form'), 100);
     //shortcode_handler( $atts, $content )
     $atts = $_POST['atts']['named'];
     $atts['preview'] = true;
     if (!empty($form)) {
         ob_start();
         wp_head();
         $content = '';
         if (!empty($_POST['content'])) {
             $content = stripslashes_deep($_POST['content']);
         }
         echo Caldera_Forms::shortcode_handler($atts, $content);
         echo '<div class="clear"></div>';
         wp_print_footer_scripts();
         $html = ob_get_clean();
     }
     $out = array();
     if (!empty($html)) {
         $out['html'] = $html;
     }
     wp_send_json_success($out);
 }