/** * Ajax handler to get the HTML representation of the request. */ function siteorigin_panels_content_save_pre_get() { if (empty($_POST['grids']) || empty($_POST['grid_cells']) || empty($_POST['widgets']) || empty($_POST['panel_order'])) { exit; } if (empty($_POST['_signature'])) { exit; } $sig = $_POST['_signature']; $data = array('grids' => $_POST['grids'], 'grid_cells' => $_POST['grid_cells'], 'widgets' => array_map('stripslashes_deep', $_POST['widgets']), 'panel_order' => $_POST['panel_order'], 'action' => $_POST['action'], 'post_id' => $_POST['post_id']); // Use the signature to secure the request. if ($sig != sha1(NONCE_SALT . serialize($data))) { exit; } // This can cause a fatal error, so handle in a separate request. $panels_data = siteorigin_panels_get_panels_data_from_post($_POST); $content = ''; if (!empty($panels_data['widgets'])) { // Save the panels data into post_content for SEO and search plugins $content = siteorigin_panels_render($_POST['post_id'], false, $panels_data); $content = preg_replace(array('@<head[^>]*?>.*?</head>@siu', '@<style[^>]*?>.*?</style>@siu', '@<script[^>]*?.*?</script>@siu', '@<object[^>]*?.*?</object>@siu', '@<embed[^>]*?.*?</embed>@siu', '@<applet[^>]*?.*?</applet>@siu', '@<noframes[^>]*?.*?</noframes>@siu', '@<noscript[^>]*?.*?</noscript>@siu', '@<noembed[^>]*?.*?</noembed>@siu'), array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '), $content); $content = strip_tags($content, '<img><h1><h2><h3><h4><h5><h6><a><p><em><strong>'); $content = explode("\n", $content); $content = array_map('trim', $content); $content = implode("\n", $content); $content = preg_replace("/[\n]{2,}/", "\n\n", $content); $content = trim($content); } echo $content; exit; }
/** * This is a way to show previews of panels, especially for the home page. * * @param $val * @return array */ function siteorigin_panels_preview_load_data($val) { if (isset($_GET['siteorigin_panels_preview'])) { $val = siteorigin_panels_get_panels_data_from_post($_POST); } return $val; }
/** * Save the panels data * * @param $post_id * @param $post * * @action save_post */ public function save_post($post_id, $post) { if (empty($_POST['_sopanels_nonce']) || !wp_verify_nonce($_POST['_sopanels_nonce'], 'save')) { return; } if (empty($_POST['panels_js_complete'])) { return; } if (!current_user_can('edit_post', $post_id)) { return; } // Don't Save panels if Post Type for $post_id is not same as current post ID type // (Prevents population product panels data in saving Tabs via Meta) if (get_post_type($_POST['post_ID']) != 'wc_product_tab' and get_post_type($post_id) == 'wc_product_tab') { return; } $panels_data = siteorigin_panels_get_panels_data_from_post($_POST); if (function_exists('wp_slash')) { $panels_data = wp_slash($panels_data); } update_post_meta($post_id, 'panels_data', $panels_data); }