WC_Settings_API::process_admin_options PHP Method

process_admin_options() public method

If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
public process_admin_options ( ) : boolean
return boolean was anything saved?
    public function process_admin_options()
    {
        $this->init_settings();
        $post_data = $this->get_post_data();
        foreach ($this->get_form_fields() as $key => $field) {
            if ('title' !== $this->get_field_type($field)) {
                try {
                    $this->settings[$key] = $this->get_field_value($key, $field, $post_data);
                } catch (Exception $e) {
                    $this->add_error($e->getMessage());
                }
            }
        }
        return update_option($this->get_option_key(), apply_filters('woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings));
    }

Usage Example

 /**
  * Processes and saves options.
  * If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
  * @since 2.6.0
  * @return bool was anything saved?
  */
 public function process_admin_options()
 {
     if ($this->instance_id) {
         $this->init_instance_settings();
         $post_data = $this->get_post_data();
         foreach ($this->get_instance_form_fields() as $key => $field) {
             if ('title' !== $this->get_field_type($field)) {
                 try {
                     $this->instance_settings[$key] = $this->get_field_value($key, $field, $post_data);
                 } catch (Exception $e) {
                     $this->add_error($e->getMessage());
                 }
             }
         }
         return update_option($this->get_instance_option_key(), apply_filters('woocommerce_shipping_' . $this->id . '_instance_settings_values', $this->instance_settings, $this));
     } else {
         return parent::process_admin_options();
     }
 }
All Usage Examples Of WC_Settings_API::process_admin_options