/** * Redirects the user back to the theme settings page */ function calibrefx_upgrade_redirect() { if (!is_admin()) { return; } //this will prevent redirect loop if (isset($_GET['upgraded'])) { calibrefx_admin_redirect('themes.php', array('page' => 'calibrefx', 'section' => 'system', 'upgraded' => 'true')); exit; } }
/** * Register the settings option in wp_options. * * @return null Returns early if not on the correct admin page. */ public function register_settings() { /** If this page doesn't store settings, no need to register them */ if (!$this->settings_field) { return; } register_setting($this->settings_field, $this->settings_field); add_option($this->settings_field, $this->default_settings); if (!isset($_REQUEST['page']) or $this->page_id != absint($_REQUEST['page'])) { return; } if (calibrefx_get_option('reset', $this->settings_field)) { //prevent redirect loop calibrefx_set_option('reset', 0); wp_cache_flush(); //refresh option caches if (update_option($this->settings_field, $this->default_settings)) { calibrefx_admin_redirect($this->page_id, array('reset' => 'true')); } else { calibrefx_admin_redirect($this->page_id, array('error' => 'true')); } exit; } }