/** * Set current tab to the specified tab ID. * * @since 3.8.8 * * @uses check_admin_referer() Prevent CSRF * @uses WPSC_Settings_Page::get_current_tab() Initializes the current tab object. * @uses WPSC_Settings_Page::save_options() Saves the submitted options to the database. * @uses WPSC_Settings_Tab::callback_submit_options() If this method exists in the tab object, it will be called after WPSC_Settings_Page::save_options(). * * @access public * @param string $tab_id Optional. The Tab ID. If this is not specified, the $_GET['tab'] variable will be used. If that variable also does not exists, the first tab will be used. */ public function set_current_tab($tab_id = null) { if (!$tab_id) { $tabs = array_keys($this->tabs); if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->tabs)) { $this->current_tab_id = $_GET['tab']; } else { $this->current_tab_id = array_shift($tabs); } } else { $this->current_tab_id = $tab_id; } $this->current_tab = $this->get_current_tab(); if (isset($_REQUEST['wpsc_admin_action']) && $_REQUEST['wpsc_admin_action'] == 'submit_options') { check_admin_referer('update-options', 'wpsc-update-options'); $this->save_options(); do_action('wpsc_save_' . $this->current_tab_id . '_settings', $this->current_tab); $query_args = array(); if (is_callable(array($this->current_tab, 'callback_submit_options'))) { $additional_query_args = $this->current_tab->callback_submit_options(); if (!empty($additional_query_args)) { $query_args += $additional_query_args; } } if ($this->current_tab->is_update_message_displayed()) { if (!count(get_settings_errors())) { add_settings_error('wpsc-settings', 'settings_updated', __('Settings saved.'), 'updated'); } set_transient('settings_errors', get_settings_errors(), 30); $query_args['settings-updated'] = true; } wp_redirect(add_query_arg($query_args)); exit; } }
/** * Set current tab to the specified tab ID. * * @since 3.8.8 * * @uses check_admin_referer() Prevent CSRF * @uses WPSC_Settings_Page::get_current_tab() Initializes the current tab object. * @uses WPSC_Settings_Page::save_options() Saves the submitted options to the database. * @uses WPSC_Settings_Tab::callback_submit_options() If this method exists in the tab object, it will be called after WPSC_Settings_Page::save_options(). * * @access public * @param string $tab_id Optional. The Tab ID. If this is not specified, the $_GET['tab'] variable will be used. If that variable also does not exists, the first tab will be used. */ public function set_current_tab($tab_id = null) { if (!$tab_id) { if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->tabs)) { $this->current_tab_id = $_GET['tab']; } else { $this->current_tab_id = array_shift(array_keys($this->tabs)); } } else { $this->current_tab_id = $tab_id; } $this->current_tab = $this->get_current_tab(); if (isset($_REQUEST['wpsc_admin_action']) && $_REQUEST['wpsc_admin_action'] == 'submit_options') { check_admin_referer('update-options', 'wpsc-update-options'); $this->save_options(); if (is_callable(array($this->current_tab, 'callback_submit_options'))) { $this->current_tab->callback_submit_options(); } } }