function inc_sidebars_free_init()
{
    // Check if the PRO plugin is present and activated.
    if (class_exists('CustomSidebars')) {
        return false;
    }
    // used for more readable i18n functions: __( 'text', CSB_LANG );
    define('CSB_LANG', 'custom-sidebars');
    $plugin_dir = dirname(__FILE__);
    $plugin_dir_rel = dirname(plugin_basename(__FILE__));
    $plugin_url = plugin_dir_url(__FILE__);
    define('CSB_PLUGIN', __FILE__);
    define('CSB_LANG_DIR', $plugin_dir_rel . '/lang/');
    define('CSB_VIEWS_DIR', $plugin_dir . '/views/');
    define('CSB_INC_DIR', $plugin_dir . '/inc/');
    define('CSB_JS_URL', $plugin_url . 'js/');
    define('CSB_CSS_URL', $plugin_url . 'css/');
    define('CSB_IMG_URL', $plugin_url . 'img/');
    // Load the actual core.
    require_once CSB_INC_DIR . 'class-custom-sidebars.php';
    // Include function library
    if (file_exists(CSB_INC_DIR . 'external/wpmu-lib/core.php')) {
        require_once CSB_INC_DIR . 'external/wpmu-lib/core.php';
    }
    // Load the text domain for the plugin
    WDev()->translate_plugin(CSB_LANG, CSB_LANG_DIR);
    // Initialize the plugin
    CustomSidebars::instance();
}
Example #2
0
 /**
  * Helper function used by `html_element`
  *
  * @since  1.1.0
  */
 private function element_table($labels, $class, $id, $rows, $args)
 {
     WDev()->load_fields($args, 'head_row', 'head_col', 'col_class');
     echo '<span class="wpmui-table-wrapper">';
     $this->element_label($labels);
     $code_body = '';
     $code_head = '';
     if (is_array($rows)) {
         $args['col_class'] = WDev()->get_array($args['col_class']);
         foreach ($rows as $row_num => $row) {
             $code_row = '';
             $is_head_row = false;
             $row_class = $row_num % 2 === 0 ? '' : 'alternate';
             if (0 === $row_num && $args['head_row']) {
                 $is_head_row = true;
             }
             if (is_array($row)) {
                 foreach ($row as $col_num => $col) {
                     $is_head = $is_head_row || 0 === $col_num && $args['head_col'];
                     $col_class = isset($args['col_class'][$col_num]) ? $args['col_class'][$col_num] : '';
                     $code_row .= sprintf('<%1$s class="%3$s">%2$s</%1$s>', $is_head ? 'th' : 'td', $col, $col_class);
                 }
             } else {
                 $code_row = $row;
             }
             $code_row = sprintf('<tr class="%2$s">%1$s</tr>', $code_row, $row_class);
             if ($is_head_row) {
                 $code_head .= $code_row;
             } else {
                 $code_body .= $code_row;
             }
         }
         printf('<table class="wpmui-html-table %1$s">%2$s%3$s</table>', esc_attr($class), '<thead>' . $code_head . '</thead>', '<tbody>' . $code_body . '</tbody>');
     }
     $this->element_hint($labels);
     echo '</span>';
 }
    /**
     * Private, since it is a singleton.
     * We directly initialize sidebar options when class is created.
     */
    private function __construct()
    {
        /**
         * ID of the WP-Pointer used to introduce the plugin upon activation
         *
         * ========== Pointer ==========
         *  Internal ID:  wpmudcs1 [WPMUDev CustomSidebars 1]
         *  Point at:     #menu-appearance (Appearance menu item)
         *  Title:        Custom Sidebars
         *  Description:  Create and edit custom sidebars in your widget screen!
         * -------------------------------------------------------------------------
         */
        WDev()->pointer('wpmudcs1', '#menu-appearance', __('Custom Sidebars', CSB_LANG), sprintf(__('Now you can create and edit custom sidebars in your ' . '<a href="%1$s">Widgets screen</a>!', CSB_LANG), admin_url('widgets.php')));
        // Find out if the page is loaded in accessibility mode.
        $flag = isset($_GET['widgets-access']) ? $_GET['widgets-access'] : get_user_setting('widgets_access');
        self::$accessibility_mode = 'on' == $flag;
        // We don't support accessibility mode. Display a note to the user.
        if (true === self::$accessibility_mode) {
            WDev()->message(sprintf(__('<strong>Accessibility mode is not supported by the
						%1$s plugin.</strong><br /><a href="%2$s">Click here</a>
						to disable accessibility mode and use the %1$s plugin!', CSB_LANG), 'Custom Sidebars', admin_url('widgets.php?widgets-access=off')), 'err', 'widgets');
        } else {
            // Load javascripts/css files
            WDev()->add_ui('core', 'widgets.php');
            WDev()->add_ui('scrollbar', 'widgets.php');
            WDev()->add_ui('select', 'widgets.php');
            WDev()->add_ui(CSB_JS_URL . 'cs.min.js', 'widgets.php');
            WDev()->add_ui(CSB_CSS_URL . 'cs.css', 'widgets.php');
            // AJAX actions
            add_action('wp_ajax_cs-ajax', array($this, 'ajax_handler'));
            // Extensions use this hook to initialize themselfs.
            do_action('cs_init');
            // Display a message after import.
            if (!empty($_GET['cs-msg'])) {
                $msg = base64_decode($_GET['cs-msg']);
                // Prevent XSS attacks...
                $kses_args = array('br' => array(), 'b' => array(), 'strong' => array(), 'i' => array(), 'em' => array());
                $msg = wp_kses($msg, $kses_args);
                if (!empty($msg)) {
                    WDev()->message($msg);
                }
            }
            // Free version only
            add_action('in_widget_form', array($this, 'in_widget_form'), 10, 1);
        }
    }
 /**
  * Setup or migrate the database to current plugin version.
  *
  * This function uses error suppression on purpose.
  *
  * @since  4.6
  */
 public static function db_update()
 {
     // Required for dbDelta()
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     global $wpdb;
     $charset_collate = '';
     if (!empty($wpdb->charset)) {
         $charset_collate = ' DEFAULT CHARACTER SET ' . $wpdb->charset;
     }
     if (!empty($wpdb->collate)) {
         $charset_collate .= ' COLLATE ' . $wpdb->collate;
     }
     $tbl_popover = self::db_prefix('popover');
     $tbl_ip_cache = self::db_prefix('popover_ip_cache');
     $count = 0;
     if ($wpdb->get_var('SHOW TABLES LIKE "' . $tbl_popover . '" ') == $tbl_popover) {
         // Create a column in old table to monitor migration status.
         $sql = "CREATE TABLE {$tbl_popover} (\n\t\t\t\tid bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\tpopover_title varchar(250) DEFAULT NULL,\n\t\t\t\tpopover_content text,\n\t\t\t\tpopover_settings text,\n\t\t\t\tpopover_order bigint(20) DEFAULT '0',\n\t\t\t\tpopover_active int(11) DEFAULT '0',\n\t\t\t\tmigrated tinyint DEFAULT '0',\n\t\t\t\tPRIMARY KEY  (id)\n\t\t\t) {$charset_collate};";
         dbDelta($sql);
         // Migrate to custom post type.
         $sql = "\n\t\t\tSELECT\n\t\t\t\tid,\n\t\t\t\tpopover_title,\n\t\t\t\tpopover_content,\n\t\t\t\tpopover_settings,\n\t\t\t\tpopover_order,\n\t\t\t\tpopover_active\n\t\t\tFROM {$tbl_popover}\n\t\t\tWHERE migrated=0\n\t\t\t";
         $res = $wpdb->get_results($sql);
         // Name mapping of conditions/rules from build 5 -> 6.
         $mapping = array('isloggedin' => 'login', 'loggedin' => 'no_login', 'onurl' => 'url', 'notonurl' => 'no_url', 'incountry' => 'country', 'notincountry' => 'no_country', 'advanced_urls' => 'adv_url', 'not-advanced_urls' => 'no_adv_url', 'categories' => 'category', 'not-categories' => 'no_category', 'post_types' => 'posttype', 'not-post_types' => 'no_posttype', 'xprofile_value' => 'xprofile', 'not-xprofile_value' => 'no_xprofile', 'supporter' => 'no_prosite', 'searchengine' => 'searchengine', 'commented' => 'no_comment', 'internal' => 'no_internal', 'referrer' => 'referrer', 'count' => 'count', 'max_width' => 'width', 'wp_roles_rule' => 'role', 'membership_level' => 'membership');
         // Translate style to new keys
         $style_mapping = array('Default' => 'old-default', 'Default Fixed' => 'old-fixed', 'Dark Background Fixed' => 'old-fullbackground');
         // Migrate data from build 5 to build 6!
         foreach ($res as $item) {
             // Confirm the item was not migrated, just to be sure...
             // This is one-time code, we don't care for performance here.
             $sql = "\n\t\t\t\t\tSELECT 1 status\n\t\t\t\t\tFROM {$tbl_popover}\n\t\t\t\t\tWHERE id=%s AND migrated=0\n\t\t\t\t";
             $sql = $wpdb->prepare($sql, $item->id);
             $status = $wpdb->get_var($sql);
             if ($status != '1') {
                 continue;
             }
             $raw = maybe_unserialize($item->popover_settings);
             $checks = explode(',', @$raw['popover_check']['order']);
             foreach ($checks as $ind => $key) {
                 if (isset($mapping[$key])) {
                     $checks[$ind] = $mapping[$key];
                 } else {
                     unset($checks[$ind]);
                 }
             }
             if (isset($style_mapping[@$raw['popover_style']])) {
                 $style = $style_mapping[@$raw['popover_style']];
             } else {
                 $style = @$raw['popover_style'];
             }
             $colors = array('col1' => @$raw['popover_colour']['back'], 'col2' => @$raw['popover_colour']['fore']);
             $display = 'delay';
             if (isset($raw['on_exit'])) {
                 $display = 'leave';
             }
             if (isset($raw['on_click'])) {
                 $display = 'click';
             }
             $custom_colors = false;
             if ($colors['col1'] != 'FFFFFF') {
                 $custom_colors = true;
             }
             if ($colors['col2'] != '000000') {
                 $custom_colors = true;
             }
             $custom_size = true;
             if (!empty($raw['popover_size']['usejs'])) {
                 $custom_size = false;
             }
             if ('no' != @$raw['popover_usejs']) {
                 $custom_size = false;
             }
             $data = array('name' => $item->popover_title, 'content' => $item->popover_content, 'order' => $item->popover_order, 'active' => true == $item->popover_active, 'size' => @$raw['popover_size'], 'color' => $colors, 'custom_colors' => $custom_colors, 'custom_size' => $custom_size, 'style' => $style, 'can_hide' => 'no' == @$raw['popoverhideforeverlink'], 'close_hides' => 'no' != @$raw['popover_close_hideforever'], 'hide_expire' => absint(@$raw['popover_hideforever_expiry']), 'display' => $display, 'display_data' => array('delay' => absint(@$raw['popoverdelay']), 'delay_type' => 's', 'click' => @$raw['on_click']['selector'], 'click_multi' => !empty($raw['on_click']['selector'])), 'rule' => $checks, 'rule_data' => array('count' => @$raw['popover_count'], 'referrer' => @$raw['popover_ereg'], 'exit' => @$raw['on_exit'], 'url' => @$raw['onurl'], 'no_url' => @$raw['notonurl'], 'adv_url' => @$raw['advanced_urls']['urls'], 'no_adv_url' => @$raw['not-advanced_urls']['urls'], 'country' => @$raw['incountry'], 'no_country' => @$raw['notincountry'], 'category' => @$raw['categories'], 'no_category' => @$raw['not-categories'], 'posttype' => @$raw['post_types'], 'no_posttype' => @$raw['not-post_types'], 'xprofile' => @$raw['xprofile_value'], 'no_xprofile' => @$raw['not-xprofile_value'], 'width' => array('min' => @$raw['max_width']['width'])));
             // Save the popup as custom posttype.
             $popup = new IncPopupItem($data);
             $popup->save(false);
             // Mark Popup as migrated
             $sql = "\n\t\t\t\t\tUPDATE {$tbl_popover}\n\t\t\t\t\tSET migrated=1\n\t\t\t\t\tWHERE id=%s\n\t\t\t\t";
             $sql = $wpdb->prepare($sql, $item->id);
             $wpdb->query($sql);
             // Advance counter.
             $count += 1;
         }
     }
     self::refresh_order();
     // Create or update the IP cache table.
     $sql = "\n\t\tCREATE TABLE {$tbl_ip_cache} (\n\t\t\tIP varchar(12) NOT NULL DEFAULT '',\n\t\t\tcountry varchar(2) DEFAULT NULL,\n\t\t\tcached bigint(20) DEFAULT NULL,\n\t\t\tPRIMARY KEY  (IP),\n\t\t\tKEY cached (cached)\n\t\t) {$charset_collate};";
     dbDelta($sql);
     if ($count > 0) {
         WDev()->message(sprintf(__('<strong>WordPress PopUp</strong><br />' . 'Your installation was successfully updated to use the ' . 'latest version of the plugin!<br />' . '<em>Note: Some PopUp options changed or were replaced. ' . 'You should have a look at your <a href="%s">PopUps</a> ' . 'to see if they still look as intended.</em>', PO_LANG), admin_url('edit.php?post_type=' . IncPopupItem::POST_TYPE)));
     }
     // Migrate the Plugin Settings.
     $old_settings = IncPopupDatabase::_get_option('popover-settings', array());
     $settings = array();
     $cur_method = @$old_settings['loadingmethod'];
     switch ($cur_method) {
         case '':
         case 'external':
             $cur_method = 'ajax';
             break;
         case 'frontloading':
             $cur_method = 'front';
             break;
     }
     $settings['loadingmethod'] = $cur_method;
     // Migrate Add-Ons to new settings.
     // Add-Ons were always saved in the local Options-table by old version.
     self::before_db();
     $addons = get_option('popover_activated_addons', array());
     self::after_db();
     $rules = array('class-popup-rule-browser.php', 'class-popup-rule-geo.php', 'class-popup-rule-popup.php', 'class-popup-rule-referrer.php', 'class-popup-rule-url.php', 'class-popup-rule-user.php', 'class-popup-rule-prosite.php');
     foreach ($addons as $addon) {
         switch ($addon) {
             case 'anonymous_loading.php':
             case 'testheadfooter.php':
                 /* Integrated; no option. */
                 break;
             case 'localgeodatabase.php':
                 $settings['geo_db'] = true;
                 break;
             case 'rules-advanced_url.php':
                 $rules[] = 'class-popup-rule-advurl.php';
                 break;
             case 'rules-categories.php':
                 $rules[] = 'class-popup-rule-category.php';
                 break;
             case 'rules-max_width.php':
                 $rules[] = 'class-popup-rule-width.php';
                 break;
             case 'rules-on_exit.php':
                 $rules[] = 'class-popup-rule-events.php';
                 break;
             case 'rules-onclick.php':
                 $rules[] = 'class-popup-rule-events.php';
                 break;
             case 'rules-post_types.php':
                 $rules[] = 'class-popup-rule-posttype.php';
                 break;
             case 'rules-xprofile_value.php':
                 $rules[] = 'class-popup-rule-xprofile.php';
                 break;
             case 'rules-membership.php':
                 $rules[] = 'class-popup-rule-membership.php';
                 break;
             case 'rules-wp_roles.php':
                 $rules[] = 'class-popup-rule-role.php';
                 break;
         }
     }
     $settings['rules'] = $rules;
     self::set_settings($settings);
     // Save the new DB version to options table.
     self::_set_option('popover_installed', PO_BUILD);
 }
 /**
  * Load-Method: Raw
  *
  * This is used when a form is submitted inside a PopUp - it means that we
  * should only return the contents of the PopUp(s) and not the whole page.
  * Set via form field "_po_method_".
  *
  * @since  4.6.1.2
  */
 protected function load_method_raw()
 {
     /**
      * Set up the rquest information from here.
      * These values are used by some rules and need to be set manually here
      * In an ajax request they would already be defined by the ajax url.
      */
     $_REQUEST['thereferrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     $_REQUEST['thefrom'] = WDev()->current_url();
     // Populates $this->popups
     $this->select_popup();
     if (empty($this->popups)) {
         die;
     }
     echo '<div>';
     $this->show_footer();
     echo '</div>';
     die;
 }
 /**
  * Returns the URL which can be defined by REQUEST[theform] or wp->request.
  *
  * @since  4.6
  * @return string
  */
 public function current_url()
 {
     global $wp;
     $current_url = '';
     if (empty($_REQUEST['thefrom'])) {
         $current_url = WDev()->current_url();
     } else {
         $current_url = strtok($_REQUEST['thefrom'], '#');
     }
     return $current_url;
 }
Example #7
0
					</span>
					<?php 
    foreach ($item->action as $action) {
        WDev()->html->element($action);
    }
    ?>
				</div>
				<div class="details">
					<?php 
    foreach ($item->details as $detail) {
        if (is_array($detail)) {
            if (isset($detail['ajax_data']) && is_array($detail['ajax_data'])) {
                $detail['ajax_data']['_is_detail'] = true;
            }
        }
        WDev()->html->element($detail);
    }
    ?>
				</div>
				<div class="fader"></div>
			</div>
			<div class="list-card-bottom">
				<span class="list-card-footer is-no-detail">
					<?php 
    echo '' . $item->footer;
    ?>
				</span>
				<span class="toggle-details toggle-link is-no-detail">
					<?php 
    echo esc_html($lang->show_details);
    ?>
 /**
  * Check for the existence of the strings where wp_head and wp_footer should
  * have been called from.
  *
  * This is loading the front-page of the current installation via
  * wp_remove_get and then parses the resonse to see if the header/footer
  * comments exist in the HTML code.
  *
  * @since  1.0.0
  */
 public static function check()
 {
     static $Init = false;
     static $Resp = null;
     if (false === $Init) {
         $Init = true;
         $Resp = (object) array('okay' => false, 'msg' => array(), 'shortcodes' => array());
         // Build the url to call, NOTE: uses home_url and thus requires WordPress 3.0
         $url = add_query_arg(array('popup-headerfooter-check' => '1'), home_url());
         // Perform the HTTP GET ignoring SSL errors
         $cookies = $_COOKIE;
         unset($cookies['PHPSESSID']);
         $response = wp_remote_get($url, array('sslverify' => false, 'cookies' => $cookies));
         // Grab the response code and make sure the request was sucessful
         $code = (int) wp_remote_retrieve_response_code($response);
         if (is_wp_error($response)) {
             WDev()->message($response->get_error_message());
             return $Resp;
         }
         if ($code !== 200) {
             return $Resp;
         }
         // Strip all tabs, line feeds, carriage returns and spaces
         $html = preg_replace('/[\\t\\r\\n\\s]/', '', wp_remote_retrieve_body($response));
         if (!strstr($html, '<wp_head>exists</wp_head>')) {
             // wp_head is missing
             $Resp->msg[] = __('Critical: Call to <code>wp_head();</code> is missing! It ' . 'should appear directly before <code>&lt;/head&gt;</code>', PO_LANG);
         }
         if (!strstr($html, '<wp_footer>exists</wp_footer>')) {
             // wp_footer is missing.
             $Resp->msg[] = __('Critical: Call to <code>wp_footer();</code> is missing! It ' . 'should appear directly before <code>&lt;/body&gt;</code>', PO_LANG);
         }
         $matches = array();
         $has_shortcodes = preg_match('#<wp_shortcodes>([^\\<]*)</wp_shortcodes>#', $html, $matches);
         if ($has_shortcodes) {
             $items = $matches[1];
             $Resp->shortcodes = explode(',', $items);
         }
         // Display any errors that we found.
         if (empty($Resp->msg)) {
             $Resp->okay = true;
             $Resp->msg[] = __('Okay: Your current theme uses <code>wp_head();</code> and ' . '<code>wp_footer();</code> correctly!', PO_LANG);
         }
     }
     return $Resp;
 }
Example #9
0
 /**
  * Parses the specified content and looks for shortcodes that are not
  * compatible with the current PopUp loading method.
  *
  * The function does not return a value, but if incompatible shortcodes are
  * detected a new Admin Notification will be generated which is displayed to
  * the user after the page has finished loading.
  *
  * @since  4.7.0
  * @param  string $content
  */
 public static function validate_shortcodes($content)
 {
     $settings = IncPopupDatabase::get_settings();
     $method = isset($settings['loadingmethod']) ? $settings['loadingmethod'] : 'ajax';
     // Check for specific/frequently used shortcodes.
     if ($method !== 'footer' && preg_match('#\\[gravityforms?(\\s.*?\\]|\\])#', $content)) {
         WDev()->message(sprintf(__('You are using Gravity Forms inside this PopUp. It is best to switch to the <a href="%s">loading method</a> "Page Footer" to ensure the form works as expected.', PO_LANG), 'edit.php?post_type=' . IncPopupItem::POST_TYPE . '&page=settings'), 'err');
     }
     // General check for shortcode incompatibility
     switch ($method) {
         case 'ajax':
         case 'anonymous':
             // Check if the content contains any of the Front-Shortcodes:
             $check = IncPopupAddon_HeaderFooter::check();
             $content = do_shortcode($content);
             foreach ($check->shortcodes as $code) {
                 $match = array();
                 if (preg_match('#\\[' . $code . '(\\s.*?\\]|\\])#', $content, $match)) {
                     WDev()->message(sprintf(__('Shortcode <code>%s</code> requires a different <a href="%s">loading method</a> to work.<br />Try "Page Footer", though sometimes the method "Custom AJAX" also works (please test the result)', PO_LANG), $match[0], 'edit.php?post_type=' . IncPopupItem::POST_TYPE . '&page=settings'), 'err');
                 }
             }
             break;
         case 'footer':
         case 'front':
             // Nothing needs to be validated here...
             break;
         default:
             //WDev()->message( 'Shortcode-Check not defined for: ' . $method );
     }
 }
Example #10
0
 /**
  * Returns an array of PopUp objects that should be displayed for the
  * current page/user. The PopUps are in the order in which they are defined
  * in the admin list.
  *
  * @since  4.6
  * @return array List of all popups that fit the current page.
  */
 protected function find_popups()
 {
     $popups = array();
     WDev()->load_request_fields('po_id', 'preview');
     $popup_id = absint($_REQUEST['po_id']);
     if ($popup_id) {
         // Check for forced popup.
         $active_ids = array($popup_id);
     } else {
         $active_ids = IncPopupDatabase::get_active_ids();
     }
     foreach ($active_ids as $id) {
         $popup = IncPopupDatabase::get($id);
         if ($popup_id) {
             // Forced popup ignores all conditions.
             $show = true;
         } else {
             // Apply the conditions to decide if the popup should be displayed.
             $show = apply_filters('popup-apply-rules', true, $popup);
         }
         // Stop here if the popup failed in some conditions.
         if (!$show) {
             continue;
         }
         // Stop here if the user did choose to hide the popup.
         if (!$_REQUEST['preview'] && $this->is_hidden($id)) {
             continue;
         }
         $popups[] = $popup;
     }
     return $popups;
 }
Example #11
0
 /**
  * Save the popup data to database
  *
  * @since  4.6.0
  * @param  int $post_id Post ID that was saved/created
  * @param  WP_Post $post Post object that was saved/created
  * @param  bool $update True means the post was updated (not created)
  */
 public static function form_save($post_id, $post, $update)
 {
     $popup = IncPopupDatabase::get($post_id);
     // Make sure the POST collection contains all required fields.
     if (0 !== WDev()->load_post_fields('popup-nonce', 'post_type', 'po-action')) {
         return;
     }
     // Autosave is not processed.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // The nonce is invalid.
     if (!wp_verify_nonce($_POST['popup-nonce'], 'save-popup')) {
         return;
     }
     // This save event is for a different post type... ??
     if (IncPopupItem::POST_TYPE != $_POST['post_type']) {
         return;
     }
     // Global PopUp modified in a Network-Blog that is not the Main-Blog.
     if (!IncPopup::correct_level()) {
         return;
     }
     // User does not have permissions for this.
     if (!current_user_can(IncPopupPosttype::$perms)) {
         return;
     }
     $action = $_POST['po-action'];
     $status = false;
     switch ($action) {
         case 'save':
             // Don't force a status...
             break;
         case 'activate':
             $status = 'active';
             break;
         case 'deactivate':
             $status = 'inactive';
             break;
         default:
             // Unknown action.
             return;
     }
     // Populate the popup.
     $data = self::prepare_formdata($_POST);
     $data['id'] = $post_id;
     $data['order'] = $popup->order;
     if ($status) {
         $data['status'] = $status;
     }
     $popup->populate($data);
     // Prevent infinite loop when saving.
     remove_action('save_post_' . IncPopupItem::POST_TYPE, array('IncPopup', 'form_save'), 10);
     $popup->save();
     add_action('save_post_' . IncPopupItem::POST_TYPE, array('IncPopup', 'form_save'), 10, 3);
     // Removes the 'message' from the redirect URL.
     add_filter('redirect_post_location', array('IncPopup', 'form_redirect'), 10, 2);
     // Update the PopUp object in WP-Cache.
     IncPopupDatabase::get($post_id, true);
 }