public function validate_options($input = array()) { if ($_REQUEST['download_log_file']) { $this->download_log_file(); exit; } if (empty($input) && $_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST[self::$_plugin_action_slug])) { $input = $_POST[self::$_plugin_action_slug]; } $saved_option = parent::get_option('ac_inspector_log_path'); if (!empty($input['log_path'])) { if ($saved_option === FALSE) { parent::add_option('ac_inspector_log_path', $input['log_path']); } else { parent::update_option('ac_inspector_log_path', $input['log_path']); } parent::$log_path = $input['log_path']; } $routines = (array) ACI_Routine_Handler::get_all(); foreach (array_keys($routines) as $routine) { $routine_settings = ACI_Routine_Handler::get_options($routine); if (!empty($input[$routine]) && is_array($input[$routine])) { $new_routine_settings = $input[$routine]; } else { $new_routine_settings = array(); } foreach ($new_routine_settings as $opt => $val) { $routine_settings[$opt] = $new_routine_settings[$opt]; } $routine_settings = apply_filters($routine . '_settings', $routine_settings); ACI_Routine_Handler::set_options($routine, $routine_settings); } if (is_multisite() && is_plugin_active_for_network(ACI_PLUGIN_BASENAME)) { // redirect to settings page in network wp_redirect(add_query_arg(array('page' => ACI_PLUGIN_SLUG, 'updated' => 'true'), network_admin_url('settings.php'))); exit; } return $input; }
public static function set_options($routine, $args = array()) { if (empty($routine)) { return false; } if (self::is_scheduled($routine)) { $schedules = array_keys(wp_get_schedules()); $inspection_method = self::get_inspection_method($routine, self::get_options($routine)); $filters = $GLOBALS['wp_filter'][$action]; foreach ($schedules as $schedule) { $action = 'ac_inspection_' . $schedule; $filters = $GLOBALS['wp_filter'][$action]; if (!empty($filters)) { foreach ($filters as $priority => $filter) { foreach ($filter as $identifier => $function) { if ($function['function'] === $inspection_method) { remove_filter($action, $inspection_method, $priority); } } } } } } $options_key = self::routine_options_key($routine); return AC_Inspector::update_option($options_key, $args); }