/** * Determine whether the save the main options or not. * * Determine whether the save the main options or not. * * @since 5.0.0 * @access public * @see __construct * @internal Uses admin_init action * */ public function maybe_save_options() { if (!current_user_can('update_core')) { return; } if (!isset($_GET['page']) || $_GET['page'] != $this->slug) { return; } if (!isset($_REQUEST['action'])) { return; } if (!isset($_POST['options'])) { return; } if ('mpsum_save_core_options' !== $_REQUEST['action']) { return; } check_admin_referer('mpsum_main_update', '_mpsum'); $query_args = array(); $query_args['updated'] = "1"; //Save options $options = $_POST['options']; if (isset($_POST['reset'])) { $options = $this->get_defaults(); } $options_to_save = array(); foreach ($options as $key => $value) { $option_value = sanitize_text_field($value); $options_to_save[sanitize_key($key)] = $option_value; } MPSUM_Updates_Manager::update_options($options_to_save, 'core'); //Redirect back to settings screen wp_redirect(esc_url_raw(add_query_arg($query_args, MPSUM_Admin::get_url()))); exit; }
protected function get_views() { global $totals, $status; $status_links = array(); foreach ($totals as $type => $count) { if (!$count) { continue; } switch ($type) { case 'all': $text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes'); break; case 'update_disabled': $text = _n('Updates Disabled <span class="count">(%s)</span>', 'Updates Disabled <span class="count">(%s)</span>', $count, 'stops-core-theme-and-plugin-updates'); break; case 'update_enabled': $text = _n('Updates Enabled <span class="count">(%s)</span>', 'Updates Enabled <span class="count">(%s)</span>', $count, 'stops-core-theme-and-plugin-updates'); break; case 'automatic': $text = _n('Automatic Updates <span class="count">(%s)</span>', 'Automatic Updates <span class="count">(%s)</span>', $count, 'stops-core-theme-and-plugin-updates'); break; } if ('search' != $type) { $theme_url = MPSUM_Admin::get_url(); $query_args = array('tab' => $this->tab, 'theme_status' => $type); $status_links[$type] = sprintf("<a href='%s' %s>%s</a>", add_query_arg($query_args, $theme_url), $type == $status ? ' class="current"' : '', sprintf($text, number_format_i18n($count))); } } return $status_links; }
/** * Determine whether the save the theme options or not. * * Determine whether the save the theme options or not. * * @since 5.0.0 * @access public * @see __construct * @internal Uses admin_init action * */ public function maybe_save_theme_options() { if (!current_user_can('update_themes')) { return; } if (!isset($_GET['page']) || $_GET['page'] != $this->slug) { return; } if (!isset($_GET['tab']) || $_GET['tab'] != $this->tab) { return; } if (!isset($_REQUEST['action'])) { return; } if (!isset($_REQUEST['_mpsum'])) { return; } $action = $_REQUEST['action']; //Build Query Args $paged = isset($_GET['paged']) ? absint($_GET['paged']) : false; $query_args = array(); $query_args['page'] = $this->slug; if (false !== $paged) { $query_args['paged'] = $paged; } $query_args['action'] = $action; $query_args['tab'] = $this->tab; $theme_status = isset($_REQUEST['theme_status']) ? $_REQUEST['theme_status'] : false; if (false !== $theme_status) { $query_args['theme_status'] = $theme_status; } //Save theme options $this->save_theme_update_options($action); //Redirect back to settings screen wp_redirect(esc_url_raw(add_query_arg($query_args, MPSUM_Admin::get_url()))); exit; }
/** * Determine whether the save the advanced options or not. * * Determine whether the save the advanced options or not. * * @since 5.0.0 * @access public * @see __construct * @internal Uses admin_init action * */ public function maybe_save_options() { if (!current_user_can('update_core')) { return; } if (!isset($_GET['page']) || $_GET['page'] != $this->slug) { return; } if (!isset($_POST['action'])) { return; } if (!isset($_POST['_mpsum'])) { return; } //Get action $action = $_POST['action']; if (empty($action)) { return; } switch ($action) { case 'mpsum_save_excluded_users': check_admin_referer('mpsum_exclude_users', '_mpsum'); $users = $_POST['mpsum_excluded_users']; if (!is_array($users) || empty($users)) { return; } $users_to_save = array(); foreach ($users as $index => $user_id) { $user_id = absint($user_id); if (0 === $user_id) { continue; } $users_to_save[] = $user_id; } MPSUM_Updates_Manager::update_options($users_to_save, 'excluded_users'); break; case 'mpsum_reset_options': check_admin_referer('mpsum_reset_options', '_mpsum'); MPSUM_Updates_Manager::update_options(array()); break; case 'mpsum_force_updates': wp_schedule_single_event(time() + 10, 'wp_update_plugins'); wp_schedule_single_event(time() + 10, 'wp_version_check'); wp_schedule_single_event(time() + 10, 'wp_update_themes'); wp_schedule_single_event(time() + 45, 'wp_maybe_auto_update'); break; default: return; } //Redirect args $query_args = array(); $query_args['updated'] = "1"; $query_args['tab'] = $this->tab; $query_args['mpaction'] = $action; //Redirect back to settings screen wp_redirect(esc_url_raw(add_query_arg($query_args, MPSUM_Admin::get_url()))); exit; }