/**
  * Method to receive and store submitted options when posted.
  */
 public function on_post()
 {
     if (isset($_POST[JanrainCapture::$name . '_action'])) {
         foreach ($this->fields as $field) {
             if (isset($_POST[$field['name']])) {
                 $value = $_POST[$field['name']];
                 if ($field['name'] == JanrainCapture::$name . '_address' || $field['name'] == JanrainCapture::$name . '_sso_address') {
                     $value = preg_replace('/^https?\\:\\/\\//i', '', $value);
                 }
                 JanrainCapture::update_option($field['name'], $value);
             } else {
                 if ($field['type'] == 'checkbox' && $field['screen'] == $_POST[JanrainCapture::$name . '_action']) {
                     $value = '0';
                     JanrainCapture::update_option($field['name'], $value);
                 } else {
                     if (JanrainCapture::get_option($field['name']) === false && isset($field['default']) && (!is_multisite() || is_main_site())) {
                         JanrainCapture::update_option($field['name'], $field['default']);
                     }
                 }
             }
         }
         $this->postMessage = array('class' => 'updated', 'message' => 'Configuration Saved');
     }
 }
 /**
  * Method to receive and store submitted options when posted.
  */
 public function on_post()
 {
     if (isset($_POST[JanrainCapture::$name . '_action']) && current_user_can('manage_options') && check_admin_referer(JanrainCapture::$name . '_action')) {
         foreach ($this->fields as $field) {
             if (isset($_POST[$field['name']])) {
                 $value = $_POST[$field['name']];
                 if (is_string($value)) {
                     $value = sanitize_text_field($value);
                 } elseif (is_array($value)) {
                     foreach ($value as $k => $v) {
                         if (is_string($v)) {
                             $value[$k] = sanitize_text_field($v);
                         }
                     }
                 }
                 JanrainCapture::update_option($field['name'], $value);
             } else {
                 if ($field['type'] == 'checkbox' && $field['screen'] == $_POST[JanrainCapture::$name . '_action']) {
                     $value = '0';
                     JanrainCapture::update_option($field['name'], $value);
                 } else {
                     if (JanrainCapture::get_option($field['name']) === false && isset($field['default'])) {
                         JanrainCapture::update_option($field['name'], $field['default']);
                     }
                 }
             }
         }
     }
 }