/** * Save IG PageBuilder shortcode content of a post/page * * @param int $post_id * @return type */ function save_pagebuilder_content($post_id) { if (!current_user_can('edit_page', $post_id)) { return; } if (!isset($_POST[IGNONCE . '_builder']) || !wp_verify_nonce($_POST[IGNONCE . '_builder'], 'ig_builder')) { return; } $ig_deactivate_pb = intval(esc_sql($_POST['ig_deactivate_pb'])); if ($ig_deactivate_pb) { IG_Pb_Utils_Common::delete_meta_key(array('_ig_page_builder_content', '_ig_html_content', '_ig_page_active_tab', '_ig_post_view_count'), $post_id); } else { $ig_active_tab = intval(esc_sql($_POST['ig_active_tab'])); $post_content = ''; // IG PageBuilder is activate if ($ig_active_tab) { $data = array(); if (isset($_POST['shortcode_content']) && is_array($_POST['shortcode_content'])) { foreach ($_POST['shortcode_content'] as $shortcode) { $data[] = trim(stripslashes($shortcode)); } } else { $data[] = ''; } $post_content = IG_Pb_Utils_Placeholder::remove_placeholder(implode('', $data), 'wrapper_append', ''); // update post meta update_post_meta($post_id, '_ig_page_builder_content', $post_content); update_post_meta($post_id, '_ig_html_content', IG_Pb_Helper_Shortcode::doshortcode_content($post_content)); } else { $content = stripslashes($_POST['content']); /// remove this line? $content = apply_filters( 'the_content', $content ); $post_content = $content; } // update current active tab update_post_meta($post_id, '_ig_page_active_tab', $ig_active_tab); } // update whether or not deactive pagebuilder update_post_meta($post_id, '_ig_deactivate_pb', $ig_deactivate_pb); }
/** * Deactivate handle * * @global type $pagenow * @global type $wpdb */ function do_deactivate() { global $pagenow; if ($pagenow == 'plugins.php') { $deactivate_action = false; $ig_pb_plugin = 'ig-pagebuilder/ig-pagebuilder.php'; // check if single deactivate plugin/ bulk deactivate plugins if (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], array('deactivate-selected', 'deactivate'))) { $action = $_REQUEST['action']; if ($action == 'deactivate' && $_REQUEST['plugin'] == $ig_pb_plugin || $action == 'deactivate-selected' && in_array($ig_pb_plugin, $_REQUEST['checked'])) { $deactivate_action = true; } } if ($deactivate_action) { $ig_action = 'ig_deactivate'; $plugin_url = admin_url('plugins.php'); // check whether delete only IG PageBuilder OR Bulk deactivate plugins $deactivate_one = isset($_POST['action']) ? false : true; // show Confirmation form before doing deactivate if (!isset($_REQUEST['ig_wpnonce']) && !isset($_REQUEST['ig_back'])) { // create ig_nonce $ig_nonce = wp_create_nonce($ig_action); $method = $deactivate_one ? 'GET' : 'POST'; $back_text = __('No, take me back', IGPBL); if ($deactivate_one) { $back_btn = "<a href='{$plugin_url}' class='button button-large'>" . $back_text . '</a>'; } else { $back_btn = "<input type='submit' name='ig_back' class='button button-large' value='" . $back_text . "'>"; } $form = " action='{$plugin_url}' method='{$method}' "; $fields = ''; foreach ($_REQUEST as $key => $value) { if (!is_array($value)) { $fields .= "<input type='hidden' name='{$key}' value='{$value}' />"; } else { foreach ($value as $p) { $fields .= "<input type='hidden' name='{$key}[]' value='{$p}' />"; } } } $fields .= "<input type='hidden' name='ig_wpnonce' value='{$ig_nonce}' />"; // show message ob_start(); ?> <p> <?php _e('After deactivating, all content built with PageBuilder will be parsed to plain HTML code. Are you sure you want to deactivate PageBuilder plugin?', IGPBL); ?> </p> <center> <form <?php echo balanceTags($form); ?> > <?php echo balanceTags($fields); ?> <input type="submit" name="ig_deactivate" class="button button-large" value="<?php _e('Yes, deactivate plugin', IGPBL); ?> " style="background: #d9534f;color: #fff;text-shadow:none;border:none;"> <?php echo balanceTags($back_btn); ?> </form> </center> <p style="font-style: italic; font-size: 12px;margin-top: 20px;"> <?php _e("Or if you want to deactivate without parsing 'content built with PageBuilder' to HTML code, click on the button below", IGPBL); ?> </p> <center> <form <?php echo balanceTags($form); ?> > <?php echo balanceTags($fields); ?> <input type="submit" name="ig_deactivate_light" class="button button-large" value="<?php _e('Deactivate without parsing data', IGPBL); ?> " style="background: #f0ad4e;color: #fff;text-shadow:none;border:none;"> </form> </center> <?php $message = ob_get_clean(); // Change page title _default_wp_die_handler($message, __('WordPress › Confirmation', IGPBL)); exit; } else { // get nonce $ig_nonce = esc_sql($_REQUEST['ig_wpnonce']); $nonce = wp_verify_nonce($ig_nonce, $ig_action); // if nonce is invalid if (!in_array($nonce, array(1, 2))) { _default_wp_die_handler(__('Nonce is invalid!', IGPBL)); exit; } // do action when customer choose "take me back" in confirmation form if (isset($_REQUEST['ig_back'])) { // remove IG PageBuilder from the checked list if (($key = array_search($ig_pb_plugin, $_REQUEST['checked'])) !== false) { unset($_REQUEST['checked'][$key]); } // Overwrite list of checked plugins to deactivating $_POST['checked'] = $_REQUEST['checked']; } else { if (isset($_REQUEST['ig_deactivate'])) { global $wpdb; // update post content = value of '_ig_html_content', deactivate pagebuilder $meta_key1 = 1; $meta_key2 = '_ig_html_content'; $meta_key3 = '_ig_deactivate_pb'; $wpdb->query($wpdb->prepare("\n\t\t\t\t\t\t\t\tUPDATE\t\t{$wpdb->posts} p\n\t\t\t\t\t\t\t\tLEFT JOIN\t{$wpdb->postmeta} p1\n\t\t\t\t\t\t\t\t\t\t\tON p1.post_id = p.ID\n\t\t\t\t\t\t\t\tLEFT JOIN\t{$wpdb->postmeta} p2\n\t\t\t\t\t\t\t\t\t\t\tON p2.post_id = p.ID\n\t\t\t\t\t\t\t\tSET\t\t\tpost_content = p1.meta_value, p2.meta_value = %d\n\t\t\t\t\t\t\t\tWHERE\t\tp1.meta_key = %s\n\t\t\t\t\t\t\t\t\t\t\tAND p2.meta_key = %s\n\t\t\t\t\t\t\t\t", $meta_key1, $meta_key2, $meta_key3)); // delete pagebuilder content IG_Pb_Utils_Common::delete_meta_key(array('_ig_page_builder_content', '_ig_page_active_tab')); do_action('ig_pb_deactivate'); } } } } } }
/** * * Uninstalling IG PageBuilder: deletes post metas & options * * @author InnoGears Team <*****@*****.**> * @package IGPGBLDR * @version $Id$ */ //if uninstall not called from WordPress exit if (!defined('WP_UNINSTALL_PLUGIN')) { exit; } include_once 'core/utils/common.php'; // delete all other providers $providers = get_transient('_ig_pb_providers'); if ($providers) { $providers = unserialize($providers); $list_plugins = array(); foreach ($providers as $provider) { if (!empty($provider['file'])) { $list_plugins[] = $provider['file']; } } delete_plugins($list_plugins); } // delete cache folder IG_Pb_Utils_Common::remove_cache_folder(); // delete meta key IG_Pb_Utils_Common::delete_meta_key(array('_ig_page_builder_content', '_ig_html_content', '_ig_page_active_tab', '_ig_post_view_count', '_ig_deactivate_pb', '_ig_page_builder_css_files', '_ig_page_builder_css_custom'));