/**
  * just checks the field isn't blank
  *
  * @param $normalized_value
  * @return bool
  * @throws \EE_Validation_Error
  */
 function validate($normalized_value)
 {
     if ($normalized_value) {
         if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) {
             throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
         } else {
             if (!EEH_URL::remote_file_exists($normalized_value, array('sslverify' => false, 'limit_response_size' => 4095))) {
                 throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
             }
         }
     }
 }
 /**
  * just checks the field isn't blank
  *
  * @param $normalized_value
  * @return bool
  * @throws \EE_Validation_Error
  */
 function validate($normalized_value)
 {
     if ($normalized_value) {
         if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) {
             throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
         } else {
             EE_Registry::instance()->load_helper('URL');
             if (!EEH_URL::remote_file_exists($normalized_value)) {
                 throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
             }
         }
     }
 }
 /**
  * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default.
  * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart
  */
 function verify_button_urls($payment_methods = NULL)
 {
     EE_Registry::instance()->load_helper('URL');
     $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart);
     foreach ($payment_methods as $payment_method) {
         try {
             $current_button_url = $payment_method->button_url();
             $buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array('current_ssl' => str_replace("http://", "https://", $current_button_url), 'current' => str_replace("https://", "http://", $current_button_url), 'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()), 'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url())));
             foreach ($buttons_urls_to_try as $button_url_to_try) {
                 if ($button_url_to_try == $current_button_url && EEH_URL::remote_file_exists($button_url_to_try, array('sslverify' => false, 'limit_response_size' => 4095)) || $button_url_to_try != $current_button_url && EEH_URL::remote_file_exists($button_url_to_try)) {
                     if ($current_button_url != $button_url_to_try) {
                         $payment_method->save(array('PMD_button_url' => $button_url_to_try));
                         EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try));
                     }
                     //this image exists. So if wasn't set before, now it is;
                     //or if it was already set, we have nothing to do
                     break;
                 }
             }
         } catch (EE_Error $e) {
             $payment_method->set_active(FALSE);
         }
     }
 }