/**
  * Validates the settings (the default validation).
  *
  * @param mixed $value The value of the submitted setting.
  * @param string $name The name (and key) of the submitted setting.
  * @return mixed The filtered value.
  * @author Paul Hughes
  * @since 3.0.1
  */
 public function validateSettings($value, $name)
 {
     switch ($name) {
         //This first case is deprecated and should no longer be used. Delete after next release.
         case 'custom_s3_bucket_name':
             $value = trim($value);
             $submitted_settings = $this->getSubmittedSettings();
             if (isset($submitted_settings['use_custom_s3_bucket']) && isset($submitted_settings['enable_proxy_rewrites']) && $submitted_settings['use_custom_s3_bucket'] && $submitted_settings['enable_proxy_rewrites']) {
                 if (isset($submitted_settings['forum_name'])) {
                     $forum_name = $submitted_settings['forum_name'];
                 } elseif (muut()->getForumName() != '') {
                     $forum_name = muut()->getForumName();
                 } else {
                     $forum_name = '';
                 }
                 $url_protocol = apply_filters('muut_s3_bucket_url_protocol', 'http');
                 $url = $url_protocol . '://' . $value . '.' . apply_filters('muut_amazon_s3_url', Muut::AMAZONS3URL) . '/' . $forum_name;
                 $valid = Muut_Field_Validation::validateExternalUri($url);
                 if (!$valid) {
                     $error_args = array('name' => $name, 'message' => __('Custom S3 Bucket name must be associated with a valid server. Make sure it matches the bucket you set up with Muut from your forum page settings.'), 'field' => 'muut_custom_s3_bucket_name', 'new_value' => $value, 'old_value' => muut()->getOption($name));
                     $this->addErrorToQueue($error_args);
                     // Unset the value, so nothing *breaks* (defaults to Muut.com indexing).
                     $value = '';
                 } else {
                     $value = sanitize_text_field($value);
                 }
             }
             break;
         case 'forum_name':
             $value = trim($value);
             // Make sure the forum name has no whitespace.
             $valid = Muut_Field_Validation::validateHasNoWhitespace($value) && Muut_Field_Validation::validateNoRegexEscaping($value, array('-'));
             if (!$valid) {
                 $error_args = array('name' => $name, 'message' => __('Forum name must contain no spaces or special characters of any kind. Make sure the forum name is the name you registered with Muut when you set up the forum.', 'muut'), 'field' => 'muut_forum_name', 'new_value' => stripslashes($value), 'old_value' => muut()->getForumName());
                 $this->addErrorToQueue($error_args);
                 $value = muut()->getForumName();
             } else {
                 $value = sanitize_text_field($value);
             }
             break;
         case 'subscription_api_key':
             $validations = array('validateHasNoWhitespace', 'validateAlphaNumeric');
             $value = trim($value);
             $valid = true;
             foreach ($validations as $validation) {
                 if (method_exists('Muut_Field_Validation', $validation) && $valid) {
                     $valid = Muut_Field_Validation::$validation($value);
                 }
             }
             if (!$valid) {
                 $error_args = array('name' => $name, 'message' => __('API Key must have no spaces and only alphanumeric characters.', 'muut'), 'field' => 'muut_subscription_api_key', 'new_value' => $value, 'old_value' => muut()->getOption($name));
                 $this->addErrorToQueue($error_args);
                 $value = muut()->getOption('subscription_api_key', '');
             } else {
                 $value = sanitize_text_field($value);
             }
             break;
         case 'subscription_secret_key':
             $validations = array('validateHasNoWhitespace', 'validateAlphaNumeric');
             $value = trim($value);
             $valid = true;
             foreach ($validations as $validation) {
                 if (method_exists('Muut_Field_Validation', $validation) && $valid) {
                     $valid = Muut_Field_Validation::$validation($value);
                 }
             }
             if (!$valid) {
                 $error_args = array('name' => $name, 'message' => __('Secret Key must have no spaces and only alphanumeric characters.', 'muut'), 'field' => 'muut_subscription_secret_key', 'new_value' => $value, 'old_value' => muut()->getOption($name));
                 $this->addErrorToQueue($error_args);
                 $value = muut()->getOption('subscription_secret_key', '');
             } else {
                 $value = sanitize_text_field($value);
             }
             break;
     }
     return $value;
 }