@@ -6,70 +6,70 @@ |
||
| 6 | 6 | |
| 7 | 7 | final class Recaptcha { |
| 8 | 8 | |
| 9 | - public $recaptcha_options; |
|
| 10 | - public $site_key; |
|
| 11 | - public $secret_key; |
|
| 9 | + public $recaptcha_options; |
|
| 10 | + public $site_key; |
|
| 11 | + public $secret_key; |
|
| 12 | 12 | |
| 13 | - const STATUS = 'yikes-mc-recaptcha-status'; |
|
| 14 | - const SITE_KEY = 'yikes-mc-recaptcha-site-key'; |
|
| 15 | - const SECRET_KEY = 'yikes-mc-recaptcha-secret-key'; |
|
| 13 | + const STATUS = 'yikes-mc-recaptcha-status'; |
|
| 14 | + const SITE_KEY = 'yikes-mc-recaptcha-site-key'; |
|
| 15 | + const SECRET_KEY = 'yikes-mc-recaptcha-secret-key'; |
|
| 16 | 16 | |
| 17 | - public function setup( $recaptcha_options = [] ) { |
|
| 18 | - if ( ! $this->has_recaptcha() ) { |
|
| 19 | - return false; |
|
| 20 | - } |
|
| 21 | - return $this->get_options( $recaptcha_options ); |
|
| 22 | - } |
|
| 17 | + public function setup( $recaptcha_options = [] ) { |
|
| 18 | + if ( ! $this->has_recaptcha() ) { |
|
| 19 | + return false; |
|
| 20 | + } |
|
| 21 | + return $this->get_options( $recaptcha_options ); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - private function has_recaptcha() { |
|
| 25 | - if ( get_option( static::STATUS, '' ) == '1' ) { |
|
| 26 | - return true; |
|
| 27 | - } |
|
| 28 | - return false; |
|
| 29 | - } |
|
| 24 | + private function has_recaptcha() { |
|
| 25 | + if ( get_option( static::STATUS, '' ) == '1' ) { |
|
| 26 | + return true; |
|
| 27 | + } |
|
| 28 | + return false; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - private function get_site_key() { |
|
| 32 | - $site_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 33 | - if ( ! $site_key ) { |
|
| 34 | - throw InvalidRecaptcha::from_site_key(); |
|
| 35 | - } |
|
| 36 | - return $site_key; |
|
| 37 | - } |
|
| 31 | + private function get_site_key() { |
|
| 32 | + $site_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 33 | + if ( ! $site_key ) { |
|
| 34 | + throw InvalidRecaptcha::from_site_key(); |
|
| 35 | + } |
|
| 36 | + return $site_key; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - private function get_secret_key() { |
|
| 40 | - $secret_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 41 | - if ( ! $secret_key ) { |
|
| 42 | - throw InvalidRecaptcha::from_secret_key(); |
|
| 43 | - } |
|
| 44 | - return $secret_key; |
|
| 45 | - } |
|
| 39 | + private function get_secret_key() { |
|
| 40 | + $secret_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 41 | + if ( ! $secret_key ) { |
|
| 42 | + throw InvalidRecaptcha::from_secret_key(); |
|
| 43 | + } |
|
| 44 | + return $secret_key; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - private function get_options( $defaults ) { |
|
| 48 | - // Store the site language (to load recaptcha in a specific language). |
|
| 49 | - $locale = get_locale(); |
|
| 50 | - $locale_split = explode( '_', $locale ); |
|
| 47 | + private function get_options( $defaults ) { |
|
| 48 | + // Store the site language (to load recaptcha in a specific language). |
|
| 49 | + $locale = get_locale(); |
|
| 50 | + $locale_split = explode( '_', $locale ); |
|
| 51 | 51 | |
| 52 | - // Setup reCAPTCHA parameters. |
|
| 53 | - $lang = ! empty( $locale_split ) ? $locale_split[0] : $locale; |
|
| 54 | - $lang = ! empty( $defaults['recaptcha_lang'] ) ? $defaults['recaptcha_lang'] : $lang; |
|
| 55 | - $type = ! empty( $defaults['recaptcha_type'] ) ? strtolower( $defaults['recaptcha_type'] ) : 'image'; // setup recaptcha type |
|
| 56 | - $theme = ! empty( $defaults['recaptcha_theme'] ) ? strtolower( $defaults['recaptcha_theme'] ) : 'light'; // setup recaptcha theme |
|
| 57 | - $size = ! empty( $defaults['recaptcha_size'] ) ? strtolower( $defaults['recaptcha_size'] ) : 'normal'; // setup recaptcha size |
|
| 58 | - $data_cb = ! empty( $defaults['recaptcha_data_callback'] ) ? $defaults['recaptcha_data_callback'] : false; // setup recaptcha size |
|
| 59 | - $expired_cb = ! empty( $defaults['recaptcha_expired_callback'] ) ? $defaults['recaptcha_expired_callback'] : false; // setup recaptcha size |
|
| 52 | + // Setup reCAPTCHA parameters. |
|
| 53 | + $lang = ! empty( $locale_split ) ? $locale_split[0] : $locale; |
|
| 54 | + $lang = ! empty( $defaults['recaptcha_lang'] ) ? $defaults['recaptcha_lang'] : $lang; |
|
| 55 | + $type = ! empty( $defaults['recaptcha_type'] ) ? strtolower( $defaults['recaptcha_type'] ) : 'image'; // setup recaptcha type |
|
| 56 | + $theme = ! empty( $defaults['recaptcha_theme'] ) ? strtolower( $defaults['recaptcha_theme'] ) : 'light'; // setup recaptcha theme |
|
| 57 | + $size = ! empty( $defaults['recaptcha_size'] ) ? strtolower( $defaults['recaptcha_size'] ) : 'normal'; // setup recaptcha size |
|
| 58 | + $data_cb = ! empty( $defaults['recaptcha_data_callback'] ) ? $defaults['recaptcha_data_callback'] : false; // setup recaptcha size |
|
| 59 | + $expired_cb = ! empty( $defaults['recaptcha_expired_callback'] ) ? $defaults['recaptcha_expired_callback'] : false; // setup recaptcha size |
|
| 60 | 60 | |
| 61 | - $script_params = '?hl=' . $lang . '&onload=renderReCaptchaCallback&render=explicit'; |
|
| 61 | + $script_params = '?hl=' . $lang . '&onload=renderReCaptchaCallback&render=explicit'; |
|
| 62 | 62 | |
| 63 | - return [ |
|
| 64 | - 'language' => $lang, |
|
| 65 | - 'theme' => $theme, |
|
| 66 | - 'type' => $type, |
|
| 67 | - 'size' => $size, |
|
| 68 | - 'success_callback' => $data_cb, |
|
| 69 | - 'expired_callback' => $expired_cb, |
|
| 70 | - 'script_params' => $script_params, |
|
| 71 | - 'site_key' => $this->get_site_key(), |
|
| 72 | - 'secret_key' => $this->get_secret_key(), |
|
| 73 | - ]; |
|
| 74 | - } |
|
| 63 | + return [ |
|
| 64 | + 'language' => $lang, |
|
| 65 | + 'theme' => $theme, |
|
| 66 | + 'type' => $type, |
|
| 67 | + 'size' => $size, |
|
| 68 | + 'success_callback' => $data_cb, |
|
| 69 | + 'expired_callback' => $expired_cb, |
|
| 70 | + 'script_params' => $script_params, |
|
| 71 | + 'site_key' => $this->get_site_key(), |
|
| 72 | + 'secret_key' => $this->get_secret_key(), |
|
| 73 | + ]; |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | \ No newline at end of file |
@@ -4,31 +4,31 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait SubmitButton { |
| 6 | 6 | |
| 7 | - public function submit_button_classes() { |
|
| 8 | - $submit_button_classes = 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-'; |
|
| 9 | - $submit_button_classes .= $this->form_id; |
|
| 10 | - $submit_button_classes .= ' btn btn-primary'; |
|
| 11 | - // Adding additional space in front of these classes. |
|
| 12 | - $submit_button_classes .= ' ' . $this->form_data['form_settings']['yikes-easy-mc-submit-button-classes']; |
|
| 13 | - $submit_button_classes .= $this->admin_class; |
|
| 14 | - return apply_filters( 'yikes-mailchimp-form-submit-button-classes', $submit_button_classes, $this->form_id ); |
|
| 15 | - } |
|
| 7 | + public function submit_button_classes() { |
|
| 8 | + $submit_button_classes = 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-'; |
|
| 9 | + $submit_button_classes .= $this->form_id; |
|
| 10 | + $submit_button_classes .= ' btn btn-primary'; |
|
| 11 | + // Adding additional space in front of these classes. |
|
| 12 | + $submit_button_classes .= ' ' . $this->form_data['form_settings']['yikes-easy-mc-submit-button-classes']; |
|
| 13 | + $submit_button_classes .= $this->admin_class; |
|
| 14 | + return apply_filters( 'yikes-mailchimp-form-submit-button-classes', $submit_button_classes, $this->form_id ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function submit_button_text( $shortcode_prop ) { |
|
| 18 | - $submit_button_text = ''; |
|
| 19 | - switch( true ) { |
|
| 20 | - case ! empty( $shortcode_prop ): |
|
| 21 | - $submit_button_text = $shortcode_prop; |
|
| 22 | - break; |
|
| 17 | + public function submit_button_text( $shortcode_prop ) { |
|
| 18 | + $submit_button_text = ''; |
|
| 19 | + switch( true ) { |
|
| 20 | + case ! empty( $shortcode_prop ): |
|
| 21 | + $submit_button_text = $shortcode_prop; |
|
| 22 | + break; |
|
| 23 | 23 | |
| 24 | - case $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']: |
|
| 25 | - $submit_button_text = $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']; |
|
| 26 | - break; |
|
| 24 | + case $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']: |
|
| 25 | + $submit_button_text = $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']; |
|
| 26 | + break; |
|
| 27 | 27 | |
| 28 | - default: |
|
| 29 | - $submit_button_text = __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 30 | - break; |
|
| 31 | - } |
|
| 32 | - return apply_filters( 'yikes-mailchimp-form-submit-button-text', $submit_button_text, $this->form_id ); |
|
| 33 | - } |
|
| 28 | + default: |
|
| 29 | + $submit_button_text = __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 30 | + break; |
|
| 31 | + } |
|
| 32 | + return apply_filters( 'yikes-mailchimp-form-submit-button-text', $submit_button_text, $this->form_id ); |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public function get_id() { |
| 105 | - return 'yikes-easy-mc-form-' . $this->form_id . '-' . $this->merge; |
|
| 106 | - } |
|
| 105 | + return 'yikes-easy-mc-form-' . $this->form_id . '-' . $this->merge; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | public function get_value() { |
| 109 | 109 | return $this->value; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | </p> |
| 140 | 140 | |
| 141 | 141 | <?php |
| 142 | - endif; |
|
| 142 | + endif; |
|
| 143 | 143 | ?> |
| 144 | 144 | <input type="<?= esc_attr( $this->get_type() ); ?>" |
| 145 | 145 | class="<?= esc_attr( implode( ' ' , $this->field_classes() ) ); ?>" |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | final class EasyFormsShortcode extends BaseShortcode { |
| 30 | 30 | |
| 31 | - const TAG = 'yikes-mailchimp'; |
|
| 31 | + const TAG = 'yikes-mailchimp'; |
|
| 32 | 32 | const VIEW_URI = 'views/easy-forms-shortcode'; |
| 33 | 33 | const SUBMITTED_URI = 'views/easy-forms-shortcode-completed'; |
| 34 | 34 | const TITLE_URI = 'views/easy-forms-shortcode-title'; |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | * @since %VERSION% |
| 52 | 52 | * @var string |
| 53 | 53 | */ |
| 54 | - private $view_uri = self::VIEW_URI; |
|
| 54 | + private $view_uri = self::VIEW_URI; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Get the default array of attributes for the shortcode. |
|
| 58 | - * |
|
| 59 | - * @since %VERSION% |
|
| 60 | - * @return array |
|
| 61 | - */ |
|
| 56 | + /** |
|
| 57 | + * Get the default array of attributes for the shortcode. |
|
| 58 | + * |
|
| 59 | + * @since %VERSION% |
|
| 60 | + * @return array |
|
| 61 | + */ |
|
| 62 | 62 | public function get_default_atts() { |
| 63 | 63 | return [ |
| 64 | 64 | 'form' => '', |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - /** |
|
| 162 | + /** |
|
| 163 | 163 | * Get the View URI to use for rendering the shortcode. |
| 164 | 164 | * |
| 165 | 165 | * @since %VERSION% |
@@ -168,15 +168,15 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | protected function get_view_uri() { |
| 170 | 170 | return $this->view_uri; |
| 171 | - } |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * Set the view URI. |
|
| 175 | - * |
|
| 176 | - * @since %VERSION% |
|
| 177 | - * |
|
| 178 | - * @param string $uri The URI to use. |
|
| 179 | - */ |
|
| 173 | + /** |
|
| 174 | + * Set the view URI. |
|
| 175 | + * |
|
| 176 | + * @since %VERSION% |
|
| 177 | + * |
|
| 178 | + * @param string $uri The URI to use. |
|
| 179 | + */ |
|
| 180 | 180 | private function set_view_uri( $uri ) { |
| 181 | 181 | $this->view_uri = $uri; |
| 182 | 182 | } |
@@ -191,15 +191,15 @@ discard block |
||
| 191 | 191 | return ! empty( $_POST ); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Render the current Renderable. |
|
| 196 | - * |
|
| 197 | - * @since %VERSION% |
|
| 198 | - * |
|
| 199 | - * @param array $context Context in which to render. |
|
| 200 | - * |
|
| 201 | - * @return string Rendered HTML. |
|
| 202 | - */ |
|
| 194 | + /** |
|
| 195 | + * Render the current Renderable. |
|
| 196 | + * |
|
| 197 | + * @since %VERSION% |
|
| 198 | + * |
|
| 199 | + * @param array $context Context in which to render. |
|
| 200 | + * |
|
| 201 | + * @return string Rendered HTML. |
|
| 202 | + */ |
|
| 203 | 203 | public function render( array $context = [] ) { |
| 204 | 204 | try { |
| 205 | 205 | $this->enqueue_assets(); |
@@ -250,15 +250,15 @@ discard block |
||
| 250 | 250 | return isset( $subscriber ) ? $subscriber : null; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Convert an exception to a string. |
|
| 255 | - * |
|
| 256 | - * @since %VERSION% |
|
| 257 | - * |
|
| 258 | - * @param \Exception $e The exception object. |
|
| 259 | - * |
|
| 260 | - * @return string |
|
| 261 | - */ |
|
| 253 | + /** |
|
| 254 | + * Convert an exception to a string. |
|
| 255 | + * |
|
| 256 | + * @since %VERSION% |
|
| 257 | + * |
|
| 258 | + * @param \Exception $e The exception object. |
|
| 259 | + * |
|
| 260 | + * @return string |
|
| 261 | + */ |
|
| 262 | 262 | private function exception_to_string( \Exception $e ) { |
| 263 | 263 | return sprintf( |
| 264 | 264 | /* translators: %s refers to the error message */ |
@@ -269,14 +269,14 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | public function load_assets() { |
| 271 | 271 | $submission_helper = new ScriptAsset( |
| 272 | - 'form-submission-helpers', |
|
| 273 | - 'assets/js/dev/form-submission-helpers', |
|
| 274 | - [ 'jquery' ], |
|
| 275 | - '1.0.0', |
|
| 276 | - ScriptAsset::ENQUEUE_HEADER |
|
| 277 | - ); |
|
| 272 | + 'form-submission-helpers', |
|
| 273 | + 'assets/js/dev/form-submission-helpers', |
|
| 274 | + [ 'jquery' ], |
|
| 275 | + '1.0.0', |
|
| 276 | + ScriptAsset::ENQUEUE_HEADER |
|
| 277 | + ); |
|
| 278 | 278 | |
| 279 | - $submission_helper->add_localization( 'form_submission_helpers', array( |
|
| 279 | + $submission_helper->add_localization( 'form_submission_helpers', array( |
|
| 280 | 280 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 281 | 281 | 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) ), |
| 282 | 282 | 'countries_with_zip' => $this->countries_with_zip(), |
@@ -289,19 +289,19 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | public function countries_with_zip() { |
| 292 | - return [ |
|
| 293 | - 'US' => 'US', 'GB' => 'GB', 'CA' => 'CA', |
|
| 294 | - 'IE' => 'IE', 'CN' => 'CN', 'IN' => 'IN', |
|
| 295 | - 'AU' => 'AU', 'BR' => 'BR', 'MX' => 'MX', |
|
| 296 | - 'IT' => 'IT', 'NZ' => 'NZ', 'JP' => 'JP', |
|
| 297 | - 'FR' => 'FR', 'GR' => 'GR', 'DE' => 'DE', |
|
| 298 | - 'NL' => 'NL', 'PT' => 'PT', 'ES' => 'ES' |
|
| 299 | - ]; |
|
| 300 | - } |
|
| 292 | + return [ |
|
| 293 | + 'US' => 'US', 'GB' => 'GB', 'CA' => 'CA', |
|
| 294 | + 'IE' => 'IE', 'CN' => 'CN', 'IN' => 'IN', |
|
| 295 | + 'AU' => 'AU', 'BR' => 'BR', 'MX' => 'MX', |
|
| 296 | + 'IT' => 'IT', 'NZ' => 'NZ', 'JP' => 'JP', |
|
| 297 | + 'FR' => 'FR', 'GR' => 'GR', 'DE' => 'DE', |
|
| 298 | + 'NL' => 'NL', 'PT' => 'PT', 'ES' => 'ES' |
|
| 299 | + ]; |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - public function page_data() { |
|
| 303 | - global $post; |
|
| 302 | + public function page_data() { |
|
| 303 | + global $post; |
|
| 304 | 304 | $page_data = isset( $post->ID ) ? $post->ID : 0; |
| 305 | 305 | return apply_filters( 'yikes-mailchimp-page-data', $page_data ); |
| 306 | - } |
|
| 306 | + } |
|
| 307 | 307 | } |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | namespace YIKES\EasyForms\Form; |
| 4 | 4 | |
| 5 | 5 | trait FormHelper { |
| 6 | - public function form_title( $title, $custom_title, $form_name ) { |
|
| 7 | - if ( $title ) { |
|
| 6 | + public function form_title( $title, $custom_title, $form_name ) { |
|
| 7 | + if ( $title ) { |
|
| 8 | 8 | if ( ! empty( $custom_title ) ) { |
| 9 | 9 | /** |
| 10 | 10 | * Filter the title that is displayed through the shortcode. |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $custom_title ), $this->form_id ); |
| 16 | 16 | } else { |
| 17 | - return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_name ), $this->form_id ); |
|
| 17 | + return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_name ), $this->form_id ); |
|
| 18 | 18 | } |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return false; |
|
| 22 | - } |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function form_description( $description, $custom_description ) { |
|
| 25 | - if ( $description ) { |
|
| 24 | + public function form_description( $description, $custom_description ) { |
|
| 25 | + if ( $description ) { |
|
| 26 | 26 | if ( ! empty( $custom_description ) ) { |
| 27 | 27 | /** |
| 28 | 28 | * Filter the description that is displayed through the shortcode. |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | return apply_filters( 'yikes-mailchimp-form-description', $this->form_data['form_description'], $this->form_id ); |
| 36 | 36 | } |
| 37 | 37 | } else { |
| 38 | - return false; |
|
| 39 | - } |
|
| 40 | - } |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - protected function reduce_field_count() { |
|
| 42 | + protected function reduce_field_count() { |
|
| 43 | 43 | $this->field_count = $this->field_count --; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $form_classes = $this->form_data['form_settings']['yikes-easy-mc-form-class-names']; |
| 52 | 52 | $form_classes .= ' yikes-easy-mc-form yikes-easy-mc-form-' . $this->form_id; |
| 53 | 53 | |
| 54 | - if ( isset( $this->form_inline ) && $this->form_inline != 0 ) { |
|
| 55 | - $form_classes .= ' yikes-mailchimp-form-inline '; |
|
| 56 | - } |
|
| 54 | + if ( isset( $this->form_inline ) && $this->form_inline != 0 ) { |
|
| 55 | + $form_classes .= ' yikes-mailchimp-form-inline '; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | $form_classes .= ' '; |
| 59 | 59 | |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | $form_classes .= ' yikes-easy-mc-display-none'; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - return $form_classes; |
|
| 66 | + return $form_classes; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function inline_form_override() { |
| 70 | 70 | return isset( $this->has_recaptcha ) || ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'eu-opt-in-compliance-for-mailchimp/yikes-inc-easy-mailchimp-eu-law-compliance-extension.php' ) ); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function edit_form_link() { |
|
| 73 | + public function edit_form_link() { |
|
| 74 | 74 | if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
| 75 | 75 | $edit_form_link = '<span class="edit-link">'; |
| 76 | 76 | $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $this->form_id ) ) . '" title="' . __( 'Edit' , 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $this->form_data['form_name'] ) . '">' . __( 'Edit Form' , 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
@@ -80,5 +80,5 @@ discard block |
||
| 80 | 80 | $edit_form_link = ''; |
| 81 | 81 | } |
| 82 | 82 | return $edit_form_link; |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -13,21 +13,21 @@ |
||
| 13 | 13 | |
| 14 | 14 | interface OptinMeta { |
| 15 | 15 | |
| 16 | - const EMAIL = 'email'; |
|
| 17 | - const TEXT = 'text'; |
|
| 18 | - const NUMBER = 'number'; |
|
| 19 | - const URL = 'url'; |
|
| 20 | - const IMAGE_URL = 'imageurl'; |
|
| 21 | - const PHONE = 'phone'; |
|
| 22 | - const ZIP = 'zip'; |
|
| 23 | - const ADDRESS = 'address'; |
|
| 24 | - const DATE = 'date'; |
|
| 25 | - const BIRTHDAY = 'birthday'; |
|
| 26 | - const DROPDOWN = 'dropdown'; |
|
| 27 | - const RADIO = 'radio'; |
|
| 28 | - const CHECKBOX = 'checkbox'; |
|
| 16 | + const EMAIL = 'email'; |
|
| 17 | + const TEXT = 'text'; |
|
| 18 | + const NUMBER = 'number'; |
|
| 19 | + const URL = 'url'; |
|
| 20 | + const IMAGE_URL = 'imageurl'; |
|
| 21 | + const PHONE = 'phone'; |
|
| 22 | + const ZIP = 'zip'; |
|
| 23 | + const ADDRESS = 'address'; |
|
| 24 | + const DATE = 'date'; |
|
| 25 | + const BIRTHDAY = 'birthday'; |
|
| 26 | + const DROPDOWN = 'dropdown'; |
|
| 27 | + const RADIO = 'radio'; |
|
| 28 | + const CHECKBOX = 'checkbox'; |
|
| 29 | 29 | |
| 30 | - const FIELD_MAP = [ |
|
| 30 | + const FIELD_MAP = [ |
|
| 31 | 31 | self::EMAIL => Types::EMAIL, |
| 32 | 32 | self::TEXT => Types::TEXT, |
| 33 | 33 | ]; |
@@ -10,126 +10,126 @@ |
||
| 10 | 10 | namespace YIKES\EasyForms\Form; |
| 11 | 11 | |
| 12 | 12 | trait FieldBuilder { |
| 13 | - protected function get_field_classes( $field ) { |
|
| 14 | - $field_classes = []; |
|
| 15 | - $label_classes = []; |
|
| 13 | + protected function get_field_classes( $field ) { |
|
| 14 | + $field_classes = []; |
|
| 15 | + $label_classes = []; |
|
| 16 | 16 | |
| 17 | - $field_classes[] = 'yikes-easy-mc-' . $field['type']; |
|
| 18 | - $label_classes[] = $field['merge'] . '-label'; |
|
| 17 | + $field_classes[] = 'yikes-easy-mc-' . $field['type']; |
|
| 18 | + $label_classes[] = $field['merge'] . '-label'; |
|
| 19 | 19 | |
| 20 | - if( $field['additional-classes'] != '' ) { |
|
| 20 | + if( $field['additional-classes'] != '' ) { |
|
| 21 | 21 | |
| 22 | - $field_classes = explode( ' ' , $field['additional-classes'] ); |
|
| 22 | + $field_classes = explode( ' ' , $field['additional-classes'] ); |
|
| 23 | 23 | |
| 24 | - if( in_array( 'field-left-half' , $field_classes ) ) { |
|
| 25 | - $$label_classes[] = 'field-left-half'; |
|
| 26 | - $key = array_search( 'field-left-half' , $field_classes ); |
|
| 27 | - unset( $field_classes[$key] ); |
|
| 28 | - } // input half right |
|
| 29 | - if( in_array( 'field-right-half' , $field_classes ) ) { |
|
| 30 | - $$label_classes[] = 'field-right-half'; |
|
| 31 | - $key = array_search( 'field-right-half' , $field_classes ); |
|
| 32 | - unset( $field_classes[$key] ); |
|
| 33 | - } // input thirds (1/3 width, floated left) |
|
| 34 | - if( in_array( 'field-third' , $field_classes ) ) { |
|
| 35 | - $$label_classes[] = 'field-third'; |
|
| 36 | - $key = array_search( 'field-third' , $field_classes ); |
|
| 37 | - unset( $field_classes[$key] ); |
|
| 38 | - } // 2 column radio |
|
| 39 | - if( in_array( 'option-2-col' , $field_classes ) ) { |
|
| 40 | - $$label_classes[] = 'option-2-col'; |
|
| 41 | - $key = array_search( 'option-2-col' , $field_classes ); |
|
| 42 | - unset( $field_classes[$key] ); |
|
| 43 | - } // 3 column radio |
|
| 44 | - if( in_array( 'option-3-col' , $field_classes ) ) { |
|
| 45 | - $$label_classes[] = 'option-3-col'; |
|
| 46 | - $key = array_search( 'option-3-col' , $field_classes ); |
|
| 47 | - unset( $field_classes[$key] ); |
|
| 48 | - } // 4 column radio |
|
| 49 | - if( in_array( 'option-4-col' , $field_classes ) ) { |
|
| 50 | - $$label_classes[] = 'option-4-col'; |
|
| 51 | - $key = array_search( 'option-4-col' , $field_classes ); |
|
| 52 | - unset( $field_classes[$key] ); |
|
| 53 | - } // inline radio & checkboxes etc |
|
| 54 | - if( in_array( 'option-inline' , $field_classes ) ) { |
|
| 55 | - $$label_classes[] = 'option-inline'; |
|
| 56 | - $key = array_search( 'option-inline' , $field_classes ); |
|
| 57 | - unset( $field_classes[$key] ); |
|
| 58 | - } |
|
| 59 | - } |
|
| 24 | + if( in_array( 'field-left-half' , $field_classes ) ) { |
|
| 25 | + $$label_classes[] = 'field-left-half'; |
|
| 26 | + $key = array_search( 'field-left-half' , $field_classes ); |
|
| 27 | + unset( $field_classes[$key] ); |
|
| 28 | + } // input half right |
|
| 29 | + if( in_array( 'field-right-half' , $field_classes ) ) { |
|
| 30 | + $$label_classes[] = 'field-right-half'; |
|
| 31 | + $key = array_search( 'field-right-half' , $field_classes ); |
|
| 32 | + unset( $field_classes[$key] ); |
|
| 33 | + } // input thirds (1/3 width, floated left) |
|
| 34 | + if( in_array( 'field-third' , $field_classes ) ) { |
|
| 35 | + $$label_classes[] = 'field-third'; |
|
| 36 | + $key = array_search( 'field-third' , $field_classes ); |
|
| 37 | + unset( $field_classes[$key] ); |
|
| 38 | + } // 2 column radio |
|
| 39 | + if( in_array( 'option-2-col' , $field_classes ) ) { |
|
| 40 | + $$label_classes[] = 'option-2-col'; |
|
| 41 | + $key = array_search( 'option-2-col' , $field_classes ); |
|
| 42 | + unset( $field_classes[$key] ); |
|
| 43 | + } // 3 column radio |
|
| 44 | + if( in_array( 'option-3-col' , $field_classes ) ) { |
|
| 45 | + $$label_classes[] = 'option-3-col'; |
|
| 46 | + $key = array_search( 'option-3-col' , $field_classes ); |
|
| 47 | + unset( $field_classes[$key] ); |
|
| 48 | + } // 4 column radio |
|
| 49 | + if( in_array( 'option-4-col' , $field_classes ) ) { |
|
| 50 | + $$label_classes[] = 'option-4-col'; |
|
| 51 | + $key = array_search( 'option-4-col' , $field_classes ); |
|
| 52 | + unset( $field_classes[$key] ); |
|
| 53 | + } // inline radio & checkboxes etc |
|
| 54 | + if( in_array( 'option-inline' , $field_classes ) ) { |
|
| 55 | + $$label_classes[] = 'option-inline'; |
|
| 56 | + $key = array_search( 'option-inline' , $field_classes ); |
|
| 57 | + unset( $field_classes[$key] ); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - // if the form is set to inline, add the inline class to our labels |
|
| 62 | - if( $this->form_inline ) { |
|
| 63 | - $label_classes[] = 'label-inline'; |
|
| 64 | - } |
|
| 61 | + // if the form is set to inline, add the inline class to our labels |
|
| 62 | + if( $this->form_inline ) { |
|
| 63 | + $label_classes[] = 'label-inline'; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - if( isset( $field['hide-label'] ) ) { |
|
| 67 | - if( absint( $field['hide-label'] ) === 1 ) { |
|
| 68 | - $this->increase_hidden_label_count(); |
|
| 69 | - $field_classes[] = 'field-no-label'; |
|
| 70 | - } |
|
| 71 | - } |
|
| 66 | + if( isset( $field['hide-label'] ) ) { |
|
| 67 | + if( absint( $field['hide-label'] ) === 1 ) { |
|
| 68 | + $this->increase_hidden_label_count(); |
|
| 69 | + $field_classes[] = 'field-no-label'; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return [ |
|
| 74 | - 'field_classes' => $field_classes, |
|
| 75 | - 'label_classes' => $label_classes, |
|
| 76 | - ]; |
|
| 77 | - } |
|
| 73 | + return [ |
|
| 74 | + 'field_classes' => $field_classes, |
|
| 75 | + 'label_classes' => $label_classes, |
|
| 76 | + ]; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - protected function increase_hidden_label_count() { |
|
| 80 | - $this->hidden_label_count = $this->hidden_label_count++; |
|
| 81 | - } |
|
| 79 | + protected function increase_hidden_label_count() { |
|
| 80 | + $this->hidden_label_count = $this->hidden_label_count++; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - protected function get_label( $field ) { |
|
| 84 | - $label = []; |
|
| 85 | - if( $field['type'] == 'email' ) { |
|
| 86 | - $label['props']['visible'] = ''; |
|
| 87 | - } else { |
|
| 88 | - $label['props']['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
| 89 | - } |
|
| 90 | - if ( isset( $field['hide-label'] ) ) { |
|
| 91 | - $label['hide-label'] = true; |
|
| 92 | - } |
|
| 93 | - if ( isset( $field['label'] ) ) { |
|
| 94 | - $label['value'] = $field['label']; |
|
| 95 | - } |
|
| 96 | - return $label; |
|
| 97 | - } |
|
| 83 | + protected function get_label( $field ) { |
|
| 84 | + $label = []; |
|
| 85 | + if( $field['type'] == 'email' ) { |
|
| 86 | + $label['props']['visible'] = ''; |
|
| 87 | + } else { |
|
| 88 | + $label['props']['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
| 89 | + } |
|
| 90 | + if ( isset( $field['hide-label'] ) ) { |
|
| 91 | + $label['hide-label'] = true; |
|
| 92 | + } |
|
| 93 | + if ( isset( $field['label'] ) ) { |
|
| 94 | + $label['value'] = $field['label']; |
|
| 95 | + } |
|
| 96 | + return $label; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - protected function get_value( $field ) { |
|
| 100 | - // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
|
| 101 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 102 | - $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
|
| 103 | - return apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $this->form_id ); |
|
| 104 | - } |
|
| 99 | + protected function get_value( $field ) { |
|
| 100 | + // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
|
| 101 | + $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 102 | + $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
|
| 103 | + return apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $this->form_id ); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - protected function get_placeholder( $field ) { |
|
| 107 | - return isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
|
| 108 | - } |
|
| 106 | + protected function get_placeholder( $field ) { |
|
| 107 | + return isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - protected function get_hidden( $field ) { |
|
| 111 | - $visible = false; |
|
| 112 | - // if both hide label and hide field are checked, we gotta hide the field! |
|
| 113 | - if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
| 114 | - if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
| 115 | - $visible = true; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - return $visible; |
|
| 119 | - } |
|
| 110 | + protected function get_hidden( $field ) { |
|
| 111 | + $visible = false; |
|
| 112 | + // if both hide label and hide field are checked, we gotta hide the field! |
|
| 113 | + if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
| 114 | + if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
| 115 | + $visible = true; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + return $visible; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - protected function get_description( $field ) { |
|
| 122 | - $description = ''; |
|
| 123 | - $show_description = isset( $field['description'] ) ? true : false; |
|
| 124 | - $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 125 | - if ( $show_description === true ) { |
|
| 126 | - $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $this->form_id ); |
|
| 127 | - } |
|
| 121 | + protected function get_description( $field ) { |
|
| 122 | + $description = ''; |
|
| 123 | + $show_description = isset( $field['description'] ) ? true : false; |
|
| 124 | + $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 125 | + if ( $show_description === true ) { |
|
| 126 | + $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $this->form_id ); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - return [ |
|
| 130 | - 'show_description' => $show_description, |
|
| 131 | - 'description_above' => $description_above, |
|
| 132 | - 'description' => $description, |
|
| 133 | - ]; |
|
| 134 | - } |
|
| 129 | + return [ |
|
| 130 | + 'show_description' => $show_description, |
|
| 131 | + 'description_above' => $description_above, |
|
| 132 | + 'description' => $description, |
|
| 133 | + ]; |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | yikes_easy_mailchimp_stop_bugging_me() |
| 582 | 582 | Remove the Review us notification when user clicks 'Dismiss' |
| 583 | 583 | @since v3.1.1 |
| 584 | - */ |
|
| 584 | + */ |
|
| 585 | 585 | public function yikes_easy_mailchimp_stop_bugging_me() {
|
| 586 | 586 | if ( isset( $_GET['yikes_easy_mc_icons_nobug'] ) && (int) filter_var( $_GET['yikes_easy_mc_icons_nobug'], FILTER_SANITIZE_NUMBER_INT ) === 1 ) {
|
| 587 | 587 | add_option( 'yikes_easy_mailchimp_review_stop_bugging_me', true ); |
@@ -843,9 +843,9 @@ discard block |
||
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | /** |
| 846 | - * Register our admin pages |
|
| 847 | - * used to display data back to the user |
|
| 848 | - **/ |
|
| 846 | + * Register our admin pages |
|
| 847 | + * used to display data back to the user |
|
| 848 | + **/ |
|
| 849 | 849 | public function register_admin_pages() {
|
| 850 | 850 | |
| 851 | 851 | /* Top Level Menu 'Easy Mailchimp' */ |
@@ -964,28 +964,28 @@ discard block |
||
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | /** |
| 967 | - * Generate Us Easy Mailchimp Manage Forms Page |
|
| 968 | - * |
|
| 969 | - * @since 1.0.0 |
|
| 970 | - */ |
|
| 967 | + * Generate Us Easy Mailchimp Manage Forms Page |
|
| 968 | + * |
|
| 969 | + * @since 1.0.0 |
|
| 970 | + */ |
|
| 971 | 971 | function generateManageFormsPage() {
|
| 972 | 972 | require_once YIKES_MC_PATH . 'admin/partials/menu/manage-forms.php'; // include our manage forms page |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | /** |
| 976 | - * Generate Us Easy Mailchimp Manage Lists Page |
|
| 977 | - * |
|
| 978 | - * @since 1.0.0 |
|
| 979 | - */ |
|
| 976 | + * Generate Us Easy Mailchimp Manage Lists Page |
|
| 977 | + * |
|
| 978 | + * @since 1.0.0 |
|
| 979 | + */ |
|
| 980 | 980 | function generateManageListsPage() {
|
| 981 | 981 | require_once YIKES_MC_PATH . 'admin/partials/menu/manage-lists.php'; // include our lists page |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | /** |
| 985 | - * Generate Us Easy Mailchimp Support Page |
|
| 986 | - * |
|
| 987 | - * @since 1.0.0 |
|
| 988 | - */ |
|
| 985 | + * Generate Us Easy Mailchimp Support Page |
|
| 986 | + * |
|
| 987 | + * @since 1.0.0 |
|
| 988 | + */ |
|
| 989 | 989 | function generateSupportPage() {
|
| 990 | 990 | |
| 991 | 991 | wp_enqueue_script( 'yikes-inc-easy-mailchimp-extender-support-scripts', plugin_dir_url( __FILE__ ) . 'js/support.js', array( 'jquery' ), $this->version, false ); |
@@ -993,37 +993,37 @@ discard block |
||
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | /** |
| 996 | - * Generate Us Easy Mailchimp Edit Form Page |
|
| 997 | - * |
|
| 998 | - * @since 1.0.0 |
|
| 999 | - */ |
|
| 996 | + * Generate Us Easy Mailchimp Edit Form Page |
|
| 997 | + * |
|
| 998 | + * @since 1.0.0 |
|
| 999 | + */ |
|
| 1000 | 1000 | function generateEditFormPage() {
|
| 1001 | 1001 | require_once YIKES_MC_PATH . 'admin/partials/edit-form.php'; // include our options page |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | /** |
| 1005 | - * Generate Us Easy Mailchimp View List Page |
|
| 1006 | - * |
|
| 1007 | - * @since 1.0.0 |
|
| 1008 | - */ |
|
| 1005 | + * Generate Us Easy Mailchimp View List Page |
|
| 1006 | + * |
|
| 1007 | + * @since 1.0.0 |
|
| 1008 | + */ |
|
| 1009 | 1009 | function generateViewListPage() {
|
| 1010 | 1010 | require_once YIKES_MC_PATH . 'admin/partials/view-list.php'; // include our options page |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /** |
| 1014 | - * Generate Us Easy Mailchimp View User Page |
|
| 1015 | - * |
|
| 1016 | - * @since 1.0.0 |
|
| 1017 | - */ |
|
| 1014 | + * Generate Us Easy Mailchimp View User Page |
|
| 1015 | + * |
|
| 1016 | + * @since 1.0.0 |
|
| 1017 | + */ |
|
| 1018 | 1018 | function generateViewUserPage() {
|
| 1019 | 1019 | require_once YIKES_MC_PATH . 'admin/partials/view-user.php'; // include our options page |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | /** |
| 1023 | - * Register our plugin settings, and display them on our settings page |
|
| 1024 | - * |
|
| 1025 | - * @since v.5.4 |
|
| 1026 | - **/ |
|
| 1023 | + * Register our plugin settings, and display them on our settings page |
|
| 1024 | + * |
|
| 1025 | + * @since v.5.4 |
|
| 1026 | + **/ |
|
| 1027 | 1027 | function yikes_easy_mc_settings_init() {
|
| 1028 | 1028 | |
| 1029 | 1029 | /* Register General Settings Section */ |
@@ -1141,9 +1141,9 @@ discard block |
||
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
| 1144 | - * Options Sanitization & Validation |
|
| 1145 | - * @since complete re-write |
|
| 1146 | - **/ |
|
| 1144 | + * Options Sanitization & Validation |
|
| 1145 | + * @since complete re-write |
|
| 1146 | + **/ |
|
| 1147 | 1147 | function yikes_mc_validate_api_key( $input ) {
|
| 1148 | 1148 | if ( $input === '' ) {
|
| 1149 | 1149 | update_option( 'yikes-mc-api-validation', 'invalid_api_key' ); |
@@ -1175,20 +1175,20 @@ discard block |
||
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | /** |
| 1178 | - * Generate Us Easy Forms for Mailchimp Options Page |
|
| 1179 | - * |
|
| 1180 | - * @since 1.0.0 |
|
| 1181 | - */ |
|
| 1178 | + * Generate Us Easy Forms for Mailchimp Options Page |
|
| 1179 | + * |
|
| 1180 | + * @since 1.0.0 |
|
| 1181 | + */ |
|
| 1182 | 1182 | function generatePageOptions() {
|
| 1183 | 1183 | require_once YIKES_MC_PATH . 'admin/partials/menu/options.php'; // include our options page |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | /** |
| 1187 | - * Check if users API key is valid, if not |
|
| 1188 | - * this function will apply a disabled attribute |
|
| 1189 | - * to form fields. (input, dropdowns, buttons etc.) |
|
| 1190 | - * @since v5.5 re-write |
|
| 1191 | - **/ |
|
| 1187 | + * Check if users API key is valid, if not |
|
| 1188 | + * this function will apply a disabled attribute |
|
| 1189 | + * to form fields. (input, dropdowns, buttons etc.) |
|
| 1190 | + * @since v5.5 re-write |
|
| 1191 | + **/ |
|
| 1192 | 1192 | public function is_user_mc_api_valid_form( $echo = true ) {
|
| 1193 | 1193 | if ( $echo == true ) {
|
| 1194 | 1194 | if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) == 'invalid_api_key' ) {
|
@@ -1214,12 +1214,12 @@ discard block |
||
| 1214 | 1214 | * - http://stackoverflow.com/questions/6661530/php-multi-dimensional-array-search |
| 1215 | 1215 | */ |
| 1216 | 1216 | function findMCListID($id, $array) {
|
| 1217 | - foreach ($array as $key => $val) {
|
|
| 1218 | - if ($val['id'] === $id) {
|
|
| 1219 | - return $key; |
|
| 1220 | - } |
|
| 1221 | - } |
|
| 1222 | - return null; |
|
| 1217 | + foreach ($array as $key => $val) {
|
|
| 1218 | + if ($val['id'] === $id) {
|
|
| 1219 | + return $key; |
|
| 1220 | + } |
|
| 1221 | + } |
|
| 1222 | + return null; |
|
| 1223 | 1223 | } // end |
| 1224 | 1224 | |
| 1225 | 1225 | /* |
@@ -1394,13 +1394,13 @@ discard block |
||
| 1394 | 1394 | <?php |
| 1395 | 1395 | |
| 1396 | 1396 | /** |
| 1397 | - * yikes-mailchimp-excluded-redirect-post-types |
|
| 1398 | - * |
|
| 1399 | - * Filter the post types that will not show on the redirect list dropdown. |
|
| 1400 | - * |
|
| 1401 | - * @param array | $excluded_post_types | The array of default excluded post types |
|
| 1402 | - * @return array| $excluded_post_types | The array of user-defined excluded post types |
|
| 1403 | - */ |
|
| 1397 | + * yikes-mailchimp-excluded-redirect-post-types |
|
| 1398 | + * |
|
| 1399 | + * Filter the post types that will not show on the redirect list dropdown. |
|
| 1400 | + * |
|
| 1401 | + * @param array | $excluded_post_types | The array of default excluded post types |
|
| 1402 | + * @return array| $excluded_post_types | The array of user-defined excluded post types |
|
| 1403 | + */ |
|
| 1404 | 1404 | $excluded_post_types = array( 'attachment', 'revision', 'nav_menu_item', 'shop_order', 'shop_order_refund', 'custom_css', 'customize_changeset', 'forum', 'topic', 'reply' ); |
| 1405 | 1405 | $excluded_post_types = apply_filters( 'yikes-mailchimp-excluded-redirect-post-types', $excluded_post_types ); |
| 1406 | 1406 | |
@@ -1530,9 +1530,9 @@ discard block |
||
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | /** |
| 1533 | - * Custom action hook for our extensions to hook into |
|
| 1534 | - * @parameter get_current_screen() current screen information |
|
| 1535 | - */ |
|
| 1533 | + * Custom action hook for our extensions to hook into |
|
| 1534 | + * @parameter get_current_screen() current screen information |
|
| 1535 | + */ |
|
| 1536 | 1536 | do_action( 'yikes-mailchimp-admin-sidebar', get_current_screen() ); |
| 1537 | 1537 | |
| 1538 | 1538 | } |
@@ -2454,13 +2454,13 @@ discard block |
||
| 2454 | 2454 | $result = $this->form_interface->create_form( $form_data ); |
| 2455 | 2455 | |
| 2456 | 2456 | /** |
| 2457 | - * `yikes-mailchimp-after-duplicating-form` |
|
| 2458 | - * |
|
| 2459 | - * @param $post_id_to_clone | int | ID of the original form |
|
| 2460 | - * @param $result | mixed | ID of the new form OR false if the operation failed |
|
| 2461 | - * @param $form_data | array | Array of the form data |
|
| 2462 | - * |
|
| 2463 | - */ |
|
| 2457 | + * `yikes-mailchimp-after-duplicating-form` |
|
| 2458 | + * |
|
| 2459 | + * @param $post_id_to_clone | int | ID of the original form |
|
| 2460 | + * @param $result | mixed | ID of the new form OR false if the operation failed |
|
| 2461 | + * @param $form_data | array | Array of the form data |
|
| 2462 | + * |
|
| 2463 | + */ |
|
| 2464 | 2464 | do_action( 'yikes-mailchimp-after-duplicating-form', $post_id_to_clone, $result, $form_data ); |
| 2465 | 2465 | |
| 2466 | 2466 | if ( false === $result ) {
|
@@ -3,234 +3,234 @@ discard block |
||
| 3 | 3 | class Yikes_Inc_Easy_Mailchimp_Extender_Process_Submission_Handler { |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | - * A flag signifying whether we're dealing with an AJAX submission or standard form submission |
|
| 7 | - * |
|
| 8 | - * @since 6.3.0 |
|
| 9 | - * @access protected |
|
| 10 | - * @var bool | $is_ajax |
|
| 11 | - */ |
|
| 6 | + * A flag signifying whether we're dealing with an AJAX submission or standard form submission |
|
| 7 | + * |
|
| 8 | + * @since 6.3.0 |
|
| 9 | + * @access protected |
|
| 10 | + * @var bool | $is_ajax |
|
| 11 | + */ |
|
| 12 | 12 | protected $is_ajax; |
| 13 | 13 | |
| 14 | 14 | /**** Hardcoded Internal Variables ****/ |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * An array of form fields we don't process |
|
| 18 | - * |
|
| 19 | - * @since 6.3.0 |
|
| 20 | - * @access protected |
|
| 21 | - * @var array | $skipped_form_fields |
|
| 22 | - */ |
|
| 17 | + * An array of form fields we don't process |
|
| 18 | + * |
|
| 19 | + * @since 6.3.0 |
|
| 20 | + * @access protected |
|
| 21 | + * @var array | $skipped_form_fields |
|
| 22 | + */ |
|
| 23 | 23 | protected $skipped_form_fields; |
| 24 | 24 | |
| 25 | 25 | /**** Form Variables ****/ |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * The ID of the corresponding YIKES Mailchimp form |
|
| 29 | - * |
|
| 30 | - * @since 6.3.0 |
|
| 31 | - * @access public |
|
| 32 | - * @var int | $form_id |
|
| 33 | - */ |
|
| 28 | + * The ID of the corresponding YIKES Mailchimp form |
|
| 29 | + * |
|
| 30 | + * @since 6.3.0 |
|
| 31 | + * @access public |
|
| 32 | + * @var int | $form_id |
|
| 33 | + */ |
|
| 34 | 34 | public $form_id; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * The ID of the corresponding Mailchimp list |
|
| 38 | - * |
|
| 39 | - * @since 6.3.0 |
|
| 40 | - * @access public |
|
| 41 | - * @var int | $list_id |
|
| 42 | - */ |
|
| 37 | + * The ID of the corresponding Mailchimp list |
|
| 38 | + * |
|
| 39 | + * @since 6.3.0 |
|
| 40 | + * @access public |
|
| 41 | + * @var int | $list_id |
|
| 42 | + */ |
|
| 43 | 43 | public $list_id; |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | - * The submitted email |
|
| 47 | - * |
|
| 48 | - * @since 6.3.0 |
|
| 49 | - * @access public |
|
| 50 | - * @var string | $email |
|
| 51 | - */ |
|
| 46 | + * The submitted email |
|
| 47 | + * |
|
| 48 | + * @since 6.3.0 |
|
| 49 | + * @access public |
|
| 50 | + * @var string | $email |
|
| 51 | + */ |
|
| 52 | 52 | public $email; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * The array of error messages defined by the user and attached to this form |
|
| 56 | - * |
|
| 57 | - * @since 6.3.0 |
|
| 58 | - * @access public |
|
| 59 | - * @var array | $error_messages |
|
| 60 | - */ |
|
| 55 | + * The array of error messages defined by the user and attached to this form |
|
| 56 | + * |
|
| 57 | + * @since 6.3.0 |
|
| 58 | + * @access public |
|
| 59 | + * @var array | $error_messages |
|
| 60 | + */ |
|
| 61 | 61 | public $error_messages; |
| 62 | 62 | |
| 63 | 63 | /**** Default Error Messages ****/ |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * The error message for no form ID |
|
| 67 | - * |
|
| 68 | - * @since 6.3.0 |
|
| 69 | - * @access public |
|
| 70 | - * @var string | $handle_empty_form_id_message |
|
| 71 | - */ |
|
| 66 | + * The error message for no form ID |
|
| 67 | + * |
|
| 68 | + * @since 6.3.0 |
|
| 69 | + * @access public |
|
| 70 | + * @var string | $handle_empty_form_id_message |
|
| 71 | + */ |
|
| 72 | 72 | public $handle_empty_form_id_message; |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | - * The error message for no form found |
|
| 76 | - * |
|
| 77 | - * @since 6.3.0 |
|
| 78 | - * @access public |
|
| 79 | - * @var string | $handle_empty_form_message |
|
| 80 | - */ |
|
| 75 | + * The error message for no form found |
|
| 76 | + * |
|
| 77 | + * @since 6.3.0 |
|
| 78 | + * @access public |
|
| 79 | + * @var string | $handle_empty_form_message |
|
| 80 | + */ |
|
| 81 | 81 | public $handle_empty_form_message; |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | - * The error message for missing form fields |
|
| 85 | - * |
|
| 86 | - * @since 6.3.0 |
|
| 87 | - * @access public |
|
| 88 | - * @var string | $handle_empty_fields_generic_message |
|
| 89 | - */ |
|
| 84 | + * The error message for missing form fields |
|
| 85 | + * |
|
| 86 | + * @since 6.3.0 |
|
| 87 | + * @access public |
|
| 88 | + * @var string | $handle_empty_fields_generic_message |
|
| 89 | + */ |
|
| 90 | 90 | public $handle_empty_fields_generic_message; |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | - * The error message for missing $list_handler class |
|
| 94 | - * |
|
| 95 | - * @since 6.3.0 |
|
| 96 | - * @access public |
|
| 97 | - * @var string | $handle_empty_list_handler_message |
|
| 98 | - */ |
|
| 93 | + * The error message for missing $list_handler class |
|
| 94 | + * |
|
| 95 | + * @since 6.3.0 |
|
| 96 | + * @access public |
|
| 97 | + * @var string | $handle_empty_list_handler_message |
|
| 98 | + */ |
|
| 99 | 99 | public $handle_empty_list_handler_message; |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | - * The error message for no email |
|
| 103 | - * |
|
| 104 | - * @since 6.3.0 |
|
| 105 | - * @access public |
|
| 106 | - * @var string | $handle_empty_email_message |
|
| 107 | - */ |
|
| 102 | + * The error message for no email |
|
| 103 | + * |
|
| 104 | + * @since 6.3.0 |
|
| 105 | + * @access public |
|
| 106 | + * @var string | $handle_empty_email_message |
|
| 107 | + */ |
|
| 108 | 108 | public $handle_empty_email_message; |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | - * The error message for a filled in honeypot |
|
| 112 | - * |
|
| 113 | - * @since 6.3.0 |
|
| 114 | - * @access public |
|
| 115 | - * @var string | $handle_non_empty_honeypot_message |
|
| 116 | - */ |
|
| 111 | + * The error message for a filled in honeypot |
|
| 112 | + * |
|
| 113 | + * @since 6.3.0 |
|
| 114 | + * @access public |
|
| 115 | + * @var string | $handle_non_empty_honeypot_message |
|
| 116 | + */ |
|
| 117 | 117 | public $handle_non_empty_honeypot_message; |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * The error message for existing users trying to update when it's disallowed |
|
| 121 | - * |
|
| 122 | - * @since 6.3.0 |
|
| 123 | - * @access public |
|
| 124 | - * @var string | $handle_disallowed_existing_user_update_message |
|
| 125 | - */ |
|
| 120 | + * The error message for existing users trying to update when it's disallowed |
|
| 121 | + * |
|
| 122 | + * @since 6.3.0 |
|
| 123 | + * @access public |
|
| 124 | + * @var string | $handle_disallowed_existing_user_update_message |
|
| 125 | + */ |
|
| 126 | 126 | public $handle_disallowed_existing_user_update_message; |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | - * The first half of the error message for updating an existing user when it's done via a profile link |
|
| 130 | - * |
|
| 131 | - * @since 6.3.0 |
|
| 132 | - * @access public |
|
| 133 | - * @var string | $handle_updating_existing_user_message |
|
| 134 | - */ |
|
| 129 | + * The first half of the error message for updating an existing user when it's done via a profile link |
|
| 130 | + * |
|
| 131 | + * @since 6.3.0 |
|
| 132 | + * @access public |
|
| 133 | + * @var string | $handle_updating_existing_user_message |
|
| 134 | + */ |
|
| 135 | 135 | public $handle_updating_existing_user_message; |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | - * The second half of the error message (the link) for updating an existing user when it's done via a profile link |
|
| 139 | - * |
|
| 140 | - * @since 6.3.0 |
|
| 141 | - * @access public |
|
| 142 | - * @var string | $handle_updating_existing_user_link_message |
|
| 143 | - */ |
|
| 138 | + * The second half of the error message (the link) for updating an existing user when it's done via a profile link |
|
| 139 | + * |
|
| 140 | + * @since 6.3.0 |
|
| 141 | + * @access public |
|
| 142 | + * @var string | $handle_updating_existing_user_link_message |
|
| 143 | + */ |
|
| 144 | 144 | public $handle_updating_existing_user_link_message; |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | - * A default, generic error message |
|
| 148 | - * |
|
| 149 | - * @since 6.3.0 |
|
| 150 | - * @access public |
|
| 151 | - * @var string | $default_error_response_message |
|
| 152 | - */ |
|
| 147 | + * A default, generic error message |
|
| 148 | + * |
|
| 149 | + * @since 6.3.0 |
|
| 150 | + * @access public |
|
| 151 | + * @var string | $default_error_response_message |
|
| 152 | + */ |
|
| 153 | 153 | public $default_error_response_message; |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | - * The error message for not filling out a required form field |
|
| 157 | - * |
|
| 158 | - * @since 6.3.0 |
|
| 159 | - * @access public |
|
| 160 | - * @var string | $handle_empty_required_field_message |
|
| 161 | - */ |
|
| 156 | + * The error message for not filling out a required form field |
|
| 157 | + * |
|
| 158 | + * @since 6.3.0 |
|
| 159 | + * @access public |
|
| 160 | + * @var string | $handle_empty_required_field_message |
|
| 161 | + */ |
|
| 162 | 162 | public $handle_empty_required_field_message; |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | - * The error message for not filling out a required interest group |
|
| 166 | - * |
|
| 167 | - * @since 6.3.0 |
|
| 168 | - * @access public |
|
| 169 | - * @var string | $handle_empty_required_interest_group_message |
|
| 170 | - */ |
|
| 165 | + * The error message for not filling out a required interest group |
|
| 166 | + * |
|
| 167 | + * @since 6.3.0 |
|
| 168 | + * @access public |
|
| 169 | + * @var string | $handle_empty_required_interest_group_message |
|
| 170 | + */ |
|
| 171 | 171 | public $handle_empty_required_interest_group_message; |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * The error message for nonce failures |
|
| 175 | - * |
|
| 176 | - * @since 6.3.0 |
|
| 177 | - * @access public |
|
| 178 | - * @var string | $handle_nonce_message |
|
| 179 | - */ |
|
| 174 | + * The error message for nonce failures |
|
| 175 | + * |
|
| 176 | + * @since 6.3.0 |
|
| 177 | + * @access public |
|
| 178 | + * @var string | $handle_nonce_message |
|
| 179 | + */ |
|
| 180 | 180 | public $handle_nonce_message; |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | - * The error message for a recaptcha that is not checked/filled out |
|
| 184 | - * |
|
| 185 | - * @since 6.3.0 |
|
| 186 | - * @access public |
|
| 187 | - * @var string | $handle_nonce_message |
|
| 188 | - */ |
|
| 183 | + * The error message for a recaptcha that is not checked/filled out |
|
| 184 | + * |
|
| 185 | + * @since 6.3.0 |
|
| 186 | + * @access public |
|
| 187 | + * @var string | $handle_nonce_message |
|
| 188 | + */ |
|
| 189 | 189 | public $handle_non_filled_recaptcha_message_message; |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | - * The error message for recaptcha errors that we're not sure of |
|
| 193 | - * |
|
| 194 | - * @since 6.3.0 |
|
| 195 | - * @access public |
|
| 196 | - * @var string | $handle_nonce_message |
|
| 197 | - */ |
|
| 192 | + * The error message for recaptcha errors that we're not sure of |
|
| 193 | + * |
|
| 194 | + * @since 6.3.0 |
|
| 195 | + * @access public |
|
| 196 | + * @var string | $handle_nonce_message |
|
| 197 | + */ |
|
| 198 | 198 | public $generic_recaptcha_error_message; |
| 199 | 199 | |
| 200 | 200 | /**** Default Success Messages ****/ |
| 201 | 201 | |
| 202 | 202 | /** |
| 203 | - * The success message for single-optin forms |
|
| 204 | - * |
|
| 205 | - * @since 6.3.0 |
|
| 206 | - * @access public |
|
| 207 | - * @var string | $default_response_single_optin_success_message |
|
| 208 | - */ |
|
| 203 | + * The success message for single-optin forms |
|
| 204 | + * |
|
| 205 | + * @since 6.3.0 |
|
| 206 | + * @access public |
|
| 207 | + * @var string | $default_response_single_optin_success_message |
|
| 208 | + */ |
|
| 209 | 209 | public $default_response_single_optin_success_message; |
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | - * The default success message for double-optin forms |
|
| 213 | - * |
|
| 214 | - * @since 6.3.0 |
|
| 215 | - * @access public |
|
| 216 | - * @var string | $default_response_double_optin_success_message |
|
| 217 | - */ |
|
| 212 | + * The default success message for double-optin forms |
|
| 213 | + * |
|
| 214 | + * @since 6.3.0 |
|
| 215 | + * @access public |
|
| 216 | + * @var string | $default_response_double_optin_success_message |
|
| 217 | + */ |
|
| 218 | 218 | public $default_response_double_optin_success_message; |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * The default success message for already subscribed users re-subscribing |
|
| 222 | - * |
|
| 223 | - * @since 6.3.0 |
|
| 224 | - * @access public |
|
| 225 | - * @var string | $existing_subscriber_profile_update_message |
|
| 226 | - */ |
|
| 221 | + * The default success message for already subscribed users re-subscribing |
|
| 222 | + * |
|
| 223 | + * @since 6.3.0 |
|
| 224 | + * @access public |
|
| 225 | + * @var string | $existing_subscriber_profile_update_message |
|
| 226 | + */ |
|
| 227 | 227 | public $existing_subscriber_profile_update_message; |
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | - * The construct function - sets all of our hardcoded variables |
|
| 231 | - * |
|
| 232 | - * @param bool | $is_ajax | Flag signifying whether this submission request is coming from an AJAX response or basic form submission |
|
| 233 | - */ |
|
| 230 | + * The construct function - sets all of our hardcoded variables |
|
| 231 | + * |
|
| 232 | + * @param bool | $is_ajax | Flag signifying whether this submission request is coming from an AJAX response or basic form submission |
|
| 233 | + */ |
|
| 234 | 234 | public function __construct( $is_ajax ) { |
| 235 | 235 | |
| 236 | 236 | // Set up our variables |
@@ -268,45 +268,45 @@ discard block |
||
| 268 | 268 | /**** Setters for our Form Variables ****/ |
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | - * Set the form ID class property |
|
| 272 | - * |
|
| 273 | - * @since 6.3.0 |
|
| 274 | - * |
|
| 275 | - * @param int | $form_id | ID of the corresponding YIKES Mailchimp form |
|
| 276 | - */ |
|
| 271 | + * Set the form ID class property |
|
| 272 | + * |
|
| 273 | + * @since 6.3.0 |
|
| 274 | + * |
|
| 275 | + * @param int | $form_id | ID of the corresponding YIKES Mailchimp form |
|
| 276 | + */ |
|
| 277 | 277 | public function set_form_id( $form_id ) { |
| 278 | 278 | $this->form_id = $form_id; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | - * Set the list ID class property |
|
| 283 | - * |
|
| 284 | - * @since 6.3.0 |
|
| 285 | - * |
|
| 286 | - * @param int | $list_id | ID of the corresponding Mailchimp list |
|
| 287 | - */ |
|
| 282 | + * Set the list ID class property |
|
| 283 | + * |
|
| 284 | + * @since 6.3.0 |
|
| 285 | + * |
|
| 286 | + * @param int | $list_id | ID of the corresponding Mailchimp list |
|
| 287 | + */ |
|
| 288 | 288 | public function set_list_id( $list_id ) { |
| 289 | 289 | $this->list_id = $list_id; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | - * Set the email class property |
|
| 294 | - * |
|
| 295 | - * @since 6.3.0 |
|
| 296 | - * |
|
| 297 | - * @param string | $sanitized_email | The sanitized email |
|
| 298 | - */ |
|
| 293 | + * Set the email class property |
|
| 294 | + * |
|
| 295 | + * @since 6.3.0 |
|
| 296 | + * |
|
| 297 | + * @param string | $sanitized_email | The sanitized email |
|
| 298 | + */ |
|
| 299 | 299 | public function set_email( $sanitized_email ) { |
| 300 | 300 | $this->email = $sanitized_email; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
| 304 | - * Set the $error_messages class property |
|
| 305 | - * |
|
| 306 | - * @since 6.3.0 |
|
| 307 | - * |
|
| 308 | - * @param array | $error_messages | The array of user-defined error messages for this form |
|
| 309 | - */ |
|
| 304 | + * Set the $error_messages class property |
|
| 305 | + * |
|
| 306 | + * @since 6.3.0 |
|
| 307 | + * |
|
| 308 | + * @param array | $error_messages | The array of user-defined error messages for this form |
|
| 309 | + */ |
|
| 310 | 310 | public function set_error_messages( $error_messages ) { |
| 311 | 311 | $this->error_messages = $error_messages; |
| 312 | 312 | } |
@@ -315,24 +315,24 @@ discard block |
||
| 315 | 315 | /**** Simple Return Functions ****/ |
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | - * Return a sanitized email |
|
| 319 | - * |
|
| 320 | - * @since 6.3.0 |
|
| 321 | - * |
|
| 322 | - * @param string | $email | The user's email |
|
| 323 | - * @return string| $email | The user's email, lowercased and sanitized |
|
| 324 | - */ |
|
| 318 | + * Return a sanitized email |
|
| 319 | + * |
|
| 320 | + * @since 6.3.0 |
|
| 321 | + * |
|
| 322 | + * @param string | $email | The user's email |
|
| 323 | + * @return string| $email | The user's email, lowercased and sanitized |
|
| 324 | + */ |
|
| 325 | 325 | public function get_sanitized_email( $email ) { |
| 326 | 326 | return sanitize_email( strtolower( $email ) ); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | - * Return the class property $skipped_form_fields |
|
| 331 | - * |
|
| 332 | - * @since 6.3.0 |
|
| 333 | - * |
|
| 334 | - * @return array | $skipped_form_fields |
|
| 335 | - */ |
|
| 330 | + * Return the class property $skipped_form_fields |
|
| 331 | + * |
|
| 332 | + * @since 6.3.0 |
|
| 333 | + * |
|
| 334 | + * @return array | $skipped_form_fields |
|
| 335 | + */ |
|
| 336 | 336 | protected function get_skipped_merge_tags() { |
| 337 | 337 | return $this->skipped_form_fields; |
| 338 | 338 | } |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | /**** Collection of functions handling the incoming form and interest group data ****/ |
| 342 | 342 | |
| 343 | 343 | /** |
| 344 | - * Loop through form data to sanitize, format, filter, and return. |
|
| 345 | - * |
|
| 346 | - * @since 6.3.0 |
|
| 347 | - * |
|
| 348 | - * @param array | $data | The array of user-submitted form values |
|
| 349 | - * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 350 | - * @return array| $merge_variables| The array of sanitized and formatted form values |
|
| 351 | - */ |
|
| 344 | + * Loop through form data to sanitize, format, filter, and return. |
|
| 345 | + * |
|
| 346 | + * @since 6.3.0 |
|
| 347 | + * |
|
| 348 | + * @param array | $data | The array of user-submitted form values |
|
| 349 | + * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 350 | + * @return array| $merge_variables| The array of sanitized and formatted form values |
|
| 351 | + */ |
|
| 352 | 352 | public function get_submitted_merge_values( $data, $form_fields ) { |
| 353 | 353 | |
| 354 | 354 | // Array to return |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
| 403 | - * Sanitize form values and return them |
|
| 404 | - * |
|
| 405 | - * @since 6.3.0 |
|
| 406 | - * |
|
| 407 | - * @param string | $key | The MERGE/Field-name for this value |
|
| 408 | - * @param mixed | $value | The form value - this could be an array or a string |
|
| 409 | - * @return mixed | $sanitized | The $value sanitized |
|
| 410 | - */ |
|
| 403 | + * Sanitize form values and return them |
|
| 404 | + * |
|
| 405 | + * @since 6.3.0 |
|
| 406 | + * |
|
| 407 | + * @param string | $key | The MERGE/Field-name for this value |
|
| 408 | + * @param mixed | $value | The form value - this could be an array or a string |
|
| 409 | + * @return mixed | $sanitized | The $value sanitized |
|
| 410 | + */ |
|
| 411 | 411 | protected function sanitize_form_values( $key, $value ) { |
| 412 | 412 | if ( is_scalar( $value ) ) { |
| 413 | 413 | $sanitized = sanitize_text_field( $value ); |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | - * Check a date field's date format and pass it along to the appropriate function |
|
| 425 | - * |
|
| 426 | - * @since 6.3.0 |
|
| 427 | - * |
|
| 428 | - * @param string | $date | The unformatted date value |
|
| 429 | - * @param string | $date_format | The date format |
|
| 430 | - * @return string| $date | The date formatted according to the $date_format |
|
| 431 | - */ |
|
| 424 | + * Check a date field's date format and pass it along to the appropriate function |
|
| 425 | + * |
|
| 426 | + * @since 6.3.0 |
|
| 427 | + * |
|
| 428 | + * @param string | $date | The unformatted date value |
|
| 429 | + * @param string | $date_format | The date format |
|
| 430 | + * @return string| $date | The date formatted according to the $date_format |
|
| 431 | + */ |
|
| 432 | 432 | protected function handle_date_format_merge_values( $date, $date_format ) { |
| 433 | 433 | // Check if EU date format (for dates: 'DD/MM/YYYY', for birthdays: 'DD/MM') |
| 434 | 434 | if ( 'DD/MM/YYYY' === $date_format ) { |
@@ -441,13 +441,13 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | /** |
| 444 | - * Format a date field whose date format is dd/mm/yyyy |
|
| 445 | - * |
|
| 446 | - * @since 6.3.0 |
|
| 447 | - * |
|
| 448 | - * @param string | $date | A date in the format dd/mm/yyyy |
|
| 449 | - * @return string| $date | A date in the format mm/dd/yyyy |
|
| 450 | - */ |
|
| 444 | + * Format a date field whose date format is dd/mm/yyyy |
|
| 445 | + * |
|
| 446 | + * @since 6.3.0 |
|
| 447 | + * |
|
| 448 | + * @param string | $date | A date in the format dd/mm/yyyy |
|
| 449 | + * @return string| $date | A date in the format mm/dd/yyyy |
|
| 450 | + */ |
|
| 451 | 451 | protected function handle_dd_mm_yyyy_date( $date ) { |
| 452 | 452 | |
| 453 | 453 | // Mailchimp wants the dates as 'MM/DD/YYYY' regardless of user-specified format, so convert |
@@ -466,13 +466,13 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | - * Format a birthday field whose date format is dd/mm |
|
| 470 | - * |
|
| 471 | - * @since 6.3.0 |
|
| 472 | - * |
|
| 473 | - * @param string | $birthday | A date in the format dd/mm |
|
| 474 | - * @return string| $birthday | A date in the format mm/dd |
|
| 475 | - */ |
|
| 469 | + * Format a birthday field whose date format is dd/mm |
|
| 470 | + * |
|
| 471 | + * @since 6.3.0 |
|
| 472 | + * |
|
| 473 | + * @param string | $birthday | A date in the format dd/mm |
|
| 474 | + * @return string| $birthday | A date in the format mm/dd |
|
| 475 | + */ |
|
| 476 | 476 | protected function handle_dd_mm_birthday( $birthday ) { |
| 477 | 477 | |
| 478 | 478 | // Mailchimp wants the birthdays as 'MM/DD' regardless of user-specified format, so convert |
@@ -492,14 +492,14 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | |
| 494 | 494 | /** |
| 495 | - * Create an array of available interest groups based on the $replace_interests flag |
|
| 496 | - * |
|
| 497 | - * @since 6.3.0 |
|
| 498 | - * |
|
| 499 | - * @param bool | $replace_interests| True if we're replacing interest groups, false if updating interest groups |
|
| 500 | - * @param class | $list_class | Class for interacting with the current list |
|
| 501 | - * @return array | $groups | Array of interest groups |
|
| 502 | - */ |
|
| 495 | + * Create an array of available interest groups based on the $replace_interests flag |
|
| 496 | + * |
|
| 497 | + * @since 6.3.0 |
|
| 498 | + * |
|
| 499 | + * @param bool | $replace_interests| True if we're replacing interest groups, false if updating interest groups |
|
| 500 | + * @param class | $list_class | Class for interacting with the current list |
|
| 501 | + * @return array | $groups | Array of interest groups |
|
| 502 | + */ |
|
| 503 | 503 | public function get_default_interest_groups( $replace_interests, $list_class ) { |
| 504 | 504 | |
| 505 | 505 | // If $replace_interests flag is true then loop through interest groups and set them all to false to start. |
@@ -537,15 +537,15 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | |
| 539 | 539 | /** |
| 540 | - * Loop through the interest group form data to sanitize, format, filter, and return. |
|
| 541 | - * |
|
| 542 | - * @since 6.3.0 |
|
| 543 | - * |
|
| 544 | - * @param array | $data | The array of user-submitted form values |
|
| 545 | - * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 546 | - * @param array | $groups | The array of interest groups created by `get_default_interest_groups()` |
|
| 547 | - * @return array| $groups | The array of sanitized and formatted form values |
|
| 548 | - */ |
|
| 540 | + * Loop through the interest group form data to sanitize, format, filter, and return. |
|
| 541 | + * |
|
| 542 | + * @since 6.3.0 |
|
| 543 | + * |
|
| 544 | + * @param array | $data | The array of user-submitted form values |
|
| 545 | + * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 546 | + * @param array | $groups | The array of interest groups created by `get_default_interest_groups()` |
|
| 547 | + * @return array| $groups | The array of sanitized and formatted form values |
|
| 548 | + */ |
|
| 549 | 549 | public function get_submitted_interest_groups( $data, $form_fields, $groups ) { |
| 550 | 550 | |
| 551 | 551 | // loop to push variables to our array |
@@ -574,13 +574,13 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
| 577 | - * yikes-mailchimp-filter-groups-before-submission |
|
| 578 | - * |
|
| 579 | - * Catch the interest groups before they get sent over to Mailchimp |
|
| 580 | - * @param array | $groups | User submitted interest group data |
|
| 581 | - * @optional int| $form_id| the ID of the form to filter |
|
| 582 | - * @since 6.3.0 |
|
| 583 | - */ |
|
| 577 | + * yikes-mailchimp-filter-groups-before-submission |
|
| 578 | + * |
|
| 579 | + * Catch the interest groups before they get sent over to Mailchimp |
|
| 580 | + * @param array | $groups | User submitted interest group data |
|
| 581 | + * @optional int| $form_id| the ID of the form to filter |
|
| 582 | + * @since 6.3.0 |
|
| 583 | + */ |
|
| 584 | 584 | $groups = apply_filters( 'yikes-mailchimp-filter-groups-before-submission', $groups, $this->form_id ); |
| 585 | 585 | $groups = apply_filters( 'yikes-mailchimp-filter-groups-before-submission-{$this->form_id}', $groups, $this->form_id ); |
| 586 | 586 | |
@@ -591,17 +591,17 @@ discard block |
||
| 591 | 591 | /**** Functions to Handle Subscribe API Response ****/ |
| 592 | 592 | |
| 593 | 593 | /** |
| 594 | - * Handle the response to a successful subscribe request |
|
| 595 | - * |
|
| 596 | - * @since 6.3.0 |
|
| 597 | - * |
|
| 598 | - * @param array | $submission_settings | Array of the form's submission settings |
|
| 599 | - * @param array | $page_data | Array of the page data |
|
| 600 | - * @param array | $merge_variables | Array of the submitted form variables |
|
| 601 | - * @param array | $notifications | Literally don't know what this is yet. |
|
| 602 | - * @param array | $optin_settings | Array of the form's optin settings |
|
| 603 | - * @param bool | $new_subscriber | True if a new subscriber, false if an existing one |
|
| 604 | - */ |
|
| 594 | + * Handle the response to a successful subscribe request |
|
| 595 | + * |
|
| 596 | + * @since 6.3.0 |
|
| 597 | + * |
|
| 598 | + * @param array | $submission_settings | Array of the form's submission settings |
|
| 599 | + * @param array | $page_data | Array of the page data |
|
| 600 | + * @param array | $merge_variables | Array of the submitted form variables |
|
| 601 | + * @param array | $notifications | Literally don't know what this is yet. |
|
| 602 | + * @param array | $optin_settings | Array of the form's optin settings |
|
| 603 | + * @param bool | $new_subscriber | True if a new subscriber, false if an existing one |
|
| 604 | + */ |
|
| 605 | 605 | public function handle_submission_response_success( $submission_settings, $page_data, $merge_variables, $notifications, $optin_settings, $new_subscriber ) { |
| 606 | 606 | |
| 607 | 607 | // Check if we should redirect, and collect the redirect info in an array |
@@ -610,27 +610,27 @@ discard block |
||
| 610 | 610 | // Fire off our actions |
| 611 | 611 | |
| 612 | 612 | /** |
| 613 | - * yikes-mailchimp-after-submission || yikes-mailchimp-after-submission-{$form_id} |
|
| 614 | - * |
|
| 615 | - * Catch the merge variables after they've been sent over to Mailchimp |
|
| 616 | - * @since 6.0.0 |
|
| 617 | - * |
|
| 618 | - * @param array | $merge_variables | The array of user submitted form data |
|
| 619 | - */ |
|
| 613 | + * yikes-mailchimp-after-submission || yikes-mailchimp-after-submission-{$form_id} |
|
| 614 | + * |
|
| 615 | + * Catch the merge variables after they've been sent over to Mailchimp |
|
| 616 | + * @since 6.0.0 |
|
| 617 | + * |
|
| 618 | + * @param array | $merge_variables | The array of user submitted form data |
|
| 619 | + */ |
|
| 620 | 620 | do_action( 'yikes-mailchimp-after-submission', $merge_variables, $this->form_id ); |
| 621 | 621 | do_action( "yikes-mailchimp-after-submission-{$this->form_id}", $merge_variables, $this->form_id ); |
| 622 | 622 | |
| 623 | 623 | /** |
| 624 | - * yikes-mailchimp-form-submission || yikes-mailchimp-form-submission-{$form_id} |
|
| 625 | - * |
|
| 626 | - * Catch our notifications and other form data |
|
| 627 | - * |
|
| 628 | - * @param string | $email | The user's email |
|
| 629 | - * @param array | $merge_variables | The array of user submitted form data |
|
| 630 | - * @param string | $form_id | The form ID |
|
| 631 | - * @param array | $notifications | Array of notification messages |
|
| 632 | - * |
|
| 633 | - */ |
|
| 624 | + * yikes-mailchimp-form-submission || yikes-mailchimp-form-submission-{$form_id} |
|
| 625 | + * |
|
| 626 | + * Catch our notifications and other form data |
|
| 627 | + * |
|
| 628 | + * @param string | $email | The user's email |
|
| 629 | + * @param array | $merge_variables | The array of user submitted form data |
|
| 630 | + * @param string | $form_id | The form ID |
|
| 631 | + * @param array | $notifications | Array of notification messages |
|
| 632 | + * |
|
| 633 | + */ |
|
| 634 | 634 | do_action( 'yikes-mailchimp-form-submission', $this->email, $merge_variables, $this->form_id, $notifications ); |
| 635 | 635 | do_action( "yikes-mailchimp-form-submission-{$this->form_id}", $this->email, $merge_variables, $this->form_id, $notifications ); |
| 636 | 636 | |
@@ -652,15 +652,15 @@ discard block |
||
| 652 | 652 | $default_response = ( $new_subscriber === false ) ? $this->check_for_user_defined_response_message( 'success-resubscribed', $this->existing_subscriber_profile_update_message ) : $default_response; |
| 653 | 653 | |
| 654 | 654 | /** |
| 655 | - * yikes-mailchimp-success-response |
|
| 656 | - * |
|
| 657 | - * Filter the success message displayed to the user |
|
| 658 | - * |
|
| 659 | - * @param string | $default_response | The response message that will be shown to the user if unchanged (see above for logic) |
|
| 660 | - * @param string | $form_id | The form ID |
|
| 661 | - * @param array | $merge_variables | The array of user submitted form data |
|
| 662 | - * |
|
| 663 | - */ |
|
| 655 | + * yikes-mailchimp-success-response |
|
| 656 | + * |
|
| 657 | + * Filter the success message displayed to the user |
|
| 658 | + * |
|
| 659 | + * @param string | $default_response | The response message that will be shown to the user if unchanged (see above for logic) |
|
| 660 | + * @param string | $form_id | The form ID |
|
| 661 | + * @param array | $merge_variables | The array of user submitted form data |
|
| 662 | + * |
|
| 663 | + */ |
|
| 664 | 664 | $response_message = apply_filters( 'yikes-mailchimp-success-response', $default_response, $this->form_id, $merge_variables ); |
| 665 | 665 | |
| 666 | 666 | // Construct our success array variables |
@@ -679,13 +679,13 @@ discard block |
||
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
| 682 | - * Handle an unsuccessful/error subscribe request |
|
| 683 | - * |
|
| 684 | - * @since 6.3.0 |
|
| 685 | - * |
|
| 686 | - * @param object | $subscribe_response | The response from the API |
|
| 687 | - * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 688 | - */ |
|
| 682 | + * Handle an unsuccessful/error subscribe request |
|
| 683 | + * |
|
| 684 | + * @since 6.3.0 |
|
| 685 | + * |
|
| 686 | + * @param object | $subscribe_response | The response from the API |
|
| 687 | + * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 688 | + */ |
|
| 689 | 689 | public function handle_submission_response_error( $subscribe_response, $form_fields ) { |
| 690 | 690 | |
| 691 | 691 | // Get the error data |
@@ -727,13 +727,13 @@ discard block |
||
| 727 | 727 | // Note: All of these functions return `return $this->yikes_fail()`. Check function for more info. |
| 728 | 728 | |
| 729 | 729 | /** |
| 730 | - * Check if the submitted form data is missing any required fields |
|
| 731 | - * |
|
| 732 | - * @since 6.3.0 |
|
| 733 | - * |
|
| 734 | - * @param array | $data | The array of user-submitted form values |
|
| 735 | - * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 736 | - */ |
|
| 730 | + * Check if the submitted form data is missing any required fields |
|
| 731 | + * |
|
| 732 | + * @since 6.3.0 |
|
| 733 | + * |
|
| 734 | + * @param array | $data | The array of user-submitted form values |
|
| 735 | + * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 736 | + */ |
|
| 737 | 737 | public function check_for_required_form_fields( $data, $form_fields ) { |
| 738 | 738 | |
| 739 | 739 | // Set up our defaults |
@@ -758,15 +758,15 @@ discard block |
||
| 758 | 758 | foreach( $value as $field => $val ) { |
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | - * 'yikes-mailchimp-ignore-required-array-field' |
|
| 762 | - * |
|
| 763 | - * Filter the default array of fields we're ignoring. As of now, this is only for address fields because no other field is an array. |
|
| 764 | - * |
|
| 765 | - * @param array | Array of fields to ignore. Key of the array should be the field name. |
|
| 766 | - * @param int | $form_id |
|
| 767 | - * |
|
| 768 | - * @return Array of fields to ignore. |
|
| 769 | - */ |
|
| 761 | + * 'yikes-mailchimp-ignore-required-array-field' |
|
| 762 | + * |
|
| 763 | + * Filter the default array of fields we're ignoring. As of now, this is only for address fields because no other field is an array. |
|
| 764 | + * |
|
| 765 | + * @param array | Array of fields to ignore. Key of the array should be the field name. |
|
| 766 | + * @param int | $form_id |
|
| 767 | + * |
|
| 768 | + * @return Array of fields to ignore. |
|
| 769 | + */ |
|
| 770 | 770 | $ignored_fields = apply_filters( 'yikes-mailchimp-ignore-required-array-field', array( 'addr2' => true ), $this->form_id ); |
| 771 | 771 | |
| 772 | 772 | if ( empty( $val ) && ! isset( $ignored_fields[ $field ] ) ) { |
@@ -797,14 +797,14 @@ discard block |
||
| 797 | 797 | ); |
| 798 | 798 | |
| 799 | 799 | /** |
| 800 | - * yikes-mailchimp-required-form-field-missing |
|
| 801 | - * |
|
| 802 | - * Alter the response message shown to the user for missing required form fields |
|
| 803 | - * |
|
| 804 | - * @param string | $handle_empty_required_field_message | The default message displayed to the user |
|
| 805 | - * @param int | $form_id | The ID of the form |
|
| 806 | - * @param array | $missing_fields | Array of the missing required fields |
|
| 807 | - */ |
|
| 800 | + * yikes-mailchimp-required-form-field-missing |
|
| 801 | + * |
|
| 802 | + * Alter the response message shown to the user for missing required form fields |
|
| 803 | + * |
|
| 804 | + * @param string | $handle_empty_required_field_message | The default message displayed to the user |
|
| 805 | + * @param int | $form_id | The ID of the form |
|
| 806 | + * @param array | $missing_fields | Array of the missing required fields |
|
| 807 | + */ |
|
| 808 | 808 | $default_response = apply_filters( 'yikes-mailchimp-required-form-field-missing', $this->handle_empty_required_field_message, $this->form_id, $missing_fields ); |
| 809 | 809 | |
| 810 | 810 | // If we've found a missing field, return the array of field data |
@@ -813,13 +813,13 @@ discard block |
||
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * Check if the submitted form interest group data is missing any required fields |
|
| 817 | - * |
|
| 818 | - * @since 6.3.0 |
|
| 819 | - * |
|
| 820 | - * @param array | $data | The array of user-submitted form values |
|
| 821 | - * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 822 | - */ |
|
| 816 | + * Check if the submitted form interest group data is missing any required fields |
|
| 817 | + * |
|
| 818 | + * @since 6.3.0 |
|
| 819 | + * |
|
| 820 | + * @param array | $data | The array of user-submitted form values |
|
| 821 | + * @param array | $form_fields | The array of form field definitions for this YIKES Mailchimp form |
|
| 822 | + */ |
|
| 823 | 823 | public function check_for_required_interest_groups( $data, $form_fields ) { |
| 824 | 824 | |
| 825 | 825 | // Set up our defaults |
@@ -853,14 +853,14 @@ discard block |
||
| 853 | 853 | ); |
| 854 | 854 | |
| 855 | 855 | /** |
| 856 | - * yikes-mailchimp-required-interest-group-missing |
|
| 857 | - * |
|
| 858 | - * Alter the response message shown to the user for missing required form fields |
|
| 859 | - * |
|
| 860 | - * @param string | $handle_empty_required_interest_group_message | The default message displayed to the user |
|
| 861 | - * @param int | $form_id | The ID of the form |
|
| 862 | - * @param array | $missing_fields | Array of the missing required fields |
|
| 863 | - */ |
|
| 856 | + * yikes-mailchimp-required-interest-group-missing |
|
| 857 | + * |
|
| 858 | + * Alter the response message shown to the user for missing required form fields |
|
| 859 | + * |
|
| 860 | + * @param string | $handle_empty_required_interest_group_message | The default message displayed to the user |
|
| 861 | + * @param int | $form_id | The ID of the form |
|
| 862 | + * @param array | $missing_fields | Array of the missing required fields |
|
| 863 | + */ |
|
| 864 | 864 | $default_response = apply_filters( 'yikes-mailchimp-required-interest-group-missing', $this->handle_empty_required_interest_group_message, $this->form_id, $missing_fields ); |
| 865 | 865 | |
| 866 | 866 | // If we find a required interest group with an empty value, send an error |
@@ -869,13 +869,13 @@ discard block |
||
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | /** |
| 872 | - * Handle the reCAPTCHA |
|
| 873 | - * |
|
| 874 | - * @since 6.3.0 |
|
| 875 | - * |
|
| 876 | - * @param string | $recaptcha_response | The form value of the recaptcha field |
|
| 877 | - * @param int | $version | The version of recaptcha to use. |
|
| 878 | - */ |
|
| 872 | + * Handle the reCAPTCHA |
|
| 873 | + * |
|
| 874 | + * @since 6.3.0 |
|
| 875 | + * |
|
| 876 | + * @param string | $recaptcha_response | The form value of the recaptcha field |
|
| 877 | + * @param int | $version | The version of recaptcha to use. |
|
| 878 | + */ |
|
| 879 | 879 | public function handle_recaptcha( $recaptcha_response, $version = 2 ) { |
| 880 | 880 | |
| 881 | 881 | // Before we the hit the API, let's check that we actually got a response. |
@@ -883,11 +883,11 @@ discard block |
||
| 883 | 883 | if ( empty( $recaptcha_response ) ) { |
| 884 | 884 | |
| 885 | 885 | /** |
| 886 | - * yikes-mailchimp-recaptcha-required-error |
|
| 887 | - * |
|
| 888 | - * Catch the recaptcha errors before they're returned to the user |
|
| 889 | - * @param string | $recaptcha_errors | A string of recaptcha errors separated by a space |
|
| 890 | - */ |
|
| 886 | + * yikes-mailchimp-recaptcha-required-error |
|
| 887 | + * |
|
| 888 | + * Catch the recaptcha errors before they're returned to the user |
|
| 889 | + * @param string | $recaptcha_errors | A string of recaptcha errors separated by a space |
|
| 890 | + */ |
|
| 891 | 891 | $response = apply_filters( 'yikes-mailchimp-recaptcha-required-error', $this->handle_non_filled_recaptcha_message_message, $this->form_id ); |
| 892 | 892 | return $this->yikes_fail( $hide = 0, $error = 1, $response, array(), $return_response_non_ajax = true ); |
| 893 | 893 | } |
@@ -932,40 +932,40 @@ discard block |
||
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | /** |
| 935 | - * yikes-mailchimp-recaptcha-required-error |
|
| 936 | - * |
|
| 937 | - * Catch the recaptcha errors before they're returned to the user |
|
| 938 | - * @param string | $recaptcha_errors | A string of recaptcha errors separated by a space |
|
| 939 | - */ |
|
| 935 | + * yikes-mailchimp-recaptcha-required-error |
|
| 936 | + * |
|
| 937 | + * Catch the recaptcha errors before they're returned to the user |
|
| 938 | + * @param string | $recaptcha_errors | A string of recaptcha errors separated by a space |
|
| 939 | + */ |
|
| 940 | 940 | $response = apply_filters( 'yikes-mailchimp-recaptcha-required-error', implode( ' ', $recaptcha_errors ), $this->form_id ); |
| 941 | 941 | return $this->yikes_fail( $hide = 0, $error = 1, $response, array(), $return_response_non_ajax = true ); |
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | /** |
| 946 | - * Handle the nonce field |
|
| 947 | - * |
|
| 948 | - * @since 6.3.0 |
|
| 949 | - * |
|
| 950 | - * @param string | $nonce_value | The form value of the nonce |
|
| 951 | - * @param string | $nonce_name | The name of the nonce |
|
| 952 | - */ |
|
| 946 | + * Handle the nonce field |
|
| 947 | + * |
|
| 948 | + * @since 6.3.0 |
|
| 949 | + * |
|
| 950 | + * @param string | $nonce_value | The form value of the nonce |
|
| 951 | + * @param string | $nonce_name | The name of the nonce |
|
| 952 | + */ |
|
| 953 | 953 | public function handle_nonce( $nonce_value, $nonce_name ) { |
| 954 | 954 | |
| 955 | 955 | // First, check our option - this is set in the general settings page |
| 956 | 956 | if ( get_option( 'yikes-mailchimp-use-nonce' ) === '1' ) { |
| 957 | 957 | |
| 958 | 958 | /** |
| 959 | - * yikes-mailchimp-use-nonce-verification |
|
| 960 | - * |
|
| 961 | - * Decide if we're going to check the nonce value. |
|
| 962 | - * The reason we filter this is that some users are experiencing nonce issues repeatedly. |
|
| 963 | - * The default will always be to use the nonce. |
|
| 964 | - * |
|
| 965 | - * @param int | $form_id | The form id |
|
| 966 | - * |
|
| 967 | - * @return bool | True if we should check the nonce |
|
| 968 | - */ |
|
| 959 | + * yikes-mailchimp-use-nonce-verification |
|
| 960 | + * |
|
| 961 | + * Decide if we're going to check the nonce value. |
|
| 962 | + * The reason we filter this is that some users are experiencing nonce issues repeatedly. |
|
| 963 | + * The default will always be to use the nonce. |
|
| 964 | + * |
|
| 965 | + * @param int | $form_id | The form id |
|
| 966 | + * |
|
| 967 | + * @return bool | True if we should check the nonce |
|
| 968 | + */ |
|
| 969 | 969 | $use_nonce = apply_filters( 'yikes-mailchimp-use-nonce-verification', true, $this->form_id ); |
| 970 | 970 | |
| 971 | 971 | // We let the filter override the option because the filter is on a per-form basis |
@@ -978,24 +978,24 @@ discard block |
||
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | /** |
| 981 | - * Handle a merge_variables error |
|
| 982 | - * |
|
| 983 | - * @since 6.3.0 |
|
| 984 | - * |
|
| 985 | - * @param int | $error | Int $error = 1 if an error |
|
| 986 | - * @param string | $message | The message shown to the user |
|
| 987 | - */ |
|
| 981 | + * Handle a merge_variables error |
|
| 982 | + * |
|
| 983 | + * @since 6.3.0 |
|
| 984 | + * |
|
| 985 | + * @param int | $error | Int $error = 1 if an error |
|
| 986 | + * @param string | $message | The message shown to the user |
|
| 987 | + */ |
|
| 988 | 988 | public function handle_merge_variables_error( $error, $message ) { |
| 989 | 989 | return $this->yikes_fail( $hide = 0, $error, $message, array(), $return_response_non_ajax = true ); |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | /** |
| 993 | - * Handle an empty email field and return the corresponding error message |
|
| 994 | - * |
|
| 995 | - * @since 6.3.0 |
|
| 996 | - * |
|
| 997 | - * @param string | $email |
|
| 998 | - */ |
|
| 993 | + * Handle an empty email field and return the corresponding error message |
|
| 994 | + * |
|
| 995 | + * @since 6.3.0 |
|
| 996 | + * |
|
| 997 | + * @param string | $email |
|
| 998 | + */ |
|
| 999 | 999 | public function handle_empty_email( $email ) { |
| 1000 | 1000 | if ( empty( $email ) ) { |
| 1001 | 1001 | return $this->yikes_fail( $hide = 0, $error = 1, $this->handle_empty_email_message ); |
@@ -1003,12 +1003,12 @@ discard block |
||
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | /** |
| 1006 | - * Check if the form is empty and return the corresponding error message |
|
| 1007 | - * |
|
| 1008 | - * @since 6.3.0 |
|
| 1009 | - * |
|
| 1010 | - * @param array | $form_data |
|
| 1011 | - */ |
|
| 1006 | + * Check if the form is empty and return the corresponding error message |
|
| 1007 | + * |
|
| 1008 | + * @since 6.3.0 |
|
| 1009 | + * |
|
| 1010 | + * @param array | $form_data |
|
| 1011 | + */ |
|
| 1012 | 1012 | public function handle_empty_form( $form_data ) { |
| 1013 | 1013 | if ( empty( $form_data ) ) { |
| 1014 | 1014 | return $this->yikes_fail( $hide = 0, $error = 1, $this->handle_empty_form_message ); |
@@ -1016,12 +1016,12 @@ discard block |
||
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | /** |
| 1019 | - * Check if the honeypot is NOT empty and return the corresponding error message |
|
| 1020 | - * |
|
| 1021 | - * @since 6.3.0 |
|
| 1022 | - * |
|
| 1023 | - * @param bool | $honey_pot_filled | True if the honeypot was filled out |
|
| 1024 | - */ |
|
| 1019 | + * Check if the honeypot is NOT empty and return the corresponding error message |
|
| 1020 | + * |
|
| 1021 | + * @since 6.3.0 |
|
| 1022 | + * |
|
| 1023 | + * @param bool | $honey_pot_filled | True if the honeypot was filled out |
|
| 1024 | + */ |
|
| 1025 | 1025 | public function handle_non_empty_honeypot( $honey_pot_filled ) { |
| 1026 | 1026 | if ( $honey_pot_filled === true ) { |
| 1027 | 1027 | return $this->yikes_fail( $hide = 0, $error = 1, $this->handle_non_empty_honeypot_message ); |
@@ -1029,12 +1029,12 @@ discard block |
||
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | /** |
| 1032 | - * Loop through fields looking for null and return the corresponding error message |
|
| 1033 | - * |
|
| 1034 | - * @since 6.3.0 |
|
| 1035 | - * |
|
| 1036 | - * @param array | $fields_array | An array of fields to loop through and make sure they're not null |
|
| 1037 | - */ |
|
| 1032 | + * Loop through fields looking for null and return the corresponding error message |
|
| 1033 | + * |
|
| 1034 | + * @since 6.3.0 |
|
| 1035 | + * |
|
| 1036 | + * @param array | $fields_array | An array of fields to loop through and make sure they're not null |
|
| 1037 | + */ |
|
| 1038 | 1038 | public function handle_empty_fields_generic( $fields_array ) { |
| 1039 | 1039 | foreach( $fields_array as $field ) { |
| 1040 | 1040 | if ( $field === null ) { |
@@ -1044,12 +1044,12 @@ discard block |
||
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | /** |
| 1047 | - * Check if the list handler is empty and return the corresponding error message |
|
| 1048 | - * |
|
| 1049 | - * @since 6.3.0 |
|
| 1050 | - * |
|
| 1051 | - * @param class | $list_handler | A class that handles list functions |
|
| 1052 | - */ |
|
| 1047 | + * Check if the list handler is empty and return the corresponding error message |
|
| 1048 | + * |
|
| 1049 | + * @since 6.3.0 |
|
| 1050 | + * |
|
| 1051 | + * @param class | $list_handler | A class that handles list functions |
|
| 1052 | + */ |
|
| 1053 | 1053 | public function handle_empty_list_handler( $list_handler ) { |
| 1054 | 1054 | if ( empty( $list_handler ) ) { |
| 1055 | 1055 | return $this->yikes_fail( $hide = 0, $error = 1, $this->handle_empty_list_handler_message ); |
@@ -1057,12 +1057,12 @@ discard block |
||
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
| 1060 | - * Check if the form id is empty and return the corresponding error message |
|
| 1061 | - * |
|
| 1062 | - * @since 6.3.0 |
|
| 1063 | - * |
|
| 1064 | - * @param int | $form_id | The form ID |
|
| 1065 | - */ |
|
| 1060 | + * Check if the form id is empty and return the corresponding error message |
|
| 1061 | + * |
|
| 1062 | + * @since 6.3.0 |
|
| 1063 | + * |
|
| 1064 | + * @param int | $form_id | The form ID |
|
| 1065 | + */ |
|
| 1066 | 1066 | public function handle_empty_form_id( $form_id ) { |
| 1067 | 1067 | if ( empty( $form_id ) ) { |
| 1068 | 1068 | return $this->yikes_fail( $hide = 0, $error = 1, $this->handle_empty_form_id_message ); |
@@ -1070,10 +1070,10 @@ discard block |
||
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | /** |
| 1073 | - * Construct and filter the error message related to user's re-subscribing when it's not allowed |
|
| 1074 | - * |
|
| 1075 | - * @since 6.3.0 |
|
| 1076 | - */ |
|
| 1073 | + * Construct and filter the error message related to user's re-subscribing when it's not allowed |
|
| 1074 | + * |
|
| 1075 | + * @since 6.3.0 |
|
| 1076 | + */ |
|
| 1077 | 1077 | public function handle_disallowed_existing_user_update() { |
| 1078 | 1078 | |
| 1079 | 1079 | // Get the default response |
@@ -1086,10 +1086,10 @@ discard block |
||
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
| 1089 | - * Construct and filter the error message related to the profile link to update user's profile |
|
| 1090 | - * |
|
| 1091 | - * @since 6.3.0 |
|
| 1092 | - */ |
|
| 1089 | + * Construct and filter the error message related to the profile link to update user's profile |
|
| 1090 | + * |
|
| 1091 | + * @since 6.3.0 |
|
| 1092 | + */ |
|
| 1093 | 1093 | public function handle_updating_existing_user() { |
| 1094 | 1094 | |
| 1095 | 1095 | // Get the first half of the message |
@@ -1114,15 +1114,15 @@ discard block |
||
| 1114 | 1114 | /**** Helper Functions ****/ |
| 1115 | 1115 | |
| 1116 | 1116 | /** |
| 1117 | - * Check the user-defined $error_messages array for a message, filter it, and return it. These messages overwrite the defaults. |
|
| 1118 | - * |
|
| 1119 | - * @since 6.3.0 |
|
| 1120 | - * |
|
| 1121 | - * @param string | $slug | The type of message we're looking for |
|
| 1122 | - * @param string | $response_text| The default response message |
|
| 1123 | - * @param array | $data | An array of data that may be needed to construct the user's error message |
|
| 1124 | - * @return string| $response_text| The $response_text (after it's potentially been changed) |
|
| 1125 | - */ |
|
| 1117 | + * Check the user-defined $error_messages array for a message, filter it, and return it. These messages overwrite the defaults. |
|
| 1118 | + * |
|
| 1119 | + * @since 6.3.0 |
|
| 1120 | + * |
|
| 1121 | + * @param string | $slug | The type of message we're looking for |
|
| 1122 | + * @param string | $response_text| The default response message |
|
| 1123 | + * @param array | $data | An array of data that may be needed to construct the user's error message |
|
| 1124 | + * @return string| $response_text| The $response_text (after it's potentially been changed) |
|
| 1125 | + */ |
|
| 1126 | 1126 | protected function check_for_user_defined_response_message( $slug, $response_text, $data = false ) { |
| 1127 | 1127 | |
| 1128 | 1128 | switch( $slug ) { |
@@ -1136,13 +1136,13 @@ discard block |
||
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | /** |
| 1139 | - * yikes-easy-mailchimp-user-already-subscribed-text |
|
| 1140 | - * |
|
| 1141 | - * Catch the message for user's already subscrbed before we show it to the user |
|
| 1142 | - * @param string | $message | The response message |
|
| 1143 | - * @param int | $form_id | The form id |
|
| 1144 | - * @param string | $email | The user's email |
|
| 1145 | - */ |
|
| 1139 | + * yikes-easy-mailchimp-user-already-subscribed-text |
|
| 1140 | + * |
|
| 1141 | + * Catch the message for user's already subscrbed before we show it to the user |
|
| 1142 | + * @param string | $message | The response message |
|
| 1143 | + * @param int | $form_id | The form id |
|
| 1144 | + * @param string | $email | The user's email |
|
| 1145 | + */ |
|
| 1146 | 1146 | $response_text = apply_filters( 'yikes-mailchimp-user-already-subscribed-text', $response_text, $this->form_id, $this->email ); |
| 1147 | 1147 | |
| 1148 | 1148 | return $response_text; |
@@ -1161,13 +1161,13 @@ discard block |
||
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | /** |
| 1164 | - * yikes-easy-mailchimp-user-already-subscribed-link-text |
|
| 1165 | - * |
|
| 1166 | - * Catch the message for user's already subscrbed link text before we show it to the user |
|
| 1167 | - * |
|
| 1168 | - * @param string | $response_text | The response message that will be shown to the user |
|
| 1169 | - * @param string | $form_id | The form ID |
|
| 1170 | - */ |
|
| 1164 | + * yikes-easy-mailchimp-user-already-subscribed-link-text |
|
| 1165 | + * |
|
| 1166 | + * Catch the message for user's already subscrbed link text before we show it to the user |
|
| 1167 | + * |
|
| 1168 | + * @param string | $response_text | The response message that will be shown to the user |
|
| 1169 | + * @param string | $form_id | The form ID |
|
| 1170 | + */ |
|
| 1171 | 1171 | $response_text = apply_filters( 'yikes-mailchimp-user-already-subscribed-link-text', $response_text, $this->form_id ); |
| 1172 | 1172 | |
| 1173 | 1173 | return $response_text; |
@@ -1181,14 +1181,14 @@ discard block |
||
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | /** |
| 1184 | - * yikes-mailchimp-success-double-optin-response |
|
| 1185 | - * |
|
| 1186 | - * Filter the success message displayed to the user |
|
| 1187 | - * |
|
| 1188 | - * @param string | $response_text | The response message that will be shown to the user |
|
| 1189 | - * @param string | $form_id | The form ID |
|
| 1190 | - * |
|
| 1191 | - */ |
|
| 1184 | + * yikes-mailchimp-success-double-optin-response |
|
| 1185 | + * |
|
| 1186 | + * Filter the success message displayed to the user |
|
| 1187 | + * |
|
| 1188 | + * @param string | $response_text | The response message that will be shown to the user |
|
| 1189 | + * @param string | $form_id | The form ID |
|
| 1190 | + * |
|
| 1191 | + */ |
|
| 1192 | 1192 | $response_text = apply_filters( 'yikes-mailchimp-success-double-optin-response', $response_text, $this->form_id ); |
| 1193 | 1193 | |
| 1194 | 1194 | return $response_text; |
@@ -1201,14 +1201,14 @@ discard block |
||
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | /** |
| 1204 | - * yikes-mailchimp-success-single-optin-response |
|
| 1205 | - * |
|
| 1206 | - * Filter the success message displayed to the user |
|
| 1207 | - * |
|
| 1208 | - * @param string | $response_text | The response message that will be shown to the user |
|
| 1209 | - * @param string | $form_id | The form ID |
|
| 1210 | - * |
|
| 1211 | - */ |
|
| 1204 | + * yikes-mailchimp-success-single-optin-response |
|
| 1205 | + * |
|
| 1206 | + * Filter the success message displayed to the user |
|
| 1207 | + * |
|
| 1208 | + * @param string | $response_text | The response message that will be shown to the user |
|
| 1209 | + * @param string | $form_id | The form ID |
|
| 1210 | + * |
|
| 1211 | + */ |
|
| 1212 | 1212 | $response_text = apply_filters( 'yikes-mailchimp-success-single-optin-response', $response_text, $this->form_id ); |
| 1213 | 1213 | |
| 1214 | 1214 | return $response_text; |
@@ -1221,14 +1221,14 @@ discard block |
||
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | /** |
| 1224 | - * yikes-mailchimp-success-resubscribed-response |
|
| 1225 | - * |
|
| 1226 | - * Filter the success message displayed to the user |
|
| 1227 | - * |
|
| 1228 | - * @param string | $response_text | The response message that will be shown to the user |
|
| 1229 | - * @param string | $form_id | The form ID |
|
| 1230 | - * |
|
| 1231 | - */ |
|
| 1224 | + * yikes-mailchimp-success-resubscribed-response |
|
| 1225 | + * |
|
| 1226 | + * Filter the success message displayed to the user |
|
| 1227 | + * |
|
| 1228 | + * @param string | $response_text | The response message that will be shown to the user |
|
| 1229 | + * @param string | $form_id | The form ID |
|
| 1230 | + * |
|
| 1231 | + */ |
|
| 1232 | 1232 | $response_text = apply_filters( 'yikes-mailchimp-success-resubscribed-response', $response_text, $this->form_id ); |
| 1233 | 1233 | |
| 1234 | 1234 | return $response_text; |
@@ -1244,16 +1244,16 @@ discard block |
||
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
| 1247 | - * yikes-mailchimp-general-error-response |
|
| 1248 | - * |
|
| 1249 | - * Filter the error message displayed to the user |
|
| 1250 | - * |
|
| 1251 | - * @param string | $original_response_text | The original response message returned from the API |
|
| 1252 | - * @param string | $user_defined_response_text | The response message defined by the user |
|
| 1253 | - * @param string | $form_id | The form ID |
|
| 1254 | - * |
|
| 1255 | - * @return string | $response_text | The message that will be shown to the user |
|
| 1256 | - */ |
|
| 1247 | + * yikes-mailchimp-general-error-response |
|
| 1248 | + * |
|
| 1249 | + * Filter the error message displayed to the user |
|
| 1250 | + * |
|
| 1251 | + * @param string | $original_response_text | The original response message returned from the API |
|
| 1252 | + * @param string | $user_defined_response_text | The response message defined by the user |
|
| 1253 | + * @param string | $form_id | The form ID |
|
| 1254 | + * |
|
| 1255 | + * @return string | $response_text | The message that will be shown to the user |
|
| 1256 | + */ |
|
| 1257 | 1257 | $response_text = apply_filters( 'yikes-mailchimp-general-error-response', $original_response_text, $user_defined_response_text, $this->form_id ); |
| 1258 | 1258 | |
| 1259 | 1259 | return $response_text; |
@@ -1267,14 +1267,14 @@ discard block |
||
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | /** |
| 1270 | - * Wrap the response message in HTML for Non-AJAX form submissions |
|
| 1271 | - * |
|
| 1272 | - * @since 6.3.0 |
|
| 1273 | - * |
|
| 1274 | - * @param string | $message | The response message |
|
| 1275 | - * @param bool | $is_success | Boolean signifying if we're returning a success message or an error message |
|
| 1276 | - * @return string| The $message wrapping in HTML |
|
| 1277 | - */ |
|
| 1270 | + * Wrap the response message in HTML for Non-AJAX form submissions |
|
| 1271 | + * |
|
| 1272 | + * @since 6.3.0 |
|
| 1273 | + * |
|
| 1274 | + * @param string | $message | The response message |
|
| 1275 | + * @param bool | $is_success | Boolean signifying if we're returning a success message or an error message |
|
| 1276 | + * @return string| The $message wrapping in HTML |
|
| 1277 | + */ |
|
| 1278 | 1278 | public function wrap_form_submission_response( $message, $is_success ) { |
| 1279 | 1279 | |
| 1280 | 1280 | // If we're successful, we wrap the $message differently |
@@ -1288,14 +1288,14 @@ discard block |
||
| 1288 | 1288 | /**** Returning Success / Failure Functions ****/ |
| 1289 | 1289 | |
| 1290 | 1290 | /** |
| 1291 | - * Return success. Method of returning success based on the $is_ajax flag |
|
| 1292 | - * |
|
| 1293 | - * @since 6.3.0 |
|
| 1294 | - * |
|
| 1295 | - * @param array | $success_array | Array of success values to return |
|
| 1296 | - * |
|
| 1297 | - * @return If AJAX, return wp_send_json_success(). If not AJAX, set the global $process_submission_response variable and simply `return`. |
|
| 1298 | - */ |
|
| 1291 | + * Return success. Method of returning success based on the $is_ajax flag |
|
| 1292 | + * |
|
| 1293 | + * @since 6.3.0 |
|
| 1294 | + * |
|
| 1295 | + * @param array | $success_array | Array of success values to return |
|
| 1296 | + * |
|
| 1297 | + * @return If AJAX, return wp_send_json_success(). If not AJAX, set the global $process_submission_response variable and simply `return`. |
|
| 1298 | + */ |
|
| 1299 | 1299 | protected function yikes_success( $success_array ) { |
| 1300 | 1300 | if ( $this->is_ajax === true ) { |
| 1301 | 1301 | wp_send_json_success( $success_array ); |
@@ -1308,18 +1308,18 @@ discard block |
||
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | 1310 | /** |
| 1311 | - * Return failure. Method of returning failure based on the $is_ajax flag |
|
| 1312 | - * |
|
| 1313 | - * @since 6.3.0 |
|
| 1314 | - * |
|
| 1315 | - * @param int | $hide | Flag whether to hide the form (1 = hide, 0 = do not hide) |
|
| 1316 | - * @param int | $error | Flag whether this is an error (1 = error, 0 = no error) |
|
| 1317 | - * @param string | $response | The response message to display to the user |
|
| 1318 | - * @param array | $additional_fields | An array of additional fields to return |
|
| 1319 | - * @param bool | $return_response_non_ajax | Boolean deciding if we need to return a message |
|
| 1320 | - * |
|
| 1321 | - * @return If AJAX, return $this->yikes_send_json_error(). If not AJAX, return an array || false. |
|
| 1322 | - */ |
|
| 1311 | + * Return failure. Method of returning failure based on the $is_ajax flag |
|
| 1312 | + * |
|
| 1313 | + * @since 6.3.0 |
|
| 1314 | + * |
|
| 1315 | + * @param int | $hide | Flag whether to hide the form (1 = hide, 0 = do not hide) |
|
| 1316 | + * @param int | $error | Flag whether this is an error (1 = error, 0 = no error) |
|
| 1317 | + * @param string | $response | The response message to display to the user |
|
| 1318 | + * @param array | $additional_fields | An array of additional fields to return |
|
| 1319 | + * @param bool | $return_response_non_ajax | Boolean deciding if we need to return a message |
|
| 1320 | + * |
|
| 1321 | + * @return If AJAX, return $this->yikes_send_json_error(). If not AJAX, return an array || false. |
|
| 1322 | + */ |
|
| 1323 | 1323 | protected function yikes_fail( $hide, $error, $response, $additional_fields = array(), $return_response_non_ajax = false ) { |
| 1324 | 1324 | if ( $this->is_ajax === true ) { |
| 1325 | 1325 | $this->yikes_send_json_error( $hide, $error, $response, $additional_fields ); |
@@ -1332,17 +1332,17 @@ discard block |
||
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | /** |
| 1335 | - * Wrapper function for wp_send_json_error() |
|
| 1336 | - * |
|
| 1337 | - * @since 6.3.0 |
|
| 1338 | - * |
|
| 1339 | - * @param int | $hide | Flag whether to hide the form (1 = hide, 0 = do not hide) |
|
| 1340 | - * @param int | $error | Flag whether this is an error (1 = error, 0 = no error) |
|
| 1341 | - * @param string | $translated_string | The response message to display to the user |
|
| 1342 | - * @param array | $additional_fields | An array of additional fields to return |
|
| 1343 | - * |
|
| 1344 | - * @return func | wp_send_json_error() |
|
| 1345 | - */ |
|
| 1335 | + * Wrapper function for wp_send_json_error() |
|
| 1336 | + * |
|
| 1337 | + * @since 6.3.0 |
|
| 1338 | + * |
|
| 1339 | + * @param int | $hide | Flag whether to hide the form (1 = hide, 0 = do not hide) |
|
| 1340 | + * @param int | $error | Flag whether this is an error (1 = error, 0 = no error) |
|
| 1341 | + * @param string | $translated_string | The response message to display to the user |
|
| 1342 | + * @param array | $additional_fields | An array of additional fields to return |
|
| 1343 | + * |
|
| 1344 | + * @return func | wp_send_json_error() |
|
| 1345 | + */ |
|
| 1346 | 1346 | protected function yikes_send_json_error( $hide, $error, $translated_string, $additional_fields = array() ) { |
| 1347 | 1347 | |
| 1348 | 1348 | // Default response array |
@@ -1366,14 +1366,14 @@ discard block |
||
| 1366 | 1366 | /** Static functions used in other places **/ |
| 1367 | 1367 | |
| 1368 | 1368 | /** |
| 1369 | - * Handle the redirect logic for successful submissions |
|
| 1370 | - * |
|
| 1371 | - * @since 6.3.0 |
|
| 1372 | - * |
|
| 1373 | - * @param array | $submission_settings | Array of the form's submission settings |
|
| 1374 | - * @param array | $page_data | Page ID |
|
| 1375 | - * @return array| $redirect_array | Array with two values: Redirection flag, Redirect URL |
|
| 1376 | - */ |
|
| 1369 | + * Handle the redirect logic for successful submissions |
|
| 1370 | + * |
|
| 1371 | + * @since 6.3.0 |
|
| 1372 | + * |
|
| 1373 | + * @param array | $submission_settings | Array of the form's submission settings |
|
| 1374 | + * @param array | $page_data | Page ID |
|
| 1375 | + * @return array| $redirect_array | Array with two values: Redirection flag, Redirect URL |
|
| 1376 | + */ |
|
| 1377 | 1377 | public static function handle_submission_response_success_redirect( $form_id, $submission_settings, $page_data ) { |
| 1378 | 1378 | |
| 1379 | 1379 | $default_redirect_time_ms = 1500; |
@@ -1406,23 +1406,23 @@ discard block |
||
| 1406 | 1406 | $redirect_url = 'custom_url' !== $redirect_page_setting ? get_permalink( $redirect_page_setting ) : $custom_redirect_setting; |
| 1407 | 1407 | |
| 1408 | 1408 | /** |
| 1409 | - * yikes-mailchimp-redirect-url |
|
| 1410 | - * |
|
| 1411 | - * Catch the redirect URL before it's shown to the user |
|
| 1412 | - * |
|
| 1413 | - * @param string | $redirect_url | The URL that we will redirect to |
|
| 1414 | - * @param string | $form_id | The ID of the current form being subscribed to |
|
| 1415 | - * @param array | $page_data | An array of data related to the page the form is on |
|
| 1416 | - */ |
|
| 1409 | + * yikes-mailchimp-redirect-url |
|
| 1410 | + * |
|
| 1411 | + * Catch the redirect URL before it's shown to the user |
|
| 1412 | + * |
|
| 1413 | + * @param string | $redirect_url | The URL that we will redirect to |
|
| 1414 | + * @param string | $form_id | The ID of the current form being subscribed to |
|
| 1415 | + * @param array | $page_data | An array of data related to the page the form is on |
|
| 1416 | + */ |
|
| 1417 | 1417 | $redirect_url = apply_filters( 'yikes-mailchimp-redirect-url', $redirect_url, $form_id, $page_data ); |
| 1418 | 1418 | |
| 1419 | 1419 | /** |
| 1420 | - * yikes-mailchimp-redirect-timer |
|
| 1421 | - * |
|
| 1422 | - * Catch the redirect timer before it's sent to the JavaScript file |
|
| 1423 | - * |
|
| 1424 | - * @param int | $default_redirect_time_ms | The default time (1500 milliseconds) to wait before redirecting |
|
| 1425 | - */ |
|
| 1420 | + * yikes-mailchimp-redirect-timer |
|
| 1421 | + * |
|
| 1422 | + * Catch the redirect timer before it's sent to the JavaScript file |
|
| 1423 | + * |
|
| 1424 | + * @param int | $default_redirect_time_ms | The default time (1500 milliseconds) to wait before redirecting |
|
| 1425 | + */ |
|
| 1426 | 1426 | $redirect_timer = apply_filters( 'yikes-mailchimp-redirect-timer', $default_redirect_time_ms, $form_id, $page_data ); |
| 1427 | 1427 | |
| 1428 | 1428 | $redirect_array['redirect_timer'] = $redirect_timer; |