function _redirect($ext = '') { if (!op_has_error()) { $step = ++$this->cur_step; wp_redirect(menu_page_url(OP_SN . '-page-builder', false) . (defined('OP_PAGEBUILDER_ID') ? '&page_id=' . OP_PAGEBUILDER_ID : '') . '&step=' . $step . $ext); } }
function save_launch_suite() { global $wpdb; add_filter(OP_SN . '-script-localize', array($this, 'localize')); $funnel_dropdown = ''; $current = intval(op_get('funnel_id')); $found = false; $funnels = $wpdb->get_results("SELECT id,title FROM `{$wpdb->prefix}optimizepress_launchfunnels` ORDER BY title ASC"); $funnel_count = 0; if ($funnels) { $funnel_count = count($funnels); foreach ($funnels as $funnel) { if ($current < 1) { $current = $funnel->id; $found = true; } elseif ($current == $funnel->id) { $found = true; } $funnel_dropdown .= '<option value="' . $funnel->id . '"' . ($current == $funnel->id ? ' selected="selected"' : '') . '>' . op_attr($funnel->title) . '</option>'; } } $this->funnel_count = $funnel_count; $this->funnel_dropdown = $funnel_dropdown; if ($found) { define('OP_LAUNCH_FUNNEL', $current); } $this->data['settings_sections'] = array('gateway_key' => __('Funnel Gateway Key', OP_SN), 'perpetual_launch' => __('Perpetual/Evergreen Launch Mode', OP_SN), 'redirect_all' => __('Redirect All Launch Pages', OP_SN), 'hide_coming_soon' => __('Hide Coming Soon Placeholders', OP_SN)); $this->data['settings_sections'] = apply_filters('op_launch_suite_settings_sections', $this->data['settings_sections']); if ($found && isset($_POST[OP_SN . '_launch_suite'])) { if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'op_launch_suite')) { $op = op_post('op'); foreach ($this->data['settings_sections'] as $name => $section) { if (is_array($section)) { if (isset($section['save_action'])) { call_user_func($section['save_action'], op_get_var($op, $name)); } } else { call_user_func(array($this, '_save_' . $name), op_get_var($op, $name)); } } $funnel_pages = array('sales' => array(), 'stages' => array()); $used_ids = array(); $page_ids = array('sales' => 0, 'stages' => array()); if (isset($op['funnel_pages'])) { if (isset($op['funnel_pages']['sales'])) { $options = array('page_setup' => array('open_sales_cart', 'sales_page', 'hide_cart'), 'page_thumbnails' => array('active_thumbnail', 'inactive_thumbnail'), 'navigation' => array('active_link_text', 'inactive_link_text')); if (isset($op['funnel_pages']['sales']['page_setup']) && ($page_id = op_get_var($op['funnel_pages']['sales']['page_setup'], 'sales_page', 0)) > 0) { foreach ($options as $section => $fields) { $conf = op_get_var($op['funnel_pages']['sales'], $section); if ($section == 'page_setup') { $page_ids['sales'] = op_get_var($conf, 'sales_page', 0); if ($page_ids['sales'] > 0) { $used_ids[$page_ids['sales']] = true; $funnel_pages['sales']['sales_page'] = $page_ids['sales']; op_update_page_id_option($page_ids['sales'], array('launch_suite_info', array('funnel_id' => OP_LAUNCH_FUNNEL, 'funnel_page' => 'sales'))); } } $tmp = array(); foreach ($fields as $field) { $tmp[$field] = op_get_var($conf, $field); } $funnel_pages['sales'][$section] = $tmp; } } } if (empty($funnel_pages['sales'])) { $funnel_pages['sales'] = $op['funnel_pages']['sales']; } if (isset($op['funnel_pages']['stage'])) { $options = array('page_setup' => array('value_page'), 'page_thumbnails' => array('active_thumbnail', 'inactive_thumbnail'), 'navigation' => array('active_link_text', 'inactive_link_text'), 'publish_stage' => array('publish')); if ($this->is_key_on) { array_unshift($options['page_setup'], 'landing_page'); } if (isset($op['funnel_pages']['stage']) && is_array($op['funnel_pages']['stage'])) { $count = count(op_get_var($op['funnel_pages']['stage']['page_setup'], 'landing_page', array())); $configs = array('page_setup' => op_get_var($op['funnel_pages']['stage'], 'page_setup', array()), 'page_thumbnails' => op_get_var($op['funnel_pages']['stage'], 'page_thumbnails', array()), 'navigation' => op_get_var($op['funnel_pages']['stage'], 'navigation', array()), 'publish_stage' => op_get_var($op['funnel_pages']['stage'], 'publish_stage', array())); for ($i = 0; $i < $count; $i++) { $stage = array(); $pg_ids = array(); foreach ($options as $section => $fields) { $stage[$section] = array(); foreach ($fields as $field) { $stage[$section][$field] = op_get_var(op_get_var($configs[$section], $field, array()), $i); if ($field == 'active_link_text' && empty($stage[$section]['active_link_text'])) { $stage[$section]['active_link_text'] = get_the_title(op_get_var($stage, 'value_page')); } elseif ($field == 'inactive_link_text' && empty($stage[$section]['inactive_link_text'])) { $stage[$section]['inactive_link_text'] = 'Coming Soon'; } if ($field == 'landing_page' || $field == 'value_page') { $pg_ids[$field] = $stage[$section][$field]; $stage[$field] = $pg_ids[$field]; if ($pg_ids[$field] > 0) { $used_ids[$pg_ids[$field]] = true; op_update_page_id_option($pg_ids[$field], array('launch_suite_info', array('funnel_id' => OP_LAUNCH_FUNNEL, 'funnel_page' => 'stage', 'stage_idx' => $i, 'type' => $field))); } } } } $funnel_pages['stages'][] = $stage; $page_ids['stages'][] = $pg_ids; } } } } op_launch_update_option('funnel_pages', $funnel_pages); op_launch_update_option('page_ids', $page_ids); $funnel_pages = $wpdb->get_results($wpdb->prepare("SELECT page_id FROM `{$wpdb->prefix}optimizepress_launchfunnels_pages` WHERE funnel_id=%s", OP_LAUNCH_FUNNEL)); if ($funnel_pages) { $pages = array(); foreach ($funnel_pages as $page) { if (!isset($used_ids[$page->page_id])) { op_update_page_id_option($page->page_id, array('launch_suite_info', array('funnel_id' => OP_LAUNCH_FUNNEL, 'funnel_page' => 'stage', 'stage_idx' => -1, 'type' => ''))); } } } if (op_has_error()) { $this->error = __('There was a problem processing the form, please review the errors below', OP_SN); } else { $this->notification = __('Your launch suite settings have been updated.', OP_SN); } } else { $this->error = __('Verification failed, please refresh the page and try again.', OP_SN); } } }
function save_step() { //Get the primary OP object $op = $_POST['op']; //Get sections $sections_op = op_get_var($op, 'sections', array()); //Loop through sections foreach ($this->sections as $name => $section) { //Get current sections $sections = $section['object']->sections(); //Loop through sub sections foreach ($sections as $section_name => $section_section) { if (is_array($section_section)) { if (isset($section_section['save_action'])) { call_user_func_array($section_section['save_action'], array($sections_op)); } if (isset($section_section['module'])) { $mod_ops = op_get_var($op, $section_name, array()); $opts = op_get_var($section_section, 'options', array()); op_mod($section_section['module'])->save_settings($section_name, $opts, $mod_ops); } } } } if (op_has_error()) { $this->error = __('There was a problem processing the form, please review the errors below', 'optimizepress'); } else { $this->notification = __('Your settings have been updated.', 'optimizepress'); } }
function save_step($redirect = true) { $op = $_POST['op']; $sections_op = op_get_var($op, 'sections', array()); $sections = $this->sections->sections(); foreach ($sections as $name => $section) { if (is_array($section)) { if (isset($section['save_action'])) { call_user_func_array($section['save_action'], array($sections_op)); } if (isset($section['module'])) { $mod_ops = op_get_var($op, $name, array()); $opts = op_get_var($section, 'options', array()); op_mod($section['module'])->save_settings($name, $opts, $mod_ops); } } } if (!op_has_error() && $redirect) { wp_redirect(menu_page_url(OP_SN . '-setup-wizard', false) . '&step=' . ++$this->cur_step); } }
/** * Save page sections * * Run each section "save_action" callback which deals with saving of data * * @return void */ public function saveSections() { if (isset($_POST[OP_SN . '_support'])) { $op = $_POST['op']; $opSections = op_get_var($op, 'sections', array()); foreach ($this->sections as $name => $section) { $sections = $section['object']->sections(); foreach ($sections as $sectionName => $sectionData) { if (is_array($sectionData)) { if (isset($sectionData['save_action'])) { call_user_func_array($sectionData['save_action'], array($opSections)); } if (isset($sectionData['module'])) { $modOps = op_get_var($op, $sectionName, array()); $opts = op_get_var($sectionData, 'options', array()); op_mod($sectionData['module'])->save_settings($sectionName, $opts, $modOps); } } } } if (op_has_error()) { $this->error = __('There was a problem processing the form, please review the errors below', 'optimizepress'); } else { $this->notification = __('Your settings have been updated.', 'optimizepress'); } } }
function save_step() { $op = $_POST['op']; $sections_op = op_get_var($op, 'sections', array()); foreach ($this->sections as $name => $section) { $sections = $section['object']->sections(); foreach ($sections as $section_name => $section_section) { if (is_array($section_section)) { if (isset($section_section['save_action'])) { call_user_func_array($section_section['save_action'], array($sections_op)); } if (isset($section_section['module'])) { $mod_ops = op_get_var($op, $section_name, array()); $opts = op_get_var($section_section, 'options', array()); op_mod($section_section['module'])->save_settings($section_name, $opts, $mod_ops); } } } } $this->save_theme(); if (op_has_error()) { $this->error = __('There was a problem processing the form, please review the errors below', OP_SN); } else { $this->notification = __('Your blog settings have been updated.', OP_SN); } }