@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | 'recaptcha_data_callback' => '', // set a custom js callback function to run after a successful recaptcha response - default none |
22 | 22 | 'recaptcha_expired_callback' => '', // set a custom js callback function to run after the recaptcha has expired - default none |
23 | 23 | 'inline' => '0', |
24 | - ), $atts , 'yikes-mailchimp' ) |
|
24 | + ), $atts, 'yikes-mailchimp' ) |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | // set globals |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | $form_submitted = isset( $form_submitted ) ? $form_submitted : 0; |
32 | 32 | |
33 | 33 | /* If the user hasn't authenticated yet, lets kill off */ |
34 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) != 'valid_api_key' ) { |
|
35 | - return '<div class="invalid-api-key-error"><p>' . __( "Whoops, you're not connected to MailChimp. You need to enter a valid MailChimp API key." , 'yikes-inc-easy-mailchimp-extender' ) . '</p></div>'; |
|
34 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) != 'valid_api_key' ) { |
|
35 | + return '<div class="invalid-api-key-error"><p>' . __( "Whoops, you're not connected to MailChimp. You need to enter a valid MailChimp API key.", 'yikes-inc-easy-mailchimp-extender' ) . '</p></div>'; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // if the user forgot to specify a form ID, lets kill of and warn them. |
39 | - if( ! $form ) { |
|
39 | + if ( ! $form ) { |
|
40 | 40 | return __( 'Whoops, it looks like you forgot to specify a form to display.', 'yikes-inc-easy-mailchimp-extender' ); |
41 | 41 | } |
42 | 42 | |
@@ -45,39 +45,39 @@ discard block |
||
45 | 45 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms WHERE id = ' . $form . '', ARRAY_A ); |
46 | 46 | |
47 | 47 | // confirm we have some results, or return an error |
48 | - if( !$form_results ) { |
|
49 | - return __( "Oh no...This form doesn't exist. Head back to the manage forms page and select a different form." , 'yikes-inc-easy-mailchimp-extender' ); |
|
48 | + if ( ! $form_results ) { |
|
49 | + return __( "Oh no...This form doesn't exist. Head back to the manage forms page and select a different form.", 'yikes-inc-easy-mailchimp-extender' ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /* |
53 | 53 | * Check if the user wants to use reCAPTCHA Spam Prevention |
54 | 54 | */ |
55 | - if( get_option( 'yikes-mc-recaptcha-status' , '' ) == '1' ) { |
|
55 | + if ( get_option( 'yikes-mc-recaptcha-status', '' ) == '1' ) { |
|
56 | 56 | // allow users to manually set recaptcha (instead of globally - recaptcha="1"/recaptcha="0" - but still needs to be globally enabled on the settings page) |
57 | - if( ! isset( $atts['recaptcha'] ) || ( isset( $atts['recaptcha'] ) && $atts['recaptcha'] == '1' ) ) { |
|
57 | + if ( ! isset( $atts[ 'recaptcha' ] ) || ( isset( $atts[ 'recaptcha' ] ) && $atts[ 'recaptcha' ] == '1' ) ) { |
|
58 | 58 | // if either of the Private the Secret key is left blank, we should display an error back to the user |
59 | - if( get_option( 'yikes-mc-recaptcha-site-key' , '' ) == '' ) { |
|
60 | - return __( "Whoops! It looks like you enabled reCAPTCHA but forgot to enter the reCAPTCHA site key!" , 'yikes-inc-easy-mailchimp-extender' ) . '<span class="edit-link yikes-easy-mc-edit-link"><a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=recaptcha-settings' ) ) . '" title="' . __( 'ReCaptcha Settings' , 'yikes-inc-easy-mailchimp-extender' ) . '">' . __( 'Edit ReCaptcha Settings' , 'yikes-inc-easy-mailchimp-extender' ) . '</a></span>'; |
|
59 | + if ( get_option( 'yikes-mc-recaptcha-site-key', '' ) == '' ) { |
|
60 | + return __( "Whoops! It looks like you enabled reCAPTCHA but forgot to enter the reCAPTCHA site key!", 'yikes-inc-easy-mailchimp-extender' ) . '<span class="edit-link yikes-easy-mc-edit-link"><a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=recaptcha-settings' ) ) . '" title="' . __( 'ReCaptcha Settings', 'yikes-inc-easy-mailchimp-extender' ) . '">' . __( 'Edit ReCaptcha Settings', 'yikes-inc-easy-mailchimp-extender' ) . '</a></span>'; |
|
61 | 61 | } |
62 | - if( get_option( 'yikes-mc-recaptcha-secret-key' , '' ) == '' ) { |
|
63 | - return __( "Whoops! It looks like you enabled reCAPTCHA but forgot to enter the reCAPTCHA secret key!" , 'yikes-inc-easy-mailchimp-extender' ) . '<span class="edit-link yikes-easy-mc-edit-link"><a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=recaptcha-settings' ) ) . '" title="' . __( 'ReCaptcha Settings' , 'yikes-inc-easy-mailchimp-extender' ) . '">' . __( 'Edit ReCaptcha Settings' , 'yikes-inc-easy-mailchimp-extender' ) . '</a></span>'; |
|
62 | + if ( get_option( 'yikes-mc-recaptcha-secret-key', '' ) == '' ) { |
|
63 | + return __( "Whoops! It looks like you enabled reCAPTCHA but forgot to enter the reCAPTCHA secret key!", 'yikes-inc-easy-mailchimp-extender' ) . '<span class="edit-link yikes-easy-mc-edit-link"><a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=recaptcha-settings' ) ) . '" title="' . __( 'ReCaptcha Settings', 'yikes-inc-easy-mailchimp-extender' ) . '">' . __( 'Edit ReCaptcha Settings', 'yikes-inc-easy-mailchimp-extender' ) . '</a></span>'; |
|
64 | 64 | } |
65 | 65 | |
66 | - if( ! empty( $atts['recaptcha_type'] ) ) { |
|
67 | - echo $atts['recaptcha_type']; |
|
66 | + if ( ! empty( $atts[ 'recaptcha_type' ] ) ) { |
|
67 | + echo $atts[ 'recaptcha_type' ]; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Store the site language (to load recaptcha in a specific language) |
71 | 71 | $locale = get_locale(); |
72 | 72 | $locale_split = explode( '_', $locale ); |
73 | 73 | // Setup reCAPTCHA parameters |
74 | - $lang = ( isset( $locale_split ) ? $locale_split[0] : $locale ); |
|
75 | - $lang = ( isset( $atts['recaptcha_lang'] ) ) ? $atts['recaptcha_lang'] : $locale_split[0]; |
|
76 | - $type = ( isset( $atts['recaptcha_type'] ) ) ? strtolower( $atts['recaptcha_type'] ) : 'image'; // setup recaptcha type |
|
77 | - $theme= ( isset( $atts['recaptcha_theme'] ) ) ? strtolower( $atts['recaptcha_theme'] ) : 'light'; // setup recaptcha theme |
|
78 | - $size = ( isset( $atts['recaptcha_size'] ) ) ? strtolower( $atts['recaptcha_size'] ) : 'normal'; // setup recaptcha size |
|
79 | - $data_callback = ( isset( $atts['recaptcha_data_callback'] ) ) ? $atts['recaptcha_data_callback'] : false; // setup recaptcha size |
|
80 | - $expired_callback = ( isset( $atts['recaptcha_expired_callback'] ) ) ? $atts['recaptcha_expired_callback'] : false; // setup recaptcha size |
|
74 | + $lang = ( isset( $locale_split ) ? $locale_split[ 0 ] : $locale ); |
|
75 | + $lang = ( isset( $atts[ 'recaptcha_lang' ] ) ) ? $atts[ 'recaptcha_lang' ] : $locale_split[ 0 ]; |
|
76 | + $type = ( isset( $atts[ 'recaptcha_type' ] ) ) ? strtolower( $atts[ 'recaptcha_type' ] ) : 'image'; // setup recaptcha type |
|
77 | + $theme = ( isset( $atts[ 'recaptcha_theme' ] ) ) ? strtolower( $atts[ 'recaptcha_theme' ] ) : 'light'; // setup recaptcha theme |
|
78 | + $size = ( isset( $atts[ 'recaptcha_size' ] ) ) ? strtolower( $atts[ 'recaptcha_size' ] ) : 'normal'; // setup recaptcha size |
|
79 | + $data_callback = ( isset( $atts[ 'recaptcha_data_callback' ] ) ) ? $atts[ 'recaptcha_data_callback' ] : false; // setup recaptcha size |
|
80 | + $expired_callback = ( isset( $atts[ 'recaptcha_expired_callback' ] ) ) ? $atts[ 'recaptcha_expired_callback' ] : false; // setup recaptcha size |
|
81 | 81 | // Pass the shortcode parameters through a filter |
82 | 82 | $recaptcha_shortcode_params = apply_filters( 'yikes-mailchimp-recaptcha-parameters', array( |
83 | 83 | 'language' => $lang, |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | 'expired_callback' => $expired_callback, |
89 | 89 | ), $form ); |
90 | 90 | // enqueue Google recaptcha JS |
91 | - wp_register_script( 'google-recaptcha-js' , 'https://www.google.com/recaptcha/api.js?hl=' . $recaptcha_shortcode_params['language'] . '&onload=renderReCaptchaCallback&render=explicit', array( 'jquery' ) , 'all' ); |
|
91 | + wp_register_script( 'google-recaptcha-js', 'https://www.google.com/recaptcha/api.js?hl=' . $recaptcha_shortcode_params[ 'language' ] . '&onload=renderReCaptchaCallback&render=explicit', array( 'jquery' ), 'all' ); |
|
92 | 92 | wp_enqueue_script( 'google-recaptcha-js' ); |
93 | - $recaptcha_site_key = get_option( 'yikes-mc-recaptcha-site-key' , '' ); |
|
94 | - $recaptcha_box = '<div name="g-recaptcha" class="g-recaptcha" data-sitekey="' . $recaptcha_site_key . '" data-theme="' . $recaptcha_shortcode_params['theme'] . '" data-type="' . $recaptcha_shortcode_params['type'] . '" data-size="' . $recaptcha_shortcode_params['size'] . '" data-callback="' . $recaptcha_shortcode_params['success_callback'] . '" data-expired-callback="' . $recaptcha_shortcode_params['expired_callback'] . '"></div>'; |
|
93 | + $recaptcha_site_key = get_option( 'yikes-mc-recaptcha-site-key', '' ); |
|
94 | + $recaptcha_box = '<div name="g-recaptcha" class="g-recaptcha" data-sitekey="' . $recaptcha_site_key . '" data-theme="' . $recaptcha_shortcode_params[ 'theme' ] . '" data-type="' . $recaptcha_shortcode_params[ 'type' ] . '" data-size="' . $recaptcha_shortcode_params[ 'size' ] . '" data-callback="' . $recaptcha_shortcode_params[ 'success_callback' ] . '" data-expired-callback="' . $recaptcha_shortcode_params[ 'expired_callback' ] . '"></div>'; |
|
95 | 95 | ?> |
96 | 96 | <script type="text/javascript"> |
97 | 97 | /* Script Callback to init. multiple recaptchas on a single page */ |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | // place our results into a seperate variable for easy looping |
121 | - $form_data = $form_results[0]; |
|
121 | + $form_data = $form_results[ 0 ]; |
|
122 | 122 | |
123 | 123 | // store our variables |
124 | - $form_id = (int) $form_data['id']; // form id (the id of the form in the database) |
|
124 | + $form_id = (int) $form_data[ 'id' ]; // form id (the id of the form in the database) |
|
125 | 125 | |
126 | 126 | /* |
127 | 127 | * Get the stored form settings |
@@ -130,32 +130,32 @@ discard block |
||
130 | 130 | */ |
131 | 131 | $form_settings = Yikes_Inc_Easy_Mailchimp_Extender_Public::yikes_retrieve_form_settings( $form_id ); |
132 | 132 | |
133 | - $additional_form_settings = ( isset( $form_data['form_settings'] ) ) ? json_decode( $form_data['form_settings'], true ) : false; |
|
133 | + $additional_form_settings = ( isset( $form_data[ 'form_settings' ] ) ) ? json_decode( $form_data[ 'form_settings' ], true ) : false; |
|
134 | 134 | // store our options from the additional form settings array |
135 | - $form_classes = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-class-names'] : ''; |
|
136 | - $inline_form = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-inline-form'] : ''; |
|
137 | - $submit_button_type = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-submit-button-type'] : 'text'; |
|
138 | - $submit_button_text = ( $additional_form_settings && $additional_form_settings['yikes-easy-mc-submit-button-text'] != '' ) ? esc_attr( $additional_form_settings['yikes-easy-mc-submit-button-text'] ) : __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
|
139 | - $submit_button_image = ( $additional_form_settings ) ? esc_url( $additional_form_settings['yikes-easy-mc-submit-button-image'] ) : ''; |
|
140 | - $submit_button_classes = ( $additional_form_settings ) ? ' ' . esc_attr( $additional_form_settings['yikes-easy-mc-submit-button-classes'] ) : ''; |
|
135 | + $form_classes = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-class-names' ] : ''; |
|
136 | + $inline_form = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-inline-form' ] : ''; |
|
137 | + $submit_button_type = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-submit-button-type' ] : 'text'; |
|
138 | + $submit_button_text = ( $additional_form_settings && $additional_form_settings[ 'yikes-easy-mc-submit-button-text' ] != '' ) ? esc_attr( $additional_form_settings[ 'yikes-easy-mc-submit-button-text' ] ) : __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
|
139 | + $submit_button_image = ( $additional_form_settings ) ? esc_url( $additional_form_settings[ 'yikes-easy-mc-submit-button-image' ] ) : ''; |
|
140 | + $submit_button_classes = ( $additional_form_settings ) ? ' ' . esc_attr( $additional_form_settings[ 'yikes-easy-mc-submit-button-classes' ] ) : ''; |
|
141 | 141 | // scheuldes |
142 | - $form_schedule_state = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-schedule'] : false; |
|
143 | - $form_schedule_start = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-start'] : '';; |
|
144 | - $form_schedule_end = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-end'] : ''; |
|
145 | - $form_pending_message = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-pending-message'] : ''; |
|
146 | - $form_expired_message = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-expired-message'] : ''; |
|
142 | + $form_schedule_state = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-schedule' ] : false; |
|
143 | + $form_schedule_start = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-start' ] : ''; ; |
|
144 | + $form_schedule_end = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-end' ] : ''; |
|
145 | + $form_pending_message = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-pending-message' ] : ''; |
|
146 | + $form_expired_message = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-expired-message' ] : ''; |
|
147 | 147 | // register required |
148 | - $form_login_required = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-login-required'] : false; |
|
149 | - $form_login_message = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-login-message'] : ''; |
|
148 | + $form_login_required = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-login-required' ] : false; |
|
149 | + $form_login_message = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-login-message' ] : ''; |
|
150 | 150 | // store number of fields |
151 | - $field_count = (int) count( $form_settings['fields'] ); |
|
151 | + $field_count = (int) count( $form_settings[ 'fields' ] ); |
|
152 | 152 | |
153 | 153 | // confirm we actually have fields, before looping |
154 | - if( isset( $form_data['fields'] ) && ! empty( $form_data['fields'] ) ) { |
|
154 | + if ( isset( $form_data[ 'fields' ] ) && ! empty( $form_data[ 'fields' ] ) ) { |
|
155 | 155 | // loop over each field, if it's set to hidden -- subtract it from the field count |
156 | 156 | // this throws off the layout for inline forms setup below |
157 | - foreach( json_decode( $form_data['fields'] ) as $form_field ) { |
|
158 | - if( isset( $form_field->hide ) && $form_field->hide == 1 ) { |
|
157 | + foreach ( json_decode( $form_data[ 'fields' ] ) as $form_field ) { |
|
158 | + if ( isset( $form_field->hide ) && $form_field->hide == 1 ) { |
|
159 | 159 | $field_count--; |
160 | 160 | } |
161 | 161 | } |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * If login is required, abort |
166 | 166 | * @since 6.0.3.8 |
167 | 167 | */ |
168 | - if( $form_login_required ) { |
|
169 | - if( apply_filters( 'yikes-mailchimp-required-login-requirement', ! is_user_logged_in() ) ) { |
|
168 | + if ( $form_login_required ) { |
|
169 | + if ( apply_filters( 'yikes-mailchimp-required-login-requirement', ! is_user_logged_in() ) ) { |
|
170 | 170 | ob_start(); |
171 | 171 | ?> |
172 | 172 | <div class="yikes-mailchimp-login-required yikes-mailchimp-form-<?php echo $form_id; ?>-login-required"> |
@@ -182,19 +182,19 @@ discard block |
||
182 | 182 | * Check if schedule is set for this form |
183 | 183 | * @since 6.0.3.8 |
184 | 184 | */ |
185 | - if( $form_schedule_state ) { |
|
185 | + if ( $form_schedule_state ) { |
|
186 | 186 | // store current date |
187 | 187 | $current_date = strtotime( current_time( 'm/d/Y g:iA' ) ); |
188 | 188 | |
189 | 189 | // the the current date is less than the form scheduled start date |
190 | - if( $current_date < $form_schedule_start ) { |
|
190 | + if ( $current_date < $form_schedule_start ) { |
|
191 | 191 | echo apply_filters( 'yikes-mailchimp-frontend-content', $form_pending_message ); |
192 | 192 | return; |
193 | 193 | // abort |
194 | 194 | } |
195 | 195 | |
196 | 196 | // The current date is past or equal to the end date, aka form has now expired |
197 | - if( $current_date >= $form_schedule_end ) { |
|
197 | + if ( $current_date >= $form_schedule_end ) { |
|
198 | 198 | echo apply_filters( 'yikes-mailchimp-frontend-content', $form_expired_message ); |
199 | 199 | return; |
200 | 200 | // abort |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | |
204 | 204 | // setup the submit button text |
205 | 205 | // shortcode parameter takes precedence over option |
206 | - if( isset( $atts['submit'] ) ) { |
|
207 | - $submit = $atts['submit']; |
|
206 | + if ( isset( $atts[ 'submit' ] ) ) { |
|
207 | + $submit = $atts[ 'submit' ]; |
|
208 | 208 | } else { |
209 | 209 | $submit = $submit_button_text; |
210 | 210 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $page_data = $post; |
215 | 215 | |
216 | 216 | // Remove the post_password from this for security |
217 | - if( isset( $page_data->post_password ) ) { |
|
217 | + if ( isset( $page_data->post_password ) ) { |
|
218 | 218 | unset( $page_data->post_password ); |
219 | 219 | } |
220 | 220 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * to exclude styles from loading, add `define( 'YIKES_MAILCHIMP_EXCLUDE_STYLES', true );` to functions.php |
229 | 229 | * @since 6.0.3.8 |
230 | 230 | */ |
231 | - if( ! defined( 'YIKES_MAILCHIMP_EXCLUDE_STYLES' ) ) { |
|
231 | + if ( ! defined( 'YIKES_MAILCHIMP_EXCLUDE_STYLES' ) ) { |
|
232 | 232 | // enqueue the form styles |
233 | 233 | wp_enqueue_style( 'yikes-inc-easy-mailchimp-public-styles', YIKES_MC_URL . 'public/css/yikes-inc-easy-mailchimp-extender-public.min.css', array( $last_key ) ); |
234 | 234 | } |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | /** |
237 | 237 | * Check for form inline parameter |
238 | 238 | */ |
239 | - $form_inline = ( isset( $atts['inline'] ) && ( $atts['inline'] == 1 || $atts['inline'] == 'true' ) ) ? true : false; |
|
239 | + $form_inline = ( isset( $atts[ 'inline' ] ) && ( $atts[ 'inline' ] == 1 || $atts[ 'inline' ] == 'true' ) ) ? true : false; |
|
240 | 240 | // recheck from our form options |
241 | - if( ! $form_inline ) { |
|
242 | - $form_inline = ( isset( $additional_form_settings['yikes-easy-mc-inline-form'] ) && $additional_form_settings['yikes-easy-mc-inline-form'] == 1 ) ? true : false; |
|
241 | + if ( ! $form_inline ) { |
|
242 | + $form_inline = ( isset( $additional_form_settings[ 'yikes-easy-mc-inline-form' ] ) && $additional_form_settings[ 'yikes-easy-mc-inline-form' ] == 1 ) ? true : false; |
|
243 | 243 | } |
244 | - if( $form_inline ) { |
|
244 | + if ( $form_inline ) { |
|
245 | 245 | $field_width = (float) ( 100 / $field_count ); |
246 | 246 | $submit_button_width = (float) ( 20 / $field_count ); |
247 | 247 | /* |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | <?php |
271 | 271 | |
272 | 272 | /* If the current user is logged in, and an admin...lets display our 'Edit Form' link */ |
273 | - if( is_user_logged_in() ) { |
|
274 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
273 | + if ( is_user_logged_in() ) { |
|
274 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
275 | 275 | $edit_form_link = '<span class="edit-link">'; |
276 | - $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $form ) ) . '" title="' . __( 'Edit' , 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $form_settings['form_name'] ) . '">' . __( 'Edit Form' , 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
276 | + $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $form ) ) . '" title="' . __( 'Edit', 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $form_settings[ 'form_name' ] ) . '">' . __( 'Edit Form', 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
277 | 277 | $edit_form_link .= '</span>'; |
278 | - $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $form, ucwords( $form_settings['form_name'] ) ); |
|
278 | + $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $form, ucwords( $form_settings[ 'form_name' ] ) ); |
|
279 | 279 | } else { |
280 | 280 | $edit_form_link = ''; |
281 | 281 | } |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | // ensure there is an 'email' field the user can fill out |
285 | 285 | // or else MailChimp throws errors at you |
286 | 286 | // extract our array keys |
287 | - if( isset( $form_settings['fields'] ) && ! empty( $form_settings['fields'] ) ) { |
|
288 | - $array_keys = array_keys( $form_settings['fields'] ); |
|
287 | + if ( isset( $form_settings[ 'fields' ] ) && ! empty( $form_settings[ 'fields' ] ) ) { |
|
288 | + $array_keys = array_keys( $form_settings[ 'fields' ] ); |
|
289 | 289 | // check for EMAIL in that array |
290 | - if( !in_array( 'EMAIL', $array_keys ) && !in_array( 'email', $array_keys ) ) { |
|
291 | - return '<p>' . __( "An email field is required for all MailChimp forms. Please add an email field to this form." , 'yikes-inc-easy-mailchimp-extender' ) . '</p><p>' . $edit_form_link . '</p>'; |
|
290 | + if ( ! in_array( 'EMAIL', $array_keys ) && ! in_array( 'email', $array_keys ) ) { |
|
291 | + return '<p>' . __( "An email field is required for all MailChimp forms. Please add an email field to this form.", 'yikes-inc-easy-mailchimp-extender' ) . '</p><p>' . $edit_form_link . '</p>'; |
|
292 | 292 | } |
293 | 293 | } else { |
294 | - $error = '<p>' . __( "Whoops, it looks like you forgot to assign fields to this form." , 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
295 | - if( is_user_logged_in() ) { |
|
296 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
294 | + $error = '<p>' . __( "Whoops, it looks like you forgot to assign fields to this form.", 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
295 | + if ( is_user_logged_in() ) { |
|
296 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
297 | 297 | return $error . $edit_form_link; |
298 | 298 | } |
299 | 299 | } else { |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | * Set a custom title using custom_title="lorem ipsum" parameter in the shortcode |
312 | 312 | * - This takes precedence over the title set |
313 | 313 | */ |
314 | - if( ! empty( $title ) && $title == 1 && isset( $atts['custom_title'] ) ) { |
|
315 | - echo '<h3 class="yikes-mailchimp-form-title yikes-mailchimp-form-title-'.$form_id.'">' . apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $atts['custom_title'] ), $form_id ) . '</h3>'; |
|
314 | + if ( ! empty( $title ) && $title == 1 && isset( $atts[ 'custom_title' ] ) ) { |
|
315 | + echo '<h3 class="yikes-mailchimp-form-title yikes-mailchimp-form-title-' . $form_id . '">' . apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $atts[ 'custom_title' ] ), $form_id ) . '</h3>'; |
|
316 | 316 | } else { |
317 | 317 | // display the form description if the user |
318 | 318 | // has specified to do so |
319 | - if( ! empty( $title ) && $title == 1 ) { |
|
320 | - echo '<h3 class="yikes-mailchimp-form-title yikes-mailchimp-form-title-'.$form_id.'">' . apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_settings['form_name'] ), $form_id ) . '</h3>'; |
|
319 | + if ( ! empty( $title ) && $title == 1 ) { |
|
320 | + echo '<h3 class="yikes-mailchimp-form-title yikes-mailchimp-form-title-' . $form_id . '">' . apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_settings[ 'form_name' ] ), $form_id ) . '</h3>'; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -325,21 +325,21 @@ discard block |
||
325 | 325 | * Allow users to specify a custom description for this form, no html support |
326 | 326 | * @since 6.0.3.8 |
327 | 327 | */ |
328 | - if( ! empty( $description ) && $description == 1 && isset( $atts['custom_description'] ) ) { |
|
329 | - echo '<section class="yikes-mailchimp-form-description yikes-mailchimp-form-description-'.$form_id.'">' . apply_filters( 'yikes-mailchimp-frontend-content', apply_filters( 'yikes-mailchimp-form-description', $atts['custom_description'], $form_id ) ) . '</section>'; |
|
328 | + if ( ! empty( $description ) && $description == 1 && isset( $atts[ 'custom_description' ] ) ) { |
|
329 | + echo '<section class="yikes-mailchimp-form-description yikes-mailchimp-form-description-' . $form_id . '">' . apply_filters( 'yikes-mailchimp-frontend-content', apply_filters( 'yikes-mailchimp-form-description', $atts[ 'custom_description' ], $form_id ) ) . '</section>'; |
|
330 | 330 | } else { |
331 | 331 | // display the form description if the user |
332 | 332 | // has specified to do so |
333 | - if( ! empty( $description ) && $description == 1 ) { |
|
334 | - echo '<section class="yikes-mailchimp-form-description yikes-mailchimp-form-description-'.$form_id.'">' . apply_filters( 'yikes-mailchimp-frontend-content', apply_filters( 'yikes-mailchimp-form-description', $form_settings['form_description'], $form_id ) ) . '</section>'; |
|
333 | + if ( ! empty( $description ) && $description == 1 ) { |
|
334 | + echo '<section class="yikes-mailchimp-form-description yikes-mailchimp-form-description-' . $form_id . '">' . apply_filters( 'yikes-mailchimp-frontend-content', apply_filters( 'yikes-mailchimp-form-description', $form_settings[ 'form_description' ], $form_id ) ) . '</section>'; |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Check for AJAX |
339 | - if( ( ! empty( $atts['ajax'] ) && $atts['ajax'] == 1 ) || $form_settings['submission_settings']['ajax'] == 1 ) { |
|
339 | + if ( ( ! empty( $atts[ 'ajax' ] ) && $atts[ 'ajax' ] == 1 ) || $form_settings[ 'submission_settings' ][ 'ajax' ] == 1 ) { |
|
340 | 340 | // enqueue our ajax script |
341 | - wp_register_script( 'yikes-easy-mc-ajax' , YIKES_MC_URL . 'public/js/yikes-mc-ajax-forms.min.js' , array( 'jquery' ) , 'yikes-inc-easy-mailchimp-extender', false ); |
|
342 | - wp_localize_script( 'yikes-easy-mc-ajax' , 'object' , array( |
|
341 | + wp_register_script( 'yikes-easy-mc-ajax', YIKES_MC_URL . 'public/js/yikes-mc-ajax-forms.min.js', array( 'jquery' ), 'yikes-inc-easy-mailchimp-extender', false ); |
|
342 | + wp_localize_script( 'yikes-easy-mc-ajax', 'object', array( |
|
343 | 343 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
344 | 344 | 'page_data' => $page_data, |
345 | 345 | 'interest_group_checkbox_error' => apply_filters( 'yikes-mailchimp-interest-group-checkbox-error', __( 'This field is required.', 'yikes-inc-easy-mailchimp-extender' ), $form_id ), |
@@ -358,63 +358,63 @@ discard block |
||
358 | 358 | |
359 | 359 | // render the form! |
360 | 360 | ?> |
361 | - <form id="<?php echo sanitize_title( $form_settings['form_name'] ); ?>-<?php echo $form_id; ?>" class="yikes-easy-mc-form yikes-easy-mc-form-<?php echo $form_id . ' '; if ( $form_inline ) { echo 'yikes-mailchimp-form-inline '; } echo ' ' . apply_filters( 'yikes-mailchimp-form-class', $form_classes, $form_id ); if( !empty( $_POST ) && $form_submitted == 1 && $form_settings['submission_settings']['hide_form_post_signup'] == 1 ) { echo ' yikes-easy-mc-display-none'; } ?>" action="" method="POST" data-attr-form-id="<?php echo $form_id; ?>"> |
|
361 | + <form id="<?php echo sanitize_title( $form_settings[ 'form_name' ] ); ?>-<?php echo $form_id; ?>" class="yikes-easy-mc-form yikes-easy-mc-form-<?php echo $form_id . ' '; if ( $form_inline ) { echo 'yikes-mailchimp-form-inline '; } echo ' ' . apply_filters( 'yikes-mailchimp-form-class', $form_classes, $form_id ); if ( ! empty( $_POST ) && $form_submitted == 1 && $form_settings[ 'submission_settings' ][ 'hide_form_post_signup' ] == 1 ) { echo ' yikes-easy-mc-display-none'; } ?>" action="" method="POST" data-attr-form-id="<?php echo $form_id; ?>"> |
|
362 | 362 | |
363 | 363 | <?php |
364 | - foreach( $form_settings['fields'] as $field ) { |
|
364 | + foreach ( $form_settings[ 'fields' ] as $field ) { |
|
365 | 365 | // input array |
366 | 366 | $field_array = array(); |
367 | 367 | // label array |
368 | 368 | $label_array = array(); |
369 | 369 | // label classes array |
370 | 370 | $label_class_array = array(); |
371 | - if( $field['additional-classes'] != '' ) { |
|
371 | + if ( $field[ 'additional-classes' ] != '' ) { |
|
372 | 372 | // split custom classes at spaces |
373 | - $custom_classes = explode( ' ' , $field['additional-classes'] ); |
|
373 | + $custom_classes = explode( ' ', $field[ 'additional-classes' ] ); |
|
374 | 374 | // check our custom class array for field-left/field-right |
375 | 375 | // if it's set we need to assign it to our label and remove it from the field classes |
376 | 376 | // input half left |
377 | - if( in_array( 'field-left-half' , $custom_classes ) ) { |
|
377 | + if ( in_array( 'field-left-half', $custom_classes ) ) { |
|
378 | 378 | // $label_array['class'] = 'class="field-left-half"'; |
379 | - $label_class_array[] = 'field-left-half'; |
|
380 | - $key = array_search( 'field-left-half' , $custom_classes ); |
|
381 | - unset( $custom_classes[$key] ); |
|
379 | + $label_class_array[ ] = 'field-left-half'; |
|
380 | + $key = array_search( 'field-left-half', $custom_classes ); |
|
381 | + unset( $custom_classes[ $key ] ); |
|
382 | 382 | } // input half right |
383 | - if( in_array( 'field-right-half' , $custom_classes ) ) { |
|
383 | + if ( in_array( 'field-right-half', $custom_classes ) ) { |
|
384 | 384 | // $label_array['class'] = 'class="field-right-half"'; |
385 | - $label_class_array[] = 'field-right-half'; |
|
386 | - $key = array_search( 'field-right-half' , $custom_classes ); |
|
387 | - unset( $custom_classes[$key] ); |
|
385 | + $label_class_array[ ] = 'field-right-half'; |
|
386 | + $key = array_search( 'field-right-half', $custom_classes ); |
|
387 | + unset( $custom_classes[ $key ] ); |
|
388 | 388 | } // input thirds (1/3 width, floated left) |
389 | - if( in_array( 'field-third' , $custom_classes ) ) { |
|
389 | + if ( in_array( 'field-third', $custom_classes ) ) { |
|
390 | 390 | // $label_array['class'] = 'class="field-third"'; |
391 | - $label_class_array[] = 'field-third'; |
|
392 | - $key = array_search( 'field-third' , $custom_classes ); |
|
393 | - unset( $custom_classes[$key] ); |
|
391 | + $label_class_array[ ] = 'field-third'; |
|
392 | + $key = array_search( 'field-third', $custom_classes ); |
|
393 | + unset( $custom_classes[ $key ] ); |
|
394 | 394 | } // 2 column radio |
395 | - if( in_array( 'option-2-col' , $custom_classes ) ) { |
|
395 | + if ( in_array( 'option-2-col', $custom_classes ) ) { |
|
396 | 396 | // $label_array['class'] = 'class="option-2-col"'; |
397 | - $label_class_array[] = 'option-2-col'; |
|
398 | - $key = array_search( 'option-2-col' , $custom_classes ); |
|
399 | - unset( $custom_classes[$key] ); |
|
397 | + $label_class_array[ ] = 'option-2-col'; |
|
398 | + $key = array_search( 'option-2-col', $custom_classes ); |
|
399 | + unset( $custom_classes[ $key ] ); |
|
400 | 400 | } // 3 column radio |
401 | - if( in_array( 'option-3-col' , $custom_classes ) ) { |
|
401 | + if ( in_array( 'option-3-col', $custom_classes ) ) { |
|
402 | 402 | // $label_array['class'] = 'class="option-3-col"'; |
403 | - $label_class_array[] = 'option-3-col'; |
|
404 | - $key = array_search( 'option-3-col' , $custom_classes ); |
|
405 | - unset( $custom_classes[$key] ); |
|
403 | + $label_class_array[ ] = 'option-3-col'; |
|
404 | + $key = array_search( 'option-3-col', $custom_classes ); |
|
405 | + unset( $custom_classes[ $key ] ); |
|
406 | 406 | } // 4 column radio |
407 | - if( in_array( 'option-4-col' , $custom_classes ) ) { |
|
407 | + if ( in_array( 'option-4-col', $custom_classes ) ) { |
|
408 | 408 | // $label_array['class'] = 'class="option-4-col"'; |
409 | - $label_class_array[] = 'option-4-col'; |
|
410 | - $key = array_search( 'option-4-col' , $custom_classes ); |
|
411 | - unset( $custom_classes[$key] ); |
|
409 | + $label_class_array[ ] = 'option-4-col'; |
|
410 | + $key = array_search( 'option-4-col', $custom_classes ); |
|
411 | + unset( $custom_classes[ $key ] ); |
|
412 | 412 | } // inline radio & checkboxes etc |
413 | - if( in_array( 'option-inline' , $custom_classes ) ) { |
|
413 | + if ( in_array( 'option-inline', $custom_classes ) ) { |
|
414 | 414 | // $label_array['class'] = 'class="option-inline"'; |
415 | - $label_class_array[] = 'option-inline'; |
|
416 | - $key = array_search( 'option-inline' , $custom_classes ); |
|
417 | - unset( $custom_classes[$key] ); |
|
415 | + $label_class_array[ ] = 'option-inline'; |
|
416 | + $key = array_search( 'option-inline', $custom_classes ); |
|
417 | + unset( $custom_classes[ $key ] ); |
|
418 | 418 | } |
419 | 419 | } else { |
420 | 420 | $custom_classes = array(); |
@@ -422,67 +422,67 @@ discard block |
||
422 | 422 | |
423 | 423 | // if the form is set to inline, add the inline class to our labels |
424 | 424 | // since @6.0.3.8 |
425 | - if( $form_inline ) { |
|
426 | - $label_class_array[] = 'label-inline'; |
|
425 | + if ( $form_inline ) { |
|
426 | + $label_class_array[ ] = 'label-inline'; |
|
427 | 427 | } |
428 | 428 | |
429 | - if( isset( $field['hide-label'] ) ) { |
|
430 | - if( $field['hide-label'] == 1 ) { |
|
431 | - $custom_classes[] = 'field-no-label'; |
|
429 | + if ( isset( $field[ 'hide-label' ] ) ) { |
|
430 | + if ( $field[ 'hide-label' ] == 1 ) { |
|
431 | + $custom_classes[ ] = 'field-no-label'; |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | /* Store tag variable based on field type */ |
436 | - if( isset( $field['merge'] ) ) { |
|
436 | + if ( isset( $field[ 'merge' ] ) ) { |
|
437 | 437 | $tag = 'merge'; |
438 | 438 | } else { |
439 | 439 | $tag = 'group_id'; |
440 | 440 | } |
441 | 441 | |
442 | 442 | // build up our array |
443 | - $field_array['id'] = 'id="yikes-easy-mc-form-' . $form_id . '-' . esc_attr( $field[$tag] ) . '" '; |
|
444 | - $field_array['name'] = 'name="' . esc_attr( $field[$tag] ) . '" '; |
|
445 | - $field_array['placeholder'] = isset( $field['placeholder'] ) ? 'placeholder="' . esc_attr( stripslashes( $field['placeholder'] ) ) . '" ' : ''; |
|
446 | - $field_array['classes'] = 'class="yikes-easy-mc-'.$field['type'] . ' ' . esc_attr( trim( implode( ' ' , $custom_classes ) ) ) . '" '; |
|
443 | + $field_array[ 'id' ] = 'id="yikes-easy-mc-form-' . $form_id . '-' . esc_attr( $field[ $tag ] ) . '" '; |
|
444 | + $field_array[ 'name' ] = 'name="' . esc_attr( $field[ $tag ] ) . '" '; |
|
445 | + $field_array[ 'placeholder' ] = isset( $field[ 'placeholder' ] ) ? 'placeholder="' . esc_attr( stripslashes( $field[ 'placeholder' ] ) ) . '" ' : ''; |
|
446 | + $field_array[ 'classes' ] = 'class="yikes-easy-mc-' . $field[ 'type' ] . ' ' . esc_attr( trim( implode( ' ', $custom_classes ) ) ) . '" '; |
|
447 | 447 | |
448 | 448 | // email must always be required and visible |
449 | - if( $field['type'] == 'email' ) { |
|
450 | - $field_array['required'] = 'required="required"'; |
|
451 | - $label_array['visible'] = ''; |
|
449 | + if ( $field[ 'type' ] == 'email' ) { |
|
450 | + $field_array[ 'required' ] = 'required="required"'; |
|
451 | + $label_array[ 'visible' ] = ''; |
|
452 | 452 | // $label_array['required'] = 'class="' . $field['merge'] . '-label yikes-mailchimp-field-required"'; |
453 | - $label_class_array[] = $field['merge'] . '-label'; |
|
454 | - $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
453 | + $label_class_array[ ] = $field[ 'merge' ] . '-label'; |
|
454 | + $label_class_array[ ] = 'yikes-mailchimp-field-required'; |
|
455 | 455 | } else { |
456 | - if( $tag == 'merge' ) { |
|
457 | - $field_array['required'] = isset( $field['require'] ) ? 'required="required"' : ''; |
|
458 | - $label_array['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
456 | + if ( $tag == 'merge' ) { |
|
457 | + $field_array[ 'required' ] = isset( $field[ 'require' ] ) ? 'required="required"' : ''; |
|
458 | + $label_array[ 'visible' ] = isset( $field[ 'hide' ] ) ? 'style="display:none;"' : ''; |
|
459 | 459 | // $label_array['required'] = isset( $field['require'] ) ? 'class="' . $field['merge'] . '-label yikes-mailchimp-field-required"' : 'class="' . $field['merge'] . '-label"'; |
460 | - $label_class_array[] = isset( $field['require'] ) ? $field['merge'] . '-label yikes-mailchimp-field-required' : $field['merge'] . '-label'; |
|
460 | + $label_class_array[ ] = isset( $field[ 'require' ] ) ? $field[ 'merge' ] . '-label yikes-mailchimp-field-required' : $field[ 'merge' ] . '-label'; |
|
461 | 461 | } else { |
462 | - $field_array['required'] = isset( $field['require'] ) ? 'required="required"' : ''; |
|
463 | - $label_array['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
462 | + $field_array[ 'required' ] = isset( $field[ 'require' ] ) ? 'required="required"' : ''; |
|
463 | + $label_array[ 'visible' ] = isset( $field[ 'hide' ] ) ? 'style="display:none;"' : ''; |
|
464 | 464 | // $label_array['required'] = isset( $field['require'] ) ? 'class="' . $field['group_id'] . '-label yikes-mailchimp-field-required"' : 'class="' . $field['group_id'] . '-label"'; |
465 | - $label_class_array[] = isset( $field['require'] ) ? $field['group_id'] . '-label yikes-mailchimp-field-required' : $field['group_id'] . '-label'; |
|
465 | + $label_class_array[ ] = isset( $field[ 'require' ] ) ? $field[ 'group_id' ] . '-label yikes-mailchimp-field-required' : $field[ 'group_id' ] . '-label'; |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
469 | 469 | // if both hide label and hide field are checked, we gotta hide the field! |
470 | - if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
471 | - if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
472 | - $field_array['visible'] = 'style="display:none;"'; |
|
470 | + if ( isset( $field[ 'hide' ] ) && $field[ 'hide' ] == 1 ) { |
|
471 | + if ( isset( $field[ 'hide-label' ] ) && $field[ 'hide-label' ] == 1 ) { |
|
472 | + $field_array[ 'visible' ] = 'style="display:none;"'; |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | - $label_array['classes'] = 'class="' . implode( ' ', $label_class_array ) . '"'; |
|
476 | + $label_array[ 'classes' ] = 'class="' . implode( ' ', $label_class_array ) . '"'; |
|
477 | 477 | |
478 | 478 | // filter the field array data |
479 | 479 | $field_array = apply_filters( 'yikes-mailchimp-field-data', $field_array, $field, $form_id ); |
480 | 480 | |
481 | 481 | /* Loop Over Standard Fields (aka merge variables) */ |
482 | - if( isset( $field['merge'] ) ) { |
|
482 | + if ( isset( $field[ 'merge' ] ) ) { |
|
483 | 483 | |
484 | 484 | // loop over our fields by Type |
485 | - switch ( $field['type'] ) { |
|
485 | + switch ( $field[ 'type' ] ) { |
|
486 | 486 | |
487 | 487 | default: |
488 | 488 | case 'email': |
@@ -490,25 +490,25 @@ discard block |
||
490 | 490 | case 'number': |
491 | 491 | |
492 | 492 | // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
493 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
493 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
494 | 494 | $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
495 | 495 | ?> |
496 | - <label for="<?php echo $field['merge']; ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
496 | + <label for="<?php echo $field[ 'merge' ]; ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
497 | 497 | |
498 | 498 | <!-- dictate label visibility --> |
499 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
500 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
501 | - <?php if( ! isset( $field['hide-label'] ) ) { echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ), $form_id ); } ?> |
|
499 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
500 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
501 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ), $form_id ); } ?> |
|
502 | 502 | </span> |
503 | 503 | <?php } ?> |
504 | 504 | |
505 | - <input <?php echo implode( ' ' , $field_array ); if( $field['type'] != 'email' && $field['type'] != 'number' ) { ?> type="text" <?php } else if( $field['type'] == 'email' ) { ?> type="email" <?php } else { ?> type="number" <?php } ?> value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo $_POST[$field['merge']]; } else { echo esc_attr( $default_value ); } ?>"> |
|
505 | + <input <?php echo implode( ' ', $field_array ); if ( $field[ 'type' ] != 'email' && $field[ 'type' ] != 'number' ) { ?> type="text" <?php } else if ( $field[ 'type' ] == 'email' ) { ?> type="email" <?php } else { ?> type="number" <?php } ?> value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo $_POST[ $field[ 'merge' ] ]; } else { echo esc_attr( $default_value ); } ?>"> |
|
506 | 506 | |
507 | 507 | <!-- description --> |
508 | - <?php if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
508 | + <?php if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
509 | 509 | <p class="form-field-description"> |
510 | 510 | <small> |
511 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $form_id ); ?> |
|
511 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); ?> |
|
512 | 512 | </small> |
513 | 513 | </p> |
514 | 514 | <?php } ?> |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | |
521 | 521 | case 'url': |
522 | 522 | case 'imageurl': |
523 | - $default_value = ( isset( $field['default'] ) ) ? $field['default'] : ''; |
|
523 | + $default_value = ( isset( $field[ 'default' ] ) ) ? $field[ 'default' ] : ''; |
|
524 | 524 | ?> |
525 | 525 | |
526 | 526 | <script type="text/javascript"> |
@@ -532,22 +532,22 @@ discard block |
||
532 | 532 | } |
533 | 533 | </script> |
534 | 534 | |
535 | - <label for="<?php echo $field['merge']; ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
535 | + <label for="<?php echo $field[ 'merge' ]; ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
536 | 536 | |
537 | 537 | <!-- dictate label visibility --> |
538 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
539 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
540 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
538 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
539 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
540 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
541 | 541 | </span> |
542 | 542 | <?php } ?> |
543 | 543 | |
544 | - <input <?php echo implode( ' ' , $field_array ); ?> type="url" <?php if( $field['type'] == 'url' ) { ?> title="<?php _e( 'Please enter a valid URL to the website.' , 'yikes-inc-easy-mailchimp-extender' ); ?>" <?php } else { ?> title="<?php _e( 'Please enter a valid URL to the image.' , 'yikes-inc-easy-mailchimp-extender' ); ?>" <?php } ?> value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo $_POST[$field['merge']]; } else { echo esc_attr( $default_value ); } ?>" onblur="properlyFormatURLField(this);return false;"> |
|
544 | + <input <?php echo implode( ' ', $field_array ); ?> type="url" <?php if ( $field[ 'type' ] == 'url' ) { ?> title="<?php _e( 'Please enter a valid URL to the website.', 'yikes-inc-easy-mailchimp-extender' ); ?>" <?php } else { ?> title="<?php _e( 'Please enter a valid URL to the image.', 'yikes-inc-easy-mailchimp-extender' ); ?>" <?php } ?> value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo $_POST[ $field[ 'merge' ] ]; } else { echo esc_attr( $default_value ); } ?>" onblur="properlyFormatURLField(this);return false;"> |
|
545 | 545 | |
546 | 546 | <!-- description --> |
547 | - <?php if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
547 | + <?php if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
548 | 548 | <p class="form-field-description"> |
549 | 549 | <small> |
550 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $form_id ); ?> |
|
550 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); ?> |
|
551 | 551 | </small> |
552 | 552 | </p> |
553 | 553 | <?php } ?> |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | break; |
559 | 559 | |
560 | 560 | case 'phone': |
561 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
562 | - $phone_format = $field['phone_format']; |
|
561 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
562 | + $phone_format = $field[ 'phone_format' ]; |
|
563 | 563 | ?> |
564 | 564 | <script type="text/javascript"> |
565 | 565 | /* Replace incorrect values and format it correctly for MailChimp API */ |
@@ -572,22 +572,22 @@ discard block |
||
572 | 572 | } |
573 | 573 | </script> |
574 | 574 | |
575 | - <label for="<?php echo $field['merge']; ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
575 | + <label for="<?php echo $field[ 'merge' ]; ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
576 | 576 | |
577 | 577 | <!-- dictate label visibility --> |
578 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
579 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
580 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
578 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
579 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
580 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
581 | 581 | </span> |
582 | 582 | <?php } ?> |
583 | 583 | |
584 | - <input <?php echo implode( ' ' , $field_array ); ?> type="text" <?php if( $phone_format != 'US' ) { ?> title="<?php _e( 'International Phone Number' , 'yikes-inc-easy-mailchimp-extender' ); ?>" pattern="<?php echo apply_filters( 'yikes-mailchimp-international-phone-pattern' , '[0-9,-]{1,}' ); ?>" <?php } else { ?> title="<?php _e( 'US Phone Number (###) ### - ####' , 'yikes-inc-easy-mailchimp-extender' ); ?>" pattern="<?php echo apply_filters( 'yikes-mailchimp-us-phone-pattern' , '^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$' ); ?>" onblur="formatUSPhoneNumber(this);"<?php } ?> value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo $_POST[$field['merge']]; } else { echo esc_attr( $default_value ); } ?>"> |
|
584 | + <input <?php echo implode( ' ', $field_array ); ?> type="text" <?php if ( $phone_format != 'US' ) { ?> title="<?php _e( 'International Phone Number', 'yikes-inc-easy-mailchimp-extender' ); ?>" pattern="<?php echo apply_filters( 'yikes-mailchimp-international-phone-pattern', '[0-9,-]{1,}' ); ?>" <?php } else { ?> title="<?php _e( 'US Phone Number (###) ### - ####', 'yikes-inc-easy-mailchimp-extender' ); ?>" pattern="<?php echo apply_filters( 'yikes-mailchimp-us-phone-pattern', '^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$' ); ?>" onblur="formatUSPhoneNumber(this);"<?php } ?> value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo $_POST[ $field[ 'merge' ] ]; } else { echo esc_attr( $default_value ); } ?>"> |
|
585 | 585 | |
586 | 586 | <!-- description --> |
587 | - <?php if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
587 | + <?php if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
588 | 588 | <p class="form-field-description"> |
589 | 589 | <small> |
590 | - <?php echo apply_filters( 'yikes-mailchimp-' . esc_attr( $field['merge'] ) . '-description', stripslashes( $field['description'] ), $form_id ); ?> |
|
590 | + <?php echo apply_filters( 'yikes-mailchimp-' . esc_attr( $field[ 'merge' ] ) . '-description', stripslashes( $field[ 'description' ] ), $form_id ); ?> |
|
591 | 591 | </small> |
592 | 592 | </p> |
593 | 593 | <?php } ?> |
@@ -597,25 +597,25 @@ discard block |
||
597 | 597 | break; |
598 | 598 | |
599 | 599 | case 'zip': |
600 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
600 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
601 | 601 | |
602 | 602 | ?> |
603 | - <label for="<?php echo $field['merge']; ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
603 | + <label for="<?php echo $field[ 'merge' ]; ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
604 | 604 | |
605 | 605 | <!-- dictate label visibility --> |
606 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
607 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
608 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
606 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
607 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
608 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
609 | 609 | </span> |
610 | 610 | <?php } ?> |
611 | 611 | |
612 | - <input <?php echo implode( ' ' , $field_array ); ?> type="text" pattern="\d{5,5}(-\d{4,4})?" title="<?php _e( '5 digit zip code, numbers only' , 'yikes-inc-easy-mailchimp-extender' ); ?>" value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo $_POST[$field['merge']]; } else { echo esc_attr( $default_value ); } ?>"> |
|
612 | + <input <?php echo implode( ' ', $field_array ); ?> type="text" pattern="\d{5,5}(-\d{4,4})?" title="<?php _e( '5 digit zip code, numbers only', 'yikes-inc-easy-mailchimp-extender' ); ?>" value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo $_POST[ $field[ 'merge' ] ]; } else { echo esc_attr( $default_value ); } ?>"> |
|
613 | 613 | |
614 | 614 | <!-- description --> |
615 | - <?php if( isset( $field['description'] ) ) { ?> |
|
615 | + <?php if ( isset( $field[ 'description' ] ) ) { ?> |
|
616 | 616 | <p class="form-field-description"> |
617 | 617 | <small> |
618 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $form_id ); ?> |
|
618 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); ?> |
|
619 | 619 | </small> |
620 | 620 | </p> |
621 | 621 | <?php } ?> |
@@ -627,28 +627,28 @@ discard block |
||
627 | 627 | |
628 | 628 | case 'address': |
629 | 629 | // required fields |
630 | - $required_fields = array( 'addr1' => 'address' , 'addr2' => 'address 2', 'city' => 'city', 'state' =>'state', 'zip' =>'zip' , 'country' => 'country' ); |
|
630 | + $required_fields = array( 'addr1' => 'address', 'addr2' => 'address 2', 'city' => 'city', 'state' =>'state', 'zip' =>'zip', 'country' => 'country' ); |
|
631 | 631 | |
632 | 632 | // setup the default country value |
633 | 633 | $default_country = apply_filters( 'yikes-mailchimp-default-country-value', 'US' ); |
634 | 634 | |
635 | 635 | // store number for looping |
636 | 636 | $x = 1; |
637 | - foreach( $required_fields as $type => $label ) { |
|
637 | + foreach ( $required_fields as $type => $label ) { |
|
638 | 638 | |
639 | 639 | // set the field names for the addrress fields |
640 | - $field_array['name'] = 'name="'.$field[$tag].'['.$type.']'.'"'; |
|
640 | + $field_array[ 'name' ] = 'name="' . $field[ $tag ] . '[' . $type . ']' . '"'; |
|
641 | 641 | |
642 | 642 | // reset the label classes for left-half/right-half for addresses |
643 | - if( isset( $label_array['class'] ) ) { |
|
643 | + if ( isset( $label_array[ 'class' ] ) ) { |
|
644 | 644 | if ( $x % 2 == 0 ) { |
645 | - $label_array['class'] = str_replace( 'field-left-half', 'field-right-half', $label_array['class'] ); |
|
645 | + $label_array[ 'class' ] = str_replace( 'field-left-half', 'field-right-half', $label_array[ 'class' ] ); |
|
646 | 646 | } else { |
647 | - $label_array['class'] = str_replace( 'field-right-half', 'field-left-half', $label_array['class'] ); |
|
647 | + $label_array[ 'class' ] = str_replace( 'field-right-half', 'field-left-half', $label_array[ 'class' ] ); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | - switch( $type ) { |
|
651 | + switch ( $type ) { |
|
652 | 652 | |
653 | 653 | default: |
654 | 654 | case 'addr1': |
@@ -657,17 +657,17 @@ discard block |
||
657 | 657 | |
658 | 658 | |
659 | 659 | ?> |
660 | - <label for="<?php echo $field['merge']; ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ' , $label_array ); ?>> |
|
660 | + <label for="<?php echo $field[ 'merge' ]; ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ', $label_array ); ?>> |
|
661 | 661 | |
662 | 662 | <!-- dictate label visibility --> |
663 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
664 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
665 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-'.$type.'-label' , esc_attr( $label ) ) ); ?> |
|
663 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
664 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
665 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ) ) ); ?> |
|
666 | 666 | </span> |
667 | 667 | <?php } ?> |
668 | 668 | |
669 | 669 | |
670 | - <input <?php echo implode( ' ' , $field_array ); ?> type="text" value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo $_POST[$field['merge']]; } ?>"> |
|
670 | + <input <?php echo implode( ' ', $field_array ); ?> type="text" value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo $_POST[ $field[ 'merge' ] ]; } ?>"> |
|
671 | 671 | |
672 | 672 | </label> |
673 | 673 | <?php |
@@ -677,16 +677,16 @@ discard block |
||
677 | 677 | case 'state': |
678 | 678 | |
679 | 679 | ?> |
680 | - <label for="<?php echo $field['merge']; ?>" <?php echo implode( ' ' , $label_array ); ?> data-attr-name="state-dropdown"<?php if( ! in_array( $default_country, array( 'US' ) ) ) { ?> style="display: none;"<?php } ?>> |
|
680 | + <label for="<?php echo $field[ 'merge' ]; ?>" <?php echo implode( ' ', $label_array ); ?> data-attr-name="state-dropdown"<?php if ( ! in_array( $default_country, array( 'US' ) ) ) { ?> style="display: none;"<?php } ?>> |
|
681 | 681 | |
682 | 682 | <!-- dictate label visibility --> |
683 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
684 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
685 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-'.$type.'-label' , esc_attr( $label ) ) ); ?> |
|
683 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
684 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
685 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ) ) ); ?> |
|
686 | 686 | </span> |
687 | 687 | <?php } ?> |
688 | 688 | |
689 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
689 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
690 | 690 | <?php include( YIKES_MC_PATH . 'public/partials/shortcodes/templates/state-dropdown.php' ); ?> |
691 | 691 | </select> |
692 | 692 | |
@@ -699,15 +699,15 @@ discard block |
||
699 | 699 | case 'zip': |
700 | 700 | |
701 | 701 | ?> |
702 | - <label for="<?php echo $field['merge']; ?>" <?php echo implode( ' ' , $label_array ); ?> data-attr-name="zip-input"<?php if( ! in_array( $default_country, array( 'US', 'GB' ) ) ) { ?> style="display: none;"<?php } ?>> |
|
702 | + <label for="<?php echo $field[ 'merge' ]; ?>" <?php echo implode( ' ', $label_array ); ?> data-attr-name="zip-input"<?php if ( ! in_array( $default_country, array( 'US', 'GB' ) ) ) { ?> style="display: none;"<?php } ?>> |
|
703 | 703 | |
704 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
705 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
706 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-'.$type.'-label' , esc_attr( $label ) ) ); ?> |
|
704 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
705 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
706 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ) ) ); ?> |
|
707 | 707 | </span> |
708 | 708 | <?php } ?> |
709 | 709 | |
710 | - <input <?php echo implode( ' ' , $field_array ); ?> type="text" pattern="<?php echo apply_filters( 'yikes-mailchimp-zip-pattern', '\d{5,5}(-\d{4,4})?' ); ?>" title="<?php _e( '5 digit zip code, numbers only' , 'yikes-inc-easy-mailchimp-extender' ); ?>" value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo $_POST[$field['merge']]; } else { echo esc_attr( $default_value ); } ?>"> |
|
710 | + <input <?php echo implode( ' ', $field_array ); ?> type="text" pattern="<?php echo apply_filters( 'yikes-mailchimp-zip-pattern', '\d{5,5}(-\d{4,4})?' ); ?>" title="<?php _e( '5 digit zip code, numbers only', 'yikes-inc-easy-mailchimp-extender' ); ?>" value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo $_POST[ $field[ 'merge' ] ]; } else { echo esc_attr( $default_value ); } ?>"> |
|
711 | 711 | |
712 | 712 | </label> |
713 | 713 | <?php |
@@ -745,16 +745,16 @@ discard block |
||
745 | 745 | $default_country = apply_filters( 'yikes-mailchimp-default-country-value', 'US' ); |
746 | 746 | ?> |
747 | 747 | |
748 | - <label for="<?php echo $field['merge']; ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ' , $label_array ); ?>> |
|
748 | + <label for="<?php echo $field[ 'merge' ]; ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ', $label_array ); ?>> |
|
749 | 749 | |
750 | 750 | <!-- dictate label visibility --> |
751 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
752 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
753 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-'.$type.'-label' , esc_attr( $label ) ) ); ?> |
|
751 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
752 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
753 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ) ) ); ?> |
|
754 | 754 | </span> |
755 | 755 | <?php } ?> |
756 | 756 | |
757 | - <select <?php echo implode( ' ' , $field_array ); ?> onchange="checkCountry(this);return false;"> |
|
757 | + <select <?php echo implode( ' ', $field_array ); ?> onchange="checkCountry(this);return false;"> |
|
758 | 758 | <?php include( YIKES_MC_PATH . 'public/partials/shortcodes/templates/country-dropdown.php' ); ?> |
759 | 759 | </select> |
760 | 760 | </label> |
@@ -765,10 +765,10 @@ discard block |
||
765 | 765 | } |
766 | 766 | |
767 | 767 | // description |
768 | - if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
768 | + if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
769 | 769 | <p class="form-field-description"> |
770 | 770 | <small> |
771 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( trim( stripslashes( $field['description'] ) ) ), $form_id ); ?> |
|
771 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( trim( stripslashes( $field[ 'description' ] ) ) ), $form_id ); ?> |
|
772 | 772 | </small> |
773 | 773 | </p> |
774 | 774 | <?php } |
@@ -778,19 +778,19 @@ discard block |
||
778 | 778 | case 'birthday': |
779 | 779 | |
780 | 780 | // bootstrap datepicker requirements |
781 | - wp_enqueue_script( 'bootstrap-hover-dropdown' , YIKES_MC_URL . 'public/js/bootstrap-hover-dropdown.min.js' , array( 'jquery' ) ); |
|
782 | - wp_enqueue_script( 'bootstrap-datepicker-script' , YIKES_MC_URL . 'public/js/bootstrap-datepicker.min.js' , array( 'jquery' , 'bootstrap-hover-dropdown' ) ); |
|
783 | - wp_enqueue_style( 'bootstrap-datepicker-styles' , YIKES_MC_URL . 'public/css/bootstrap-datepicker3.standalone.min.css' ); |
|
784 | - wp_enqueue_style( 'override-datepicker-styles' , YIKES_MC_URL . 'public/css/yikes-inc-easy-mailchimp-datepicker-styles.css' , array( 'bootstrap-datepicker-styles' ) ); |
|
781 | + wp_enqueue_script( 'bootstrap-hover-dropdown', YIKES_MC_URL . 'public/js/bootstrap-hover-dropdown.min.js', array( 'jquery' ) ); |
|
782 | + wp_enqueue_script( 'bootstrap-datepicker-script', YIKES_MC_URL . 'public/js/bootstrap-datepicker.min.js', array( 'jquery', 'bootstrap-hover-dropdown' ) ); |
|
783 | + wp_enqueue_style( 'bootstrap-datepicker-styles', YIKES_MC_URL . 'public/css/bootstrap-datepicker3.standalone.min.css' ); |
|
784 | + wp_enqueue_style( 'override-datepicker-styles', YIKES_MC_URL . 'public/css/yikes-inc-easy-mailchimp-datepicker-styles.css', array( 'bootstrap-datepicker-styles' ) ); |
|
785 | 785 | |
786 | - switch ( $field['type'] ) { |
|
786 | + switch ( $field[ 'type' ] ) { |
|
787 | 787 | default: |
788 | 788 | case 'date': |
789 | - $date_format = ( isset( $field['date_format'] ) ) ? $field['date_format'] : 'mm/dd/yy'; |
|
789 | + $date_format = ( isset( $field[ 'date_format' ] ) ) ? $field[ 'date_format' ] : 'mm/dd/yy'; |
|
790 | 790 | break; |
791 | 791 | |
792 | 792 | case 'birthday': |
793 | - $date_format = ( isset( $field['date_format'] ) ) ? strtolower( $field['date_format'] ) : 'mm/dd'; |
|
793 | + $date_format = ( isset( $field[ 'date_format' ] ) ) ? strtolower( $field[ 'date_format' ] ) : 'mm/dd'; |
|
794 | 794 | break; |
795 | 795 | } |
796 | 796 | // initialize the datepicker |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | padding: .85em .5em !important; |
802 | 802 | } |
803 | 803 | <?php |
804 | - if( wp_is_mobile() ) { |
|
804 | + if ( wp_is_mobile() ) { |
|
805 | 805 | ?> |
806 | 806 | .datepicker-dropdown { |
807 | 807 | margin-top: 0px; |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | $day_names = $admin_class->yikes_jQuery_datepicker_strip_array_indices( $wp_locale->weekday ); |
817 | 817 | $day_names_short = $admin_class->yikes_jQuery_datepicker_strip_array_indices( $wp_locale->weekday_abbrev ); |
818 | 818 | $day_names_min = $admin_class->yikes_jQuery_datepicker_strip_array_indices( $wp_locale->weekday_initial ); |
819 | - $date_format = $admin_class->yikes_jQuery_datepicker_date_format_php_to_js( $date_format, $field['type'] ); |
|
819 | + $date_format = $admin_class->yikes_jQuery_datepicker_date_format_php_to_js( $date_format, $field[ 'type' ] ); |
|
820 | 820 | $first_day = get_option( 'start_of_week' ); |
821 | 821 | $isRTL = $wp_locale->is_rtl(); |
822 | 822 | ?> |
@@ -837,10 +837,10 @@ discard block |
||
837 | 837 | numberOfMonths: 1, |
838 | 838 | today: '<?php _e( 'Today', 'yikes-inc-easy-mailchimp-extender' ); ?>' |
839 | 839 | }; |
840 | - jQuery('input[data-attr-type="<?php echo $field['type']; ?>"]').datepicker().on( 'show', function( e ) { |
|
841 | - var date_picker_height = jQuery('input[data-attr-type="<?php echo $field['type']; ?>"]').css( 'height' ); |
|
840 | + jQuery('input[data-attr-type="<?php echo $field[ 'type' ]; ?>"]').datepicker().on( 'show', function( e ) { |
|
841 | + var date_picker_height = jQuery('input[data-attr-type="<?php echo $field[ 'type' ]; ?>"]').css( 'height' ); |
|
842 | 842 | date_picker_height = parseInt( date_picker_height.replace( 'px', '' ) ) + parseInt( 15 ) + 'px'; |
843 | - var date_picker_width = jQuery('input[data-attr-type="<?php echo $field['type']; ?>"]').css( 'width' ).replace( 'px', '' ); |
|
843 | + var date_picker_width = jQuery('input[data-attr-type="<?php echo $field[ 'type' ]; ?>"]').css( 'width' ).replace( 'px', '' ); |
|
844 | 844 | if( date_picker_width > 500 ) { |
845 | 845 | date_picker_width = 500; |
846 | 846 | } |
@@ -850,27 +850,27 @@ discard block |
||
850 | 850 | </script> |
851 | 851 | <?php |
852 | 852 | |
853 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
853 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
854 | 854 | // store empty number for looping |
855 | 855 | $x = 0; |
856 | 856 | |
857 | 857 | ?> |
858 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
858 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
859 | 859 | |
860 | 860 | <!-- dictate label visibility --> |
861 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
862 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
863 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
861 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
862 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
863 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
864 | 864 | </span> |
865 | 865 | <?php } ?> |
866 | 866 | |
867 | - <input <?php echo implode( ' ' , $field_array ); ?> type="text" <?php if( $field['type'] == 'date' ) { ?> data-attr-type="date" <?php } else { ?> data-attr-type="birthday" <?php } ?> value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo $_POST[$field['merge']]; } else { echo esc_attr( $default_value ); } ?>"> |
|
867 | + <input <?php echo implode( ' ', $field_array ); ?> type="text" <?php if ( $field[ 'type' ] == 'date' ) { ?> data-attr-type="date" <?php } else { ?> data-attr-type="birthday" <?php } ?> value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo $_POST[ $field[ 'merge' ] ]; } else { echo esc_attr( $default_value ); } ?>"> |
|
868 | 868 | |
869 | 869 | <!-- description --> |
870 | - <?php if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
870 | + <?php if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
871 | 871 | <p class="form-field-description"> |
872 | 872 | <small> |
873 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( trim( stripslashes( $field['description'] ) ) ), $form_id ); ?> |
|
873 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( trim( stripslashes( $field[ 'description' ] ) ) ), $form_id ); ?> |
|
874 | 874 | </small> |
875 | 875 | </p> |
876 | 876 | <?php } ?> |
@@ -881,36 +881,36 @@ discard block |
||
881 | 881 | break; |
882 | 882 | |
883 | 883 | case 'dropdown': |
884 | - $default_value = $field['default_choice']; |
|
884 | + $default_value = $field[ 'default_choice' ]; |
|
885 | 885 | // store empty number for looping |
886 | 886 | $x = 0; |
887 | 887 | // hidden labels |
888 | 888 | |
889 | 889 | ?> |
890 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
890 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
891 | 891 | <!-- dictate label visibility --> |
892 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
893 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
894 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
892 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
893 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
894 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
895 | 895 | </span> |
896 | 896 | <?php } ?> |
897 | 897 | |
898 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
898 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
899 | 899 | <?php |
900 | 900 | // decode for looping |
901 | - $choices = json_decode( $field['choices'], true ); |
|
902 | - foreach( $choices as $choice ) { |
|
903 | - ?><option value="<?php echo $choice; ?>" <?php selected( $default_value , $x ); ?>><?php echo esc_attr( stripslashes( $choice ) ); ?></option><?php |
|
901 | + $choices = json_decode( $field[ 'choices' ], true ); |
|
902 | + foreach ( $choices as $choice ) { |
|
903 | + ?><option value="<?php echo $choice; ?>" <?php selected( $default_value, $x ); ?>><?php echo esc_attr( stripslashes( $choice ) ); ?></option><?php |
|
904 | 904 | $x++; |
905 | 905 | } |
906 | 906 | ?> |
907 | 907 | </select> |
908 | 908 | |
909 | 909 | <!-- description --> |
910 | - <?php if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
910 | + <?php if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
911 | 911 | <p class="form-field-description"> |
912 | 912 | <small> |
913 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( trim( stripslashes( $field['description'] ) ) ), $form_id ); ?> |
|
913 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( trim( stripslashes( $field[ 'description' ] ) ) ), $form_id ); ?> |
|
914 | 914 | </small> |
915 | 915 | </p> |
916 | 916 | <?php } ?> |
@@ -924,13 +924,13 @@ discard block |
||
924 | 924 | case 'radio': |
925 | 925 | case 'checkbox': |
926 | 926 | // remove the ID (as to not assign the same ID to every radio button) |
927 | - unset( $field_array['id'] ); |
|
928 | - $choices = json_decode( $field['choices'], true ); |
|
927 | + unset( $field_array[ 'id' ] ); |
|
928 | + $choices = json_decode( $field[ 'choices' ], true ); |
|
929 | 929 | // assign a default choice |
930 | - $default_value = ( isset( $field['default_choice'] ) && $field['default_choice'] != '' ) ? $field['default_choice'] : $choices[0]; |
|
930 | + $default_value = ( isset( $field[ 'default_choice' ] ) && $field[ 'default_choice' ] != '' ) ? $field[ 'default_choice' ] : $choices[ 0 ]; |
|
931 | 931 | // if the form was submit, but failed, let's reset the post data |
932 | - if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { |
|
933 | - $default_value = $_POST[$field['merge']]; |
|
932 | + if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { |
|
933 | + $default_value = $_POST[ $field[ 'merge' ] ]; |
|
934 | 934 | } |
935 | 935 | $count = count( $choices ); |
936 | 936 | $i = 1; |
@@ -939,20 +939,20 @@ discard block |
||
939 | 939 | // hidden labels |
940 | 940 | |
941 | 941 | ?> |
942 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
942 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
943 | 943 | |
944 | 944 | <!-- dictate label visibility --> |
945 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
946 | - <span class="<?php echo esc_attr( $field['merge'] ). '-label'; ?> checkbox-parent-label"> |
|
947 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
945 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
946 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?> checkbox-parent-label"> |
|
947 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
948 | 948 | </span> |
949 | 949 | <?php } |
950 | 950 | |
951 | - foreach( $choices as $choice ) { |
|
951 | + foreach ( $choices as $choice ) { |
|
952 | 952 | ?> |
953 | - <label for="<?php echo esc_attr( $field['merge'] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ' , $custom_classes ); if( $i === $count ) { ?> last-selection<?php } ?>" <?php if( $i == 1 ) { echo $field_array['required']; } ?>> |
|
954 | - <input type="<?php echo esc_attr( $field['type'] ); ?>" name="<?php echo $field['merge']; ?>" id="<?php echo $field['merge'] . '-' . $i; ?>" <?php checked( $default_value , $x ); ?> value="<?php echo esc_attr( $choice ); ?>"> |
|
955 | - <span class="<?php echo esc_attr( $field['merge'] ). '-label'; ?>"><?php echo stripslashes( $choice ); ?></span> |
|
953 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ', $custom_classes ); if ( $i === $count ) { ?> last-selection<?php } ?>" <?php if ( $i == 1 ) { echo $field_array[ 'required' ]; } ?>> |
|
954 | + <input type="<?php echo esc_attr( $field[ 'type' ] ); ?>" name="<?php echo $field[ 'merge' ]; ?>" id="<?php echo $field[ 'merge' ] . '-' . $i; ?>" <?php checked( $default_value, $x ); ?> value="<?php echo esc_attr( $choice ); ?>"> |
|
955 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"><?php echo stripslashes( $choice ); ?></span> |
|
956 | 956 | </label> |
957 | 957 | <?php |
958 | 958 | $i++; |
@@ -960,10 +960,10 @@ discard block |
||
960 | 960 | } |
961 | 961 | |
962 | 962 | // description |
963 | - if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
963 | + if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
964 | 964 | <p class="form-field-description"> |
965 | 965 | <small> |
966 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( trim( stripslashes( $field['description'] ) ) ), $form_id ); ?> |
|
966 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( trim( stripslashes( $field[ 'description' ] ) ) ), $form_id ); ?> |
|
967 | 967 | </small> |
968 | 968 | </p> |
969 | 969 | <?php } ?> |
@@ -979,26 +979,26 @@ discard block |
||
979 | 979 | |
980 | 980 | |
981 | 981 | // store default choice |
982 | - $default_choice = ( isset( $field['default_choice'] ) && ! empty( $field['default_choice'] ) ) ? ( is_array( $field['default_choice'] ) ? $field['default_choice'] : $field['default_choice'] ) : ( isset( $field['default_choice'] ) ? $field['default_choice'] : '' ); |
|
982 | + $default_choice = ( isset( $field[ 'default_choice' ] ) && ! empty( $field[ 'default_choice' ] ) ) ? ( is_array( $field[ 'default_choice' ] ) ? $field[ 'default_choice' ] : $field[ 'default_choice' ] ) : ( isset( $field[ 'default_choice' ] ) ? $field[ 'default_choice' ] : '' ); |
|
983 | 983 | |
984 | 984 | // if the form was submit, but failed, let's reset the post data |
985 | - if( isset( $_POST[$field['group_id']] ) && $form_submitted != 1 ) { |
|
986 | - $default_choice = $_POST[$field['group_id']]; |
|
985 | + if ( isset( $_POST[ $field[ 'group_id' ] ] ) && $form_submitted != 1 ) { |
|
986 | + $default_choice = $_POST[ $field[ 'group_id' ] ]; |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | // get our groups |
990 | - $groups = ( isset( $field['groups'] ) && ! empty( $field['groups'] ) ) ? json_decode( $field['groups'], true ) : array(); |
|
990 | + $groups = ( isset( $field[ 'groups' ] ) && ! empty( $field[ 'groups' ] ) ) ? json_decode( $field[ 'groups' ], true ) : array(); |
|
991 | 991 | |
992 | 992 | $count = count( $groups ); |
993 | 993 | |
994 | - if( $field['type'] == 'checkboxes' ) { |
|
994 | + if ( $field[ 'type' ] == 'checkboxes' ) { |
|
995 | 995 | $type = 'checkbox'; |
996 | - } else if( $field['type'] == 'radio' ) { |
|
996 | + } else if ( $field[ 'type' ] == 'radio' ) { |
|
997 | 997 | $type = 'radio'; |
998 | 998 | } |
999 | 999 | |
1000 | 1000 | // loop over the interest group field types |
1001 | - switch ( $field['type'] ) { |
|
1001 | + switch ( $field[ 'type' ] ) { |
|
1002 | 1002 | |
1003 | 1003 | case 'checkboxes': |
1004 | 1004 | case 'radio': |
@@ -1006,18 +1006,18 @@ discard block |
||
1006 | 1006 | $x = 1; // used to find the last item of our array |
1007 | 1007 | |
1008 | 1008 | ?> |
1009 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
1010 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
1009 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
1010 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
1011 | 1011 | <!-- dictate label visibility --> |
1012 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?> checkbox-parent-label"> |
|
1013 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['group_id'].'-label' , esc_attr( $field['label'] ) ); ?> |
|
1012 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?> checkbox-parent-label"> |
|
1013 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( $field[ 'label' ] ) ); ?> |
|
1014 | 1014 | </span> |
1015 | 1015 | <?php |
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | // Display Submission Errors |
1019 | - if( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
1020 | - if( in_array( $field['group_id'], $missing_required_checkbox_interest_groups ) ) { |
|
1019 | + if ( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
1020 | + if ( in_array( $field[ 'group_id' ], $missing_required_checkbox_interest_groups ) ) { |
|
1021 | 1021 | ?> |
1022 | 1022 | <p class="yikes-mailchimp-required-interest-group-error"> |
1023 | 1023 | <?php echo apply_filters( 'yikes-mailchimp-interest-group-checkbox-error', __( 'This field is required.', 'yikes-inc-easy-mailchimp-extender' ), $form_id ); ?> |
@@ -1028,19 +1028,19 @@ discard block |
||
1028 | 1028 | |
1029 | 1029 | |
1030 | 1030 | |
1031 | - foreach( $groups as $group ) { |
|
1032 | - if( $field['type'] == 'checkboxes' ) { |
|
1031 | + foreach ( $groups as $group ) { |
|
1032 | + if ( $field[ 'type' ] == 'checkboxes' ) { |
|
1033 | 1033 | /* Setup the defaults for this field - varies if the field was previously submitted */ |
1034 | - if( isset( $_POST[$field['group_id']] ) && $form_submitted != 1 ) { |
|
1035 | - $default_choice = $_POST[$field['group_id']]; |
|
1036 | - } elseif( ( ! isset( $_POST['yikes-mailchimp-honeypot'] ) && $form_submitted != 1 ) || ( isset( $_POST['yikes-mailchimp-honeypot'] ) && $form_submitted == 1 ) ) { |
|
1037 | - $default_choice = ( isset( $field['default_choice'] ) && ! empty( $field['default_choice'] ) ) ? ( is_array( $field['default_choice'] ) ? $field['default_choice'] : $field['default_choice'] ) : array(); |
|
1034 | + if ( isset( $_POST[ $field[ 'group_id' ] ] ) && $form_submitted != 1 ) { |
|
1035 | + $default_choice = $_POST[ $field[ 'group_id' ] ]; |
|
1036 | + } elseif ( ( ! isset( $_POST[ 'yikes-mailchimp-honeypot' ] ) && $form_submitted != 1 ) || ( isset( $_POST[ 'yikes-mailchimp-honeypot' ] ) && $form_submitted == 1 ) ) { |
|
1037 | + $default_choice = ( isset( $field[ 'default_choice' ] ) && ! empty( $field[ 'default_choice' ] ) ) ? ( is_array( $field[ 'default_choice' ] ) ? $field[ 'default_choice' ] : $field[ 'default_choice' ] ) : array(); |
|
1038 | 1038 | } |
1039 | 1039 | } |
1040 | 1040 | ?> |
1041 | - <label for="<?php echo $field['group_id'] . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ' , $custom_classes ); if( $x === $count ) { ?> last-selection<?php } ?>"> |
|
1042 | - <input <?php if( isset( $field['require'] ) && $field['require'] == 1 ) { ?> class="yikes-interest-group-required" <?php } ?> type="<?php echo $type; ?>" name="<?php echo $field['group_id']; ?>[]" id="<?php echo $field['group_id'] . '-' . $i; ?>" <?php if( $field['type'] == 'checkboxes' ) { if( ( ( isset( $_POST['yikes-mailchimp-honeypot' ] ) && $form_submitted == 1 && in_array( $i , $default_choice )) || ! isset( $_POST['yikes-mailchimp-honeypot' ] ) && $form_submitted != 1 && in_array( $i , $default_choice ) ) || ( ( $form_submitted != 1 && isset( $_POST[$field['group_id']] ) ) && in_array( esc_attr( $group['name'] ), $default_choice ) ) ) { echo 'checked="checked"'; } } else { checked( ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice[0] : $default_choice , $i ); } ?> value="<?php echo esc_attr( $group['name'] ); ?>"> |
|
1043 | - <?php echo $group['name']; ?> |
|
1041 | + <label for="<?php echo $field[ 'group_id' ] . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ', $custom_classes ); if ( $x === $count ) { ?> last-selection<?php } ?>"> |
|
1042 | + <input <?php if ( isset( $field[ 'require' ] ) && $field[ 'require' ] == 1 ) { ?> class="yikes-interest-group-required" <?php } ?> type="<?php echo $type; ?>" name="<?php echo $field[ 'group_id' ]; ?>[]" id="<?php echo $field[ 'group_id' ] . '-' . $i; ?>" <?php if ( $field[ 'type' ] == 'checkboxes' ) { if ( ( ( isset( $_POST[ 'yikes-mailchimp-honeypot' ] ) && $form_submitted == 1 && in_array( $i, $default_choice ) ) || ! isset( $_POST[ 'yikes-mailchimp-honeypot' ] ) && $form_submitted != 1 && in_array( $i, $default_choice ) ) || ( ( $form_submitted != 1 && isset( $_POST[ $field[ 'group_id' ] ] ) ) && in_array( esc_attr( $group[ 'name' ] ), $default_choice ) ) ) { echo 'checked="checked"'; } } else { checked( ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice[ 0 ] : $default_choice, $i ); } ?> value="<?php echo esc_attr( $group[ 'name' ] ); ?>"> |
|
1043 | + <?php echo $group[ 'name' ]; ?> |
|
1044 | 1044 | </label> |
1045 | 1045 | <?php |
1046 | 1046 | $i++; |
@@ -1048,10 +1048,10 @@ discard block |
||
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | // description |
1051 | - if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
1051 | + if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
1052 | 1052 | <p class="form-field-description"> |
1053 | 1053 | <small> |
1054 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description', esc_attr( trim( $field['description'] ) ), $form_id ); ?> |
|
1054 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-description', esc_attr( trim( $field[ 'description' ] ) ), $form_id ); ?> |
|
1055 | 1055 | </small> |
1056 | 1056 | </p> |
1057 | 1057 | <?php } ?> |
@@ -1065,28 +1065,28 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | ?> |
1067 | 1067 | |
1068 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
1068 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
1069 | 1069 | <!-- dictate label visibility --> |
1070 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
1071 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?>"> |
|
1072 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['group_id'].'-label' , esc_attr( $field['label'] ) ); ?> |
|
1070 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
1071 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?>"> |
|
1072 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( $field[ 'label' ] ) ); ?> |
|
1073 | 1073 | </span> |
1074 | 1074 | <?php } ?> |
1075 | 1075 | |
1076 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
1076 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
1077 | 1077 | <?php |
1078 | 1078 | $i = 0; |
1079 | - foreach( $groups as $group ) { |
|
1080 | - ?><option <?php selected( $i , $default_choice ); ?> value="<?php echo $group['name']; ?>"><?php echo esc_attr( $group['name'] ); ?></option><?php |
|
1079 | + foreach ( $groups as $group ) { |
|
1080 | + ?><option <?php selected( $i, $default_choice ); ?> value="<?php echo $group[ 'name' ]; ?>"><?php echo esc_attr( $group[ 'name' ] ); ?></option><?php |
|
1081 | 1081 | $i++; |
1082 | 1082 | } |
1083 | 1083 | ?> |
1084 | 1084 | </select> |
1085 | 1085 | |
1086 | - <?php if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
1086 | + <?php if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
1087 | 1087 | <p class="form-field-description"> |
1088 | 1088 | <small> |
1089 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description', esc_attr( trim( $field['description'] ) ), $form_id ); ?> |
|
1089 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-description', esc_attr( trim( $field[ 'description' ] ) ), $form_id ); ?> |
|
1090 | 1090 | </small> |
1091 | 1091 | </p> |
1092 | 1092 | <?php } ?> |
@@ -1103,21 +1103,21 @@ discard block |
||
1103 | 1103 | |
1104 | 1104 | ?> |
1105 | 1105 | |
1106 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
1106 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
1107 | 1107 | |
1108 | 1108 | <!-- dictate label visibility --> |
1109 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
1110 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?> checkbox-parent-label" style="display:none;"> |
|
1111 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['group_id'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
1109 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
1110 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?> checkbox-parent-label" style="display:none;"> |
|
1111 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
1112 | 1112 | </span> |
1113 | 1113 | <?php } |
1114 | 1114 | |
1115 | 1115 | |
1116 | - foreach( $groups as $group ) { |
|
1116 | + foreach ( $groups as $group ) { |
|
1117 | 1117 | ?> |
1118 | - <label for="<?php echo $field['group_id'] . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ' , $custom_classes ); if( $x === $count ) { ?> last-selection<?php } ?>" style="display:none;"> |
|
1119 | - <input type="radio" name="<?php echo $field['group_id']; ?>[]" id="<?php echo $field['group_id'] . '-' . $i; ?>" <?php if( $field['type'] == 'checkboxes' ) { if( in_array( $i , $default_choice ) ) { echo 'checked="checked"'; } } else { checked( ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice[0] : $default_choice , $i ); } ?> value="<?php echo esc_attr( $group['name'] ); ?>"> |
|
1120 | - <?php echo esc_attr( stripslashes( str_replace( '' , '\'', $group['name'] ) ) ); ?> |
|
1118 | + <label for="<?php echo $field[ 'group_id' ] . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ', $custom_classes ); if ( $x === $count ) { ?> last-selection<?php } ?>" style="display:none;"> |
|
1119 | + <input type="radio" name="<?php echo $field[ 'group_id' ]; ?>[]" id="<?php echo $field[ 'group_id' ] . '-' . $i; ?>" <?php if ( $field[ 'type' ] == 'checkboxes' ) { if ( in_array( $i, $default_choice ) ) { echo 'checked="checked"'; } } else { checked( ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice[ 0 ] : $default_choice, $i ); } ?> value="<?php echo esc_attr( $group[ 'name' ] ); ?>"> |
|
1120 | + <?php echo esc_attr( stripslashes( str_replace( '', '\'', $group[ 'name' ] ) ) ); ?> |
|
1121 | 1121 | </label> |
1122 | 1122 | <?php |
1123 | 1123 | $i++; |
@@ -1125,10 +1125,10 @@ discard block |
||
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | // description |
1128 | - if( isset( $field['description'] ) && trim( $field['description'] ) != '' ) { ?> |
|
1128 | + if ( isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) != '' ) { ?> |
|
1129 | 1129 | <p class="form-field-description"> |
1130 | 1130 | <small> |
1131 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description', esc_attr( trim( stripslashes( $field['description'] ) ) ), $form_id ); ?> |
|
1131 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-description', esc_attr( trim( stripslashes( $field[ 'description' ] ) ) ), $form_id ); ?> |
|
1132 | 1132 | </small> |
1133 | 1133 | </p> |
1134 | 1134 | <?php } |
@@ -1145,11 +1145,11 @@ discard block |
||
1145 | 1145 | do_action( 'yikes-mailchimp-additional-form-fields', $form_data ); |
1146 | 1146 | |
1147 | 1147 | /* if we've enabled reCAPTCHA protection */ |
1148 | - if( isset( $recaptcha_box ) ) { |
|
1148 | + if ( isset( $recaptcha_box ) ) { |
|
1149 | 1149 | echo $recaptcha_box; |
1150 | 1150 | } |
1151 | - if( is_user_logged_in() ) { |
|
1152 | - $admin_class = ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) ? ' admin-logged-in' : ''; |
|
1151 | + if ( is_user_logged_in() ) { |
|
1152 | + $admin_class = ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) ? ' admin-logged-in' : ''; |
|
1153 | 1153 | } else { |
1154 | 1154 | $admin_class = ''; |
1155 | 1155 | } |
@@ -1159,23 +1159,23 @@ discard block |
||
1159 | 1159 | <input type="hidden" name="yikes-mailchimp-honeypot" id="yikes-mailchimp-honeypot" value=""> |
1160 | 1160 | |
1161 | 1161 | <!-- List ID --> |
1162 | - <input type="hidden" name="yikes-mailchimp-associated-list-id" id="yikes-mailchimp-associated-list-id" value="<?php echo $form_settings['list_id']; ?>"> |
|
1162 | + <input type="hidden" name="yikes-mailchimp-associated-list-id" id="yikes-mailchimp-associated-list-id" value="<?php echo $form_settings[ 'list_id' ]; ?>"> |
|
1163 | 1163 | |
1164 | 1164 | <!-- Form that is being submitted! Used to display error/success messages above the correct form --> |
1165 | 1165 | <input type="hidden" name="yikes-mailchimp-submitted-form" id="yikes-mailchimp-submitted-form" value="<?php echo $form_id; ?>"> |
1166 | 1166 | |
1167 | 1167 | <!-- Submit Button --> |
1168 | 1168 | <?php |
1169 | - if( $form_inline ) { |
|
1169 | + if ( $form_inline ) { |
|
1170 | 1170 | echo '<label class="empty-form-inline-label submit-button-inline-label"><span class="empty-label"> </span>'; |
1171 | 1171 | } |
1172 | 1172 | // display the image or text based button |
1173 | - if( $submit_button_type == 'text' ) { |
|
1174 | - echo apply_filters( 'yikes-mailchimp-form-submit-button', '<button type="submit" class="' . apply_filters( 'yikes-mailchimp-form-submit-button-classes', 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-' . esc_attr( $form_data['id'] ) . ' btn btn-primary' . $submit_button_classes . $admin_class, $form_data['id'] ) . '">' . apply_filters( 'yikes-mailchimp-form-submit-button-text', esc_attr( stripslashes( $submit ) ), $form_data['id'] ) . '</button>', $form_data['id'] ); |
|
1173 | + if ( $submit_button_type == 'text' ) { |
|
1174 | + echo apply_filters( 'yikes-mailchimp-form-submit-button', '<button type="submit" class="' . apply_filters( 'yikes-mailchimp-form-submit-button-classes', 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-' . esc_attr( $form_data[ 'id' ] ) . ' btn btn-primary' . $submit_button_classes . $admin_class, $form_data[ 'id' ] ) . '">' . apply_filters( 'yikes-mailchimp-form-submit-button-text', esc_attr( stripslashes( $submit ) ), $form_data[ 'id' ] ) . '</button>', $form_data[ 'id' ] ); |
|
1175 | 1175 | } else { |
1176 | - echo apply_filters( 'yikes-mailchimp-form-submit-button', '<input type="image" alt="' . apply_filters( 'yikes-mailchimp-form-submit-button-text', esc_attr( stripslashes( $submit ) ), $form_data['id'] ) . '" src="' . $submit_button_image . '" class="' . apply_filters( 'yikes-mailchimp-form-submit-button-classes', 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-image yikes-easy-mc-submit-button-' . esc_attr( $form_data['id'] ) . ' btn btn-primary' . $submit_button_classes . $admin_class, $form_data['id'] ) . '">', $form_data['id'] ); |
|
1176 | + echo apply_filters( 'yikes-mailchimp-form-submit-button', '<input type="image" alt="' . apply_filters( 'yikes-mailchimp-form-submit-button-text', esc_attr( stripslashes( $submit ) ), $form_data[ 'id' ] ) . '" src="' . $submit_button_image . '" class="' . apply_filters( 'yikes-mailchimp-form-submit-button-classes', 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-image yikes-easy-mc-submit-button-' . esc_attr( $form_data[ 'id' ] ) . ' btn btn-primary' . $submit_button_classes . $admin_class, $form_data[ 'id' ] ) . '">', $form_data[ 'id' ] ); |
|
1177 | 1177 | } |
1178 | - if( $form_inline ) { |
|
1178 | + if ( $form_inline ) { |
|
1179 | 1179 | echo '</label>'; |
1180 | 1180 | } |
1181 | 1181 | ?> |
@@ -1187,8 +1187,8 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | <?php |
1189 | 1189 | /* If the current user is logged in, and an admin...lets display our 'Edit Form' link */ |
1190 | - if( is_user_logged_in() ) { |
|
1191 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
1190 | + if ( is_user_logged_in() ) { |
|
1191 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
1192 | 1192 | echo $edit_form_link; |
1193 | 1193 | } |
1194 | 1194 | } |
@@ -1203,16 +1203,16 @@ discard block |
||
1203 | 1203 | * Update the impressions count |
1204 | 1204 | * for non-admins |
1205 | 1205 | */ |
1206 | - if( !current_user_can( 'manage_options' ) ) { |
|
1207 | - $form_data['impressions']++; |
|
1206 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
1207 | + $form_data[ 'impressions' ]++; |
|
1208 | 1208 | $wpdb->update( |
1209 | 1209 | $wpdb->prefix . 'yikes_easy_mc_forms', |
1210 | 1210 | array( |
1211 | - 'impressions' => $form_data['impressions'], |
|
1211 | + 'impressions' => $form_data[ 'impressions' ], |
|
1212 | 1212 | ), |
1213 | 1213 | array( 'ID' => $form ), |
1214 | 1214 | array( |
1215 | - '%d', // send welcome email |
|
1215 | + '%d', // send welcome email |
|
1216 | 1216 | ), |
1217 | 1217 | array( '%d' ) |
1218 | 1218 | ); |
@@ -5,34 +5,34 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // parse our form data |
8 | -parse_str( $_POST['form_data'], $data ); |
|
8 | +parse_str( $_POST[ 'form_data' ], $data ); |
|
9 | 9 | // store the form ID to use in our hooks and filters |
10 | -$form = $_POST['form_id']; |
|
10 | +$form = $_POST[ 'form_id' ]; |
|
11 | 11 | |
12 | 12 | // Retreive the form data from the database instead of posting it with the form-submission |
13 | 13 | global $wpdb; |
14 | 14 | // return it as an array, so we can work with it to build our form below |
15 | 15 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms WHERE id = ' . $form . '', ARRAY_A ); |
16 | 16 | |
17 | -if( $form_results ) { |
|
18 | - $form_data = $form_results[0]; |
|
17 | +if ( $form_results ) { |
|
18 | + $form_data = $form_results[ 0 ]; |
|
19 | 19 | // List ID |
20 | - $list_id = $form_data['list_id']; |
|
20 | + $list_id = $form_data[ 'list_id' ]; |
|
21 | 21 | // decode our submission settings |
22 | - $submission_settings = json_decode( stripslashes( $form_data['submission_settings'] ), true ); |
|
22 | + $submission_settings = json_decode( stripslashes( $form_data[ 'submission_settings' ] ), true ); |
|
23 | 23 | // decode our optin settings |
24 | - $optin_settings = json_decode( stripslashes( $form_data['optin_settings'] ), true ); |
|
24 | + $optin_settings = json_decode( stripslashes( $form_data[ 'optin_settings' ] ), true ); |
|
25 | 25 | // decode our fields |
26 | - $form_fields = json_decode( stripslashes( $form_data['fields'] ), true ); |
|
26 | + $form_fields = json_decode( stripslashes( $form_data[ 'fields' ] ), true ); |
|
27 | 27 | /* Decode our error messages |
28 | 28 | * Workaround for international characters (cyrillic etc) |
29 | 29 | * See: https://wordpress.org/support/topic/custom-messages-do-not-support-cyrillic-characters?replies=11#post-7629620 |
30 | 30 | */ |
31 | - $error_messages = ( get_magic_quotes_gpc() ) ? json_decode( stripslashes( $form_data['error_messages'] ), true ) : json_decode( $form_data['error_messages'], true ); |
|
31 | + $error_messages = ( get_magic_quotes_gpc() ) ? json_decode( stripslashes( $form_data[ 'error_messages' ] ), true ) : json_decode( $form_data[ 'error_messages' ], true ); |
|
32 | 32 | /** Submit Process **/ |
33 | - $notifications = json_decode( stripslashes( $form_data['custom_notifications'] ), true ); |
|
33 | + $notifications = json_decode( stripslashes( $form_data[ 'custom_notifications' ] ), true ); |
|
34 | 34 | /* Page Data */ |
35 | - $page_data = $_POST['page_data']; |
|
35 | + $page_data = $_POST[ 'page_data' ]; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Empty array to build up merge variables |
@@ -42,39 +42,39 @@ discard block |
||
42 | 42 | $error = 0; |
43 | 43 | |
44 | 44 | /* Check for Honeypot filled */ |
45 | -$honey_pot_filled = ( isset( $data['yikes-mailchimp-honeypot'] ) && $data['yikes-mailchimp-honeypot'] != '' ) ? true : false; |
|
45 | +$honey_pot_filled = ( isset( $data[ 'yikes-mailchimp-honeypot' ] ) && $data[ 'yikes-mailchimp-honeypot' ] != '' ) ? true : false; |
|
46 | 46 | // if it was filled out, return an error... |
47 | -if( $honey_pot_filled ) { |
|
47 | +if ( $honey_pot_filled ) { |
|
48 | 48 | wp_send_json_error( array( |
49 | 49 | 'hide' => '0', |
50 | 50 | 'error' => 1, |
51 | - 'response' => __( "Error: It looks like the honeypot was filled out and the form was not properly be submitted." , 'yikes-inc-easy-mailchimp-extender' ) |
|
51 | + 'response' => __( "Error: It looks like the honeypot was filled out and the form was not properly be submitted.", 'yikes-inc-easy-mailchimp-extender' ) |
|
52 | 52 | ) ); |
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | 56 | // Check reCAPTCHA Response was submitted with the form data |
57 | -if( isset( $data['g-recaptcha-response'] ) ) { |
|
58 | - $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key' , '' ) . '&response=' . $data['g-recaptcha-response'] . '&remoteip=' . $_SERVER["REMOTE_ADDR"] ); |
|
57 | +if ( isset( $data[ 'g-recaptcha-response' ] ) ) { |
|
58 | + $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key', '' ) . '&response=' . $data[ 'g-recaptcha-response' ] . '&remoteip=' . $_SERVER[ "REMOTE_ADDR" ] ); |
|
59 | 59 | $response = wp_remote_get( $url ); |
60 | - $response_body = json_decode( $response['body'] , true ); |
|
60 | + $response_body = json_decode( $response[ 'body' ], true ); |
|
61 | 61 | // if we've hit an error, lets return the error! |
62 | - if( $response_body['success'] != 1 ) { |
|
62 | + if ( $response_body[ 'success' ] != 1 ) { |
|
63 | 63 | $error_messages = array(); // empty array to store error messages |
64 | - if( isset( $response_body['error-codes'] ) ) { |
|
65 | - foreach( $response_body['error-codes'] as $error_code ) { |
|
66 | - if( $error_code == 'missing-input-response' ) { |
|
64 | + if ( isset( $response_body[ 'error-codes' ] ) ) { |
|
65 | + foreach ( $response_body[ 'error-codes' ] as $error_code ) { |
|
66 | + if ( $error_code == 'missing-input-response' ) { |
|
67 | 67 | $error_code = __( 'Please check the reCAPTCHA field.', 'yikes-inc-easy-mailchimp-extender' ); |
68 | 68 | } |
69 | - $error_messages[] = __( 'Error', 'yikes-inc-easy-mailchimp-extender' ) . ': ' . $error_code; |
|
69 | + $error_messages[ ] = __( 'Error', 'yikes-inc-easy-mailchimp-extender' ) . ': ' . $error_code; |
|
70 | 70 | } |
71 | 71 | } else { |
72 | - $error_messages[] = __( 'Please refresh the page and try again.', 'yikes-inc-easy-mailchimp-extender' ); |
|
72 | + $error_messages[ ] = __( 'Please refresh the page and try again.', 'yikes-inc-easy-mailchimp-extender' ); |
|
73 | 73 | } |
74 | 74 | $error = 1; |
75 | 75 | wp_send_json_error( array( |
76 | 76 | 'hide' => '0', |
77 | - 'error' => $error , |
|
77 | + 'error' => $error, |
|
78 | 78 | 'response' => apply_filters( 'yikes-mailchimp-recaptcha-required-error', implode( ' ', $error_messages ) ), |
79 | 79 | ) ); |
80 | 80 | exit(); |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | |
84 | 84 | // loop to push variables to our array |
85 | 85 | foreach ( $data as $merge_tag => $value ) { |
86 | - if( $merge_tag != 'yikes_easy_mc_new_subscriber' && $merge_tag != '_wp_http_referer' ) { |
|
86 | + if ( $merge_tag != 'yikes_easy_mc_new_subscriber' && $merge_tag != '_wp_http_referer' ) { |
|
87 | 87 | // check if the current iteration has a 'date_format' key set |
88 | 88 | // (aka - date/birthday fields) |
89 | - if( isset( $form_fields[$merge_tag]['date_format'] ) ) { |
|
89 | + if ( isset( $form_fields[ $merge_tag ][ 'date_format' ] ) ) { |
|
90 | 90 | // check if EU date format |
91 | - if( $form_fields[$merge_tag]['date_format'] == 'DD/MM/YYYY' ) { |
|
91 | + if ( $form_fields[ $merge_tag ][ 'date_format' ] == 'DD/MM/YYYY' ) { |
|
92 | 92 | // convert '/' to '.' and to UNIX timestamp |
93 | 93 | $value = date( 'Y-m-d', strtotime( str_replace( '/', '.', $value ) ) ); |
94 | 94 | } else { |
@@ -96,22 +96,22 @@ discard block |
||
96 | 96 | $value = date( 'Y-m-d', strtotime( $value ) ); |
97 | 97 | } |
98 | 98 | } |
99 | - if( is_numeric( $merge_tag ) ) { // this is is an interest group! |
|
100 | - $merge_variables['groupings'][] = array( 'id' => $merge_tag , 'groups' => ( is_array( $value ) ) ? $value : array( $value ) ); |
|
99 | + if ( is_numeric( $merge_tag ) ) { // this is is an interest group! |
|
100 | + $merge_variables[ 'groupings' ][ ] = array( 'id' => $merge_tag, 'groups' => ( is_array( $value ) ) ? $value : array( $value ) ); |
|
101 | 101 | } else { // or else it's just a standard merge variable |
102 | - $merge_variables[$merge_tag] = $value; |
|
102 | + $merge_variables[ $merge_tag ] = $value; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | // store the opt-in time |
107 | -$merge_variables['optin_time'] = current_time( 'Y-m-d H:i:s', 1 ); |
|
107 | +$merge_variables[ 'optin_time' ] = current_time( 'Y-m-d H:i:s', 1 ); |
|
108 | 108 | |
109 | 109 | // Submit our form data |
110 | 110 | $api_key = yikes_get_mc_api_key(); |
111 | 111 | $dash_position = strpos( $api_key, '-' ); |
112 | 112 | |
113 | 113 | // setup the end point |
114 | -if( $dash_position !== false ) { |
|
114 | +if ( $dash_position !== false ) { |
|
115 | 115 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/subscribe.json'; |
116 | 116 | } |
117 | 117 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * Allow users to check for submit value |
138 | 138 | * and pass back an error to the user |
139 | 139 | */ |
140 | -if( isset( $merge_variables['error'] ) ) { |
|
140 | +if ( isset( $merge_variables[ 'error' ] ) ) { |
|
141 | 141 | // send our error response back |
142 | - wp_send_json_error( array( 'hide' => '0', 'error' => $merge_variables['error'] , 'response' => $merge_variables['message'] ) ); |
|
142 | + wp_send_json_error( array( 'hide' => '0', 'error' => $merge_variables[ 'error' ], 'response' => $merge_variables[ 'message' ] ) ); |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 | |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * Setup whether or not we should update the user, or display the error with email generation |
148 | 148 | * @since 6.1 |
149 | 149 | */ |
150 | -if ( isset( $optin_settings['update_existing_user'] ) && 1 === absint( $optin_settings['update_existing_user'] ) ) { |
|
150 | +if ( isset( $optin_settings[ 'update_existing_user' ] ) && 1 === absint( $optin_settings[ 'update_existing_user' ] ) ) { |
|
151 | 151 | // Should we send the update email |
152 | - if ( isset( $optin_settings['send_update_email'] ) && 1 === absint( $optin_settings['send_update_email'] ) ) { |
|
152 | + if ( isset( $optin_settings[ 'send_update_email' ] ) && 1 === absint( $optin_settings[ 'send_update_email' ] ) ) { |
|
153 | 153 | $update_existing_user = 0; |
154 | 154 | } else { |
155 | 155 | $update_existing_user = 1; |
@@ -164,38 +164,38 @@ discard block |
||
164 | 164 | 'body' => apply_filters( 'yikes-mailchimp-user-subscribe-api-request', array( |
165 | 165 | 'apikey' => $api_key, |
166 | 166 | 'id' => $list_id, |
167 | - 'email' => array( 'email' => sanitize_email( $data['EMAIL'] ) ), |
|
167 | + 'email' => array( 'email' => sanitize_email( $data[ 'EMAIL' ] ) ), |
|
168 | 168 | 'merge_vars' => $merge_variables, |
169 | - 'double_optin' => $optin_settings['optin'], |
|
169 | + 'double_optin' => $optin_settings[ 'optin' ], |
|
170 | 170 | 'update_existing' => $update_existing_user, // Decide if we should update the user or not |
171 | - 'send_welcome' => $optin_settings['send_welcome_email'], |
|
172 | - 'replace_interests' => ( isset( $submission_settings['replace_interests'] ) ) ? $submission_settings['replace_interests'] : 1, // defaults to replace |
|
173 | - ), $form, $list_id, $data['EMAIL'] ), |
|
171 | + 'send_welcome' => $optin_settings[ 'send_welcome_email' ], |
|
172 | + 'replace_interests' => ( isset( $submission_settings[ 'replace_interests' ] ) ) ? $submission_settings[ 'replace_interests' ] : 1, // defaults to replace |
|
173 | + ), $form, $list_id, $data[ 'EMAIL' ] ), |
|
174 | 174 | 'timeout' => 10, |
175 | 175 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
176 | 176 | ) ); |
177 | 177 | |
178 | 178 | $subscribe_response = json_decode( wp_remote_retrieve_body( $subscribe_response ), true ); |
179 | 179 | |
180 | - if( isset( $subscribe_response['error'] ) ) { |
|
180 | + if ( isset( $subscribe_response[ 'error' ] ) ) { |
|
181 | 181 | |
182 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
182 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
183 | 183 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
184 | 184 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
185 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribe_response['error'], __( "Subscribe New User" , 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission_ajax.php" ); |
|
185 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribe_response[ 'error' ], __( "Subscribe New User", 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission_ajax.php" ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $update_account_details_link = ''; |
189 | 189 | $error = 1; |
190 | - switch( $subscribe_response['code'] ) { |
|
190 | + switch ( $subscribe_response[ 'code' ] ) { |
|
191 | 191 | // user already subscribed |
192 | 192 | case '214': |
193 | - $custom_already_subscribed_text = apply_filters( 'yikes-easy-mailchimp-update-existing-subscriber-text', sprintf( __( ' To update your MailChimp profile, please %s.', 'yikes-inc-easy-mailchimp-extender' ), '<a class="send-update-email" data-list-id="' . $list_id . '" data-user-email="' . sanitize_email( $data['EMAIL'] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ), $form, '<a class="send-update-email" data-list-id="' . $_POST['yikes-mailchimp-associated-list-id'] . '" data-user-email="' . sanitize_email( $data['EMAIL'] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); |
|
194 | - $update_account_details_link = ( 1 === absint( $optin_settings['update_existing_user'] ) && 1 === absint( $optin_settings['send_update_email'] ) ) ? $custom_already_subscribed_text : false; |
|
195 | - if( ! empty( $error_messages['already-subscribed'] ) ) { |
|
196 | - $error_response = apply_filters( 'yikes-easy-mailchimp-user-already-subscribed-text', $error_messages['already-subscribed'] , $form, $data['EMAIL'] ) . ' ' . $update_account_details_link; |
|
193 | + $custom_already_subscribed_text = apply_filters( 'yikes-easy-mailchimp-update-existing-subscriber-text', sprintf( __( ' To update your MailChimp profile, please %s.', 'yikes-inc-easy-mailchimp-extender' ), '<a class="send-update-email" data-list-id="' . $list_id . '" data-user-email="' . sanitize_email( $data[ 'EMAIL' ] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ), $form, '<a class="send-update-email" data-list-id="' . $_POST[ 'yikes-mailchimp-associated-list-id' ] . '" data-user-email="' . sanitize_email( $data[ 'EMAIL' ] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); |
|
194 | + $update_account_details_link = ( 1 === absint( $optin_settings[ 'update_existing_user' ] ) && 1 === absint( $optin_settings[ 'send_update_email' ] ) ) ? $custom_already_subscribed_text : false; |
|
195 | + if ( ! empty( $error_messages[ 'already-subscribed' ] ) ) { |
|
196 | + $error_response = apply_filters( 'yikes-easy-mailchimp-user-already-subscribed-text', $error_messages[ 'already-subscribed' ], $form, $data[ 'EMAIL' ] ) . ' ' . $update_account_details_link; |
|
197 | 197 | } else { |
198 | - $error_response = $subscribe_response['error'] . ' ' . $update_account_details_link; |
|
198 | + $error_response = $subscribe_response[ 'error' ] . ' ' . $update_account_details_link; |
|
199 | 199 | } |
200 | 200 | break; |
201 | 201 | // missing a required field |
@@ -203,34 +203,34 @@ discard block |
||
203 | 203 | // get all merge variables in array, loop and str_replace error code with field name |
204 | 204 | $api_key = yikes_get_mc_api_key(); |
205 | 205 | $dash_position = strpos( $api_key, '-' ); |
206 | - if( $dash_position !== false ) { |
|
206 | + if ( $dash_position !== false ) { |
|
207 | 207 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/merge-vars.json'; |
208 | 208 | } |
209 | 209 | $merge_variables = wp_remote_post( $api_endpoint, array( |
210 | 210 | 'body' => array( |
211 | 211 | 'apikey' => $api_key, |
212 | - 'id' => array( $list_id ) , |
|
212 | + 'id' => array( $list_id ), |
|
213 | 213 | ), |
214 | 214 | 'timeout' => 10, |
215 | 215 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ), |
216 | 216 | ) ); |
217 | 217 | $merge_variables = json_decode( wp_remote_retrieve_body( $merge_variables ), true ); |
218 | - if( is_wp_error( $merge_variables ) || isset( $merge_variables['error'] ) ) { |
|
219 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
218 | + if ( is_wp_error( $merge_variables ) || isset( $merge_variables[ 'error' ] ) ) { |
|
219 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
220 | 220 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
221 | 221 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
222 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables['error'], __( "Get Merge Variables" , 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission_ajax.php" ); |
|
222 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables[ 'error' ], __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission_ajax.php" ); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | // re-store our data |
226 | - $merge_variables = $merge_variables['data'][0]['merge_vars']; |
|
226 | + $merge_variables = $merge_variables[ 'data' ][ 0 ][ 'merge_vars' ]; |
|
227 | 227 | $merge_variable_name_array = array(); |
228 | - foreach( $merge_variables as $merge_var ) { |
|
229 | - $merge_variables_name_array[$merge_var['tag']] = $merge_var['name']; |
|
228 | + foreach ( $merge_variables as $merge_var ) { |
|
229 | + $merge_variables_name_array[ $merge_var[ 'tag' ] ] = $merge_var[ 'name' ]; |
|
230 | 230 | } |
231 | - $error_message = $subscribe_response['error']; |
|
231 | + $error_message = $subscribe_response[ 'error' ]; |
|
232 | 232 | // replace tag with name in the error message. |
233 | - foreach( $merge_variables_name_array as $tag => $name ) { |
|
233 | + foreach ( $merge_variables_name_array as $tag => $name ) { |
|
234 | 234 | $error_message = str_replace( $tag, $name, $error_message ); |
235 | 235 | } |
236 | 236 | $error_response = $error_message; |
@@ -238,14 +238,14 @@ discard block |
||
238 | 238 | // [email protected] is not allowed |
239 | 239 | case '-99': |
240 | 240 | // generic error |
241 | - $error_response = str_replace( ' and cannot be imported', '', str_replace( 'List_RoleEmailMember:', '', $subscribe_response['error'] ) ); |
|
241 | + $error_response = str_replace( ' and cannot be imported', '', str_replace( 'List_RoleEmailMember:', '', $subscribe_response[ 'error' ] ) ); |
|
242 | 242 | break; |
243 | 243 | // invalid email (or no email at all) |
244 | 244 | case '-100': |
245 | - $error_response = ( ! empty( $error_messages['invalid-email'] ) ) ? $error_messages['invalid-email'] : __( 'Please provide a valid email address.', 'yikes-inc-easy-mailchimp-extender' ); |
|
245 | + $error_response = ( ! empty( $error_messages[ 'invalid-email' ] ) ) ? $error_messages[ 'invalid-email' ] : __( 'Please provide a valid email address.', 'yikes-inc-easy-mailchimp-extender' ); |
|
246 | 246 | break; |
247 | 247 | default: |
248 | - $error_response = ( ! empty( $error_messages['general-error'] ) ) ? $error_messages['general-error'] : $subscribe_response['error']; |
|
248 | + $error_response = ( ! empty( $error_messages[ 'general-error' ] ) ) ? $error_messages[ 'general-error' ] : $subscribe_response[ 'error' ]; |
|
249 | 249 | break; |
250 | 250 | } |
251 | 251 | // send the response |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | /* |
264 | 264 | * Successful form submission redirect |
265 | 265 | */ |
266 | - if( $submission_settings['redirect_on_submission'] == '1' ) { |
|
266 | + if ( $submission_settings[ 'redirect_on_submission' ] == '1' ) { |
|
267 | 267 | $redirection = '1'; |
268 | - $redirect_url = ( 'custom_url' != $submission_settings['redirect_page'] ) ? get_permalink( $submission_settings['redirect_page'] ) : $submission_settings['custom_redirect_url']; |
|
268 | + $redirect_url = ( 'custom_url' != $submission_settings[ 'redirect_page' ] ) ? get_permalink( $submission_settings[ 'redirect_page' ] ) : $submission_settings[ 'custom_redirect_url' ]; |
|
269 | 269 | $redirect = '<script type="text/javascript">setTimeout(function() { window.location="' . apply_filters( 'yikes-mailchimp-redirect-url', esc_url( $redirect_url ), $form, $page_data ) . '"; }, ' . apply_filters( 'yikes-mailchimp-redirect-timer', 1500 ) . ');</script>'; |
270 | 270 | } |
271 | 271 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | do_action( 'yikes-mailchimp-after-submission-' . $form, $merge_variables ); |
282 | 282 | |
283 | 283 | // send our notifications if setup (must go before wp_send_json()) |
284 | - do_action( 'yikes-mailchimp-form-submission' , sanitize_email( $data['EMAIL'] ), $merge_variables , $form , $notifications ); |
|
285 | - do_action( 'yikes-mailchimp-form-submission-' . $form, sanitize_email( $data['EMAIL'] ), $merge_variables , $form , $notifications ); |
|
284 | + do_action( 'yikes-mailchimp-form-submission', sanitize_email( $data[ 'EMAIL' ] ), $merge_variables, $form, $notifications ); |
|
285 | + do_action( 'yikes-mailchimp-form-submission-' . $form, sanitize_email( $data[ 'EMAIL' ] ), $merge_variables, $form, $notifications ); |
|
286 | 286 | |
287 | - $default_success_response = ( 1 === $optin_settings['optin'] ) ? __( "Thank you for subscribing! Check your email for the confirmation message." , 'yikes-inc-easy-mailchimp-extender' ) : __( "Thank you for subscribing!" , 'yikes-inc-easy-mailchimp-extender' ); |
|
287 | + $default_success_response = ( 1 === $optin_settings[ 'optin' ] ) ? __( "Thank you for subscribing! Check your email for the confirmation message.", 'yikes-inc-easy-mailchimp-extender' ) : __( "Thank you for subscribing!", 'yikes-inc-easy-mailchimp-extender' ); |
|
288 | 288 | |
289 | 289 | wp_send_json_success( |
290 | 290 | array( |
291 | - 'hide' => $submission_settings['hide_form_post_signup'], |
|
291 | + 'hide' => $submission_settings[ 'hide_form_post_signup' ], |
|
292 | 292 | 'error' => $error, |
293 | - 'response' => apply_filters( 'yikes-mailchimp-success-response', ( ! empty( $error_messages['success'] ) ? $error_messages['success'] : $default_success_response ), $form, $merge_variables ), |
|
293 | + 'response' => apply_filters( 'yikes-mailchimp-success-response', ( ! empty( $error_messages[ 'success' ] ) ? $error_messages[ 'success' ] : $default_success_response ), $form, $merge_variables ), |
|
294 | 294 | 'redirection' => isset( $redirection ) ? '1' : '0', |
295 | 295 | 'redirect' => isset( $redirect ) ? $redirect : '', |
296 | 296 | ) |
@@ -8,45 +8,45 @@ discard block |
||
8 | 8 | global $form_submitted, $process_submission_response; |
9 | 9 | |
10 | 10 | // confirm we have a form id to work with |
11 | -$form_id = ( ! empty( $_POST['yikes-mailchimp-submitted-form'] ) ) ? $_POST['yikes-mailchimp-submitted-form'] : false; |
|
12 | -if( ! $form_id ) { |
|
11 | +$form_id = ( ! empty( $_POST[ 'yikes-mailchimp-submitted-form' ] ) ) ? $_POST[ 'yikes-mailchimp-submitted-form' ] : false; |
|
12 | +if ( ! $form_id ) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | -$form_settings = Yikes_Inc_Easy_Mailchimp_Extender_Public::yikes_retrieve_form_settings( $_POST['yikes-mailchimp-submitted-form'] ); |
|
16 | +$form_settings = Yikes_Inc_Easy_Mailchimp_Extender_Public::yikes_retrieve_form_settings( $_POST[ 'yikes-mailchimp-submitted-form' ] ); |
|
17 | 17 | |
18 | 18 | // Process our form submissions (non ajax forms) |
19 | -if ( ! isset( $_POST['yikes_easy_mc_new_subscriber'] ) || ! wp_verify_nonce( $_POST['yikes_easy_mc_new_subscriber'], 'yikes_easy_mc_form_submit' ) ) { |
|
19 | +if ( ! isset( $_POST[ 'yikes_easy_mc_new_subscriber' ] ) || ! wp_verify_nonce( $_POST[ 'yikes_easy_mc_new_subscriber' ], 'yikes_easy_mc_form_submit' ) ) { |
|
20 | 20 | |
21 | - $process_submission_response = '<p><small class="form_submission_error">' . __( "Error : Sorry, the nonce security check didn't pass. Please reload the page and try again. You may want to try clearing your browser cache as a last attempt." , 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
21 | + $process_submission_response = '<p><small class="form_submission_error">' . __( "Error : Sorry, the nonce security check didn't pass. Please reload the page and try again. You may want to try clearing your browser cache as a last attempt.", 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
22 | 22 | return; |
23 | 23 | |
24 | 24 | } else { |
25 | 25 | |
26 | 26 | /* Check for Honeypot filled */ |
27 | - $honey_pot_filled = ( isset( $_POST['yikes-mailchimp-honeypot'] ) && $_POST['yikes-mailchimp-honeypot'] != '' ) ? true : false; |
|
27 | + $honey_pot_filled = ( isset( $_POST[ 'yikes-mailchimp-honeypot' ] ) && $_POST[ 'yikes-mailchimp-honeypot' ] != '' ) ? true : false; |
|
28 | 28 | // if it was filled out, return an error... |
29 | 29 | if ( $honey_pot_filled ) { |
30 | - $process_submission_response = '<p><small class="form_submission_error">' . __( "Error: It looks like the honeypot was filled out and the form was not properly be submitted." , 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
30 | + $process_submission_response = '<p><small class="form_submission_error">' . __( "Error: It looks like the honeypot was filled out and the form was not properly be submitted.", 'yikes-inc-easy-mailchimp-extender' ) . '</small></p>'; |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | 34 | // Check reCAPTCHA Response |
35 | - if( isset( $_POST['g-recaptcha-response'] ) ) { |
|
36 | - $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key' , '' ) . '&response=' . $_POST['g-recaptcha-response'] . '&remoteip=' . $_SERVER["REMOTE_ADDR"] ); |
|
35 | + if ( isset( $_POST[ 'g-recaptcha-response' ] ) ) { |
|
36 | + $url = esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify?secret=' . get_option( 'yikes-mc-recaptcha-secret-key', '' ) . '&response=' . $_POST[ 'g-recaptcha-response' ] . '&remoteip=' . $_SERVER[ "REMOTE_ADDR" ] ); |
|
37 | 37 | $response = wp_remote_get( $url ); |
38 | - $response_body = json_decode( $response['body'] , true ); |
|
38 | + $response_body = json_decode( $response[ 'body' ], true ); |
|
39 | 39 | |
40 | 40 | // if we've hit an error, lets return the error! |
41 | - if( $response_body['success'] != 1 ) { |
|
41 | + if ( $response_body[ 'success' ] != 1 ) { |
|
42 | 42 | $recaptcha_error = array(); // empty array to store error messages |
43 | - foreach( $response_body['error-codes'] as $error_code ) { |
|
44 | - if( $error_code == 'missing-input-response' ) { |
|
43 | + foreach ( $response_body[ 'error-codes' ] as $error_code ) { |
|
44 | + if ( $error_code == 'missing-input-response' ) { |
|
45 | 45 | $error_code = __( 'Please check the reCAPTCHA field.', 'yikes-inc-easy-mailchimp-extender' ); |
46 | 46 | } |
47 | - $recaptcha_error[] = $error_code; |
|
47 | + $recaptcha_error[ ] = $error_code; |
|
48 | 48 | } |
49 | - $process_submission_response .= "<p class='yikes-easy-mc-error-message'>" . apply_filters( 'yikes-mailchimp-recaptcha-required-error', __( 'Error' , 'yikes-inc-easy-mailchimp-extender' ) . ': ' . implode( ' ' , $recaptcha_error ) ) . "</p>"; |
|
49 | + $process_submission_response .= "<p class='yikes-easy-mc-error-message'>" . apply_filters( 'yikes-mailchimp-recaptcha-required-error', __( 'Error', 'yikes-inc-easy-mailchimp-extender' ) . ': ' . implode( ' ', $recaptcha_error ) ) . "</p>"; |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | } |
@@ -56,20 +56,20 @@ discard block |
||
56 | 56 | * No HTML5 validation, and don't want to use jQuery for non-ajax forms |
57 | 57 | */ |
58 | 58 | $missing_required_checkbox_interest_groups = array(); |
59 | - foreach( $form_settings['fields'] as $merge_tag => $field_data ) { |
|
60 | - if( is_numeric( $merge_tag ) ) { |
|
59 | + foreach ( $form_settings[ 'fields' ] as $merge_tag => $field_data ) { |
|
60 | + if ( is_numeric( $merge_tag ) ) { |
|
61 | 61 | // check if the checkbox group was set to required, if so return an error |
62 | - if( isset( $field_data['require'] ) && $field_data['require'] == 1 ) { |
|
63 | - if( $field_data['type'] == 'checkboxes' ) { |
|
64 | - if( ! isset( $_POST[$merge_tag] ) ) { |
|
65 | - $missing_required_checkbox_interest_groups[] = $merge_tag; |
|
62 | + if ( isset( $field_data[ 'require' ] ) && $field_data[ 'require' ] == 1 ) { |
|
63 | + if ( $field_data[ 'type' ] == 'checkboxes' ) { |
|
64 | + if ( ! isset( $_POST[ $merge_tag ] ) ) { |
|
65 | + $missing_required_checkbox_interest_groups[ ] = $merge_tag; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - if( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
72 | + if ( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
73 | 73 | $process_submission_response = '<p class="yikes-easy-mc-error-message">' . apply_filters( 'yikes-mailchimp-interest-group-required-top-error', sprintf( _n( 'It looks like you forgot to fill in a required field.', 'It looks like you forgot to fill in %s required fields.', count( $missing_required_checkbox_interest_groups ), 'yikes-inc-easy-mailchimp-extender' ), count( $missing_required_checkbox_interest_groups ) ), count( $missing_required_checkbox_interest_groups ), $form_id ) . '</p>'; |
74 | 74 | return; |
75 | 75 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | |
80 | 80 | // loop to push variables to our array |
81 | 81 | foreach ( $_POST as $merge_tag => $value ) { |
82 | - if( $merge_tag != 'yikes_easy_mc_new_subscriber' && $merge_tag != '_wp_http_referer' ) { |
|
82 | + if ( $merge_tag != 'yikes_easy_mc_new_subscriber' && $merge_tag != '_wp_http_referer' ) { |
|
83 | 83 | // check if the current iteration has a 'date_format' key set |
84 | 84 | // (aka - date/birthday fields) |
85 | - if( isset( $form_settings['fields'][$merge_tag]['date_format'] ) ) { |
|
85 | + if ( isset( $form_settings[ 'fields' ][ $merge_tag ][ 'date_format' ] ) ) { |
|
86 | 86 | // check if EU date format |
87 | - if( $form_settings['fields'][$merge_tag]['date_format'] == 'DD/MM/YYYY' ) { |
|
87 | + if ( $form_settings[ 'fields' ][ $merge_tag ][ 'date_format' ] == 'DD/MM/YYYY' ) { |
|
88 | 88 | // convert '/' to '.' and to UNIX timestamp |
89 | 89 | $value = ( '' != $value ) ? date( 'Y-m-d', strtotime( str_replace( '/', '.', $value ) ) ) : ''; |
90 | 90 | } else { |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | $value = ( '' != $value ) ? date( 'Y-m-d', strtotime( $value ) ) : ''; |
93 | 93 | } |
94 | 94 | } |
95 | - if( is_numeric( $merge_tag ) ) { // this is is an interest group! |
|
96 | - $merge_variables['groupings'][] = array( 'id' => $merge_tag , 'groups' => ( is_array( $value ) ) ? $value : array( $value ) ); |
|
95 | + if ( is_numeric( $merge_tag ) ) { // this is is an interest group! |
|
96 | + $merge_variables[ 'groupings' ][ ] = array( 'id' => $merge_tag, 'groups' => ( is_array( $value ) ) ? $value : array( $value ) ); |
|
97 | 97 | } else { // or else it's just a standard merge variable |
98 | - $merge_variables[$merge_tag] = $value; |
|
98 | + $merge_variables[ $merge_tag ] = $value; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | // store the opt-in time |
104 | - $merge_variables['optin_time'] = current_time( 'Y-m-d H:i:s', 1 ); |
|
104 | + $merge_variables[ 'optin_time' ] = current_time( 'Y-m-d H:i:s', 1 ); |
|
105 | 105 | |
106 | 106 | // Submit our form data |
107 | 107 | $api_key = yikes_get_mc_api_key(); |
108 | 108 | $dash_position = strpos( $api_key, '-' ); |
109 | 109 | |
110 | 110 | // setup the end point |
111 | - if( $dash_position !== false ) { |
|
111 | + if ( $dash_position !== false ) { |
|
112 | 112 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/subscribe.json'; |
113 | 113 | } |
114 | 114 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * Allow users to check for submit value |
137 | 137 | * and pass back an error to the user |
138 | 138 | */ |
139 | - if( isset( $merge_variables['error'] ) ) { |
|
140 | - $process_submission_response = apply_filters( 'yikes-mailchimp-frontend-content' , $merge_variables['message'] ); |
|
139 | + if ( isset( $merge_variables[ 'error' ] ) ) { |
|
140 | + $process_submission_response = apply_filters( 'yikes-mailchimp-frontend-content', $merge_variables[ 'message' ] ); |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | * Setup whether or not we should update the user, or display the error with email generation |
146 | 146 | * @since 6.1 |
147 | 147 | */ |
148 | - if ( isset( $form_settings['optin_settings']['update_existing_user'] ) && 1 === absint( $form_settings['optin_settings']['update_existing_user'] ) ) { |
|
148 | + if ( isset( $form_settings[ 'optin_settings' ][ 'update_existing_user' ] ) && 1 === absint( $form_settings[ 'optin_settings' ][ 'update_existing_user' ] ) ) { |
|
149 | 149 | $update_existing_user = 1; |
150 | 150 | // Should we send the update email |
151 | - if ( isset( $form_settings['optin_settings']['send_update_email'] ) && 1 === absint( $form_settings['optin_settings']['send_update_email'] ) ) { |
|
151 | + if ( isset( $form_settings[ 'optin_settings' ][ 'send_update_email' ] ) && 1 === absint( $form_settings[ 'optin_settings' ][ 'send_update_email' ] ) ) { |
|
152 | 152 | $update_existing_user = 0; |
153 | 153 | } |
154 | 154 | } else { |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | $subscribe_response = wp_remote_post( $api_endpoint, array( |
161 | 161 | 'body' => apply_filters( 'yikes-mailchimp-user-subscribe-api-request', array( |
162 | 162 | 'apikey' => $api_key, |
163 | - 'id' => $_POST['yikes-mailchimp-associated-list-id'], |
|
164 | - 'email' => array( 'email' => sanitize_email( $_POST['EMAIL'] ) ), |
|
163 | + 'id' => $_POST[ 'yikes-mailchimp-associated-list-id' ], |
|
164 | + 'email' => array( 'email' => sanitize_email( $_POST[ 'EMAIL' ] ) ), |
|
165 | 165 | 'merge_vars' => $merge_variables, |
166 | - 'double_optin' => $form_settings['optin_settings']['optin'], |
|
166 | + 'double_optin' => $form_settings[ 'optin_settings' ][ 'optin' ], |
|
167 | 167 | 'update_existing' => $update_existing_user, // Decide if we should update the user or not |
168 | - 'send_welcome' => $form_settings['optin_settings']['send_welcome_email'], |
|
169 | - 'replace_interests' => ( isset( $form_settings['submission_settings']['replace_interests'] ) ) ? $form_settings['submission_settings']['replace_interests'] : 1, // defaults to replace |
|
170 | - ), $form_id, $_POST['yikes-mailchimp-associated-list-id'], $_POST['EMAIL'] ), |
|
168 | + 'send_welcome' => $form_settings[ 'optin_settings' ][ 'send_welcome_email' ], |
|
169 | + 'replace_interests' => ( isset( $form_settings[ 'submission_settings' ][ 'replace_interests' ] ) ) ? $form_settings[ 'submission_settings' ][ 'replace_interests' ] : 1, // defaults to replace |
|
170 | + ), $form_id, $_POST[ 'yikes-mailchimp-associated-list-id' ], $_POST[ 'EMAIL' ] ), |
|
171 | 171 | 'timeout' => 10, |
172 | 172 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
173 | 173 | ) ); |
@@ -175,32 +175,32 @@ discard block |
||
175 | 175 | $subscribe_response = json_decode( wp_remote_retrieve_body( $subscribe_response ), true ); |
176 | 176 | |
177 | 177 | // check for any errors |
178 | - if( isset( $subscribe_response['error'] ) ) { |
|
178 | + if ( isset( $subscribe_response[ 'error' ] ) ) { |
|
179 | 179 | |
180 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
180 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
181 | 181 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
182 | 182 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
183 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribe_response['error'], __( "Subscribe New User" , 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
183 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribe_response[ 'error' ], __( "Subscribe New User", 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $update_account_details_link = ''; |
187 | - switch( $subscribe_response['code'] ) { |
|
187 | + switch ( $subscribe_response[ 'code' ] ) { |
|
188 | 188 | // user already subscribed |
189 | 189 | case '214': |
190 | - $custom_already_subscribed_text = apply_filters( 'yikes-easy-mailchimp-update-existing-subscriber-text', sprintf( __( ' To update your MailChimp profile, please %s.', 'yikes-inc-easy-mailchimp-extender' ), '<a class="send-update-email" data-list-id="' . $_POST['yikes-mailchimp-associated-list-id'] . '" data-user-email="' . sanitize_email( $_POST['EMAIL'] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ), $form_id, '<a class="send-update-email" data-list-id="' . $_POST['yikes-mailchimp-associated-list-id'] . '" data-user-email="' . sanitize_email( $_POST['EMAIL'] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); |
|
191 | - $update_account_details_link = ( 1 === absint( $form_settings['optin_settings']['update_existing_user'] ) && 1 === absint( $form_settings['optin_settings']['send_update_email'] ) ) ? $custom_already_subscribed_text : false; |
|
192 | - if( $update_account_details_link ) { |
|
190 | + $custom_already_subscribed_text = apply_filters( 'yikes-easy-mailchimp-update-existing-subscriber-text', sprintf( __( ' To update your MailChimp profile, please %s.', 'yikes-inc-easy-mailchimp-extender' ), '<a class="send-update-email" data-list-id="' . $_POST[ 'yikes-mailchimp-associated-list-id' ] . '" data-user-email="' . sanitize_email( $_POST[ 'EMAIL' ] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ), $form_id, '<a class="send-update-email" data-list-id="' . $_POST[ 'yikes-mailchimp-associated-list-id' ] . '" data-user-email="' . sanitize_email( $_POST[ 'EMAIL' ] ) . '" href="#">' . __( 'click to send yourself an update link', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); |
|
191 | + $update_account_details_link = ( 1 === absint( $form_settings[ 'optin_settings' ][ 'update_existing_user' ] ) && 1 === absint( $form_settings[ 'optin_settings' ][ 'send_update_email' ] ) ) ? $custom_already_subscribed_text : false; |
|
192 | + if ( $update_account_details_link ) { |
|
193 | 193 | // if update account details is set, we need to include our script to send out the update email |
194 | - wp_enqueue_script( 'update-existing-subscriber.js', YIKES_MC_URL . 'public/js/yikes-update-existing-subscriber.js' , array( 'jquery' ), 'all' ); |
|
194 | + wp_enqueue_script( 'update-existing-subscriber.js', YIKES_MC_URL . 'public/js/yikes-update-existing-subscriber.js', array( 'jquery' ), 'all' ); |
|
195 | 195 | wp_localize_script( 'update-existing-subscriber.js', 'update_subscriber_details_data', array( |
196 | 196 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
197 | 197 | 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) ), |
198 | 198 | ) ); |
199 | 199 | } |
200 | - if( ! empty( $form_settings['error_messages']['already-subscribed'] ) ) { |
|
201 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . apply_filters( 'yikes-easy-mailchimp-user-already-subscribed-text', $form_settings['error_messages']['already-subscribed'], $form_id, $_POST['EMAIL'] ) . ' ' . $update_account_details_link . '</p>'; |
|
200 | + if ( ! empty( $form_settings[ 'error_messages' ][ 'already-subscribed' ] ) ) { |
|
201 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . apply_filters( 'yikes-easy-mailchimp-user-already-subscribed-text', $form_settings[ 'error_messages' ][ 'already-subscribed' ], $form_id, $_POST[ 'EMAIL' ] ) . ' ' . $update_account_details_link . '</p>'; |
|
202 | 202 | } else { |
203 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response['error'] . ' ' . $update_account_details_link . '</p>'; |
|
203 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response[ 'error' ] . ' ' . $update_account_details_link . '</p>'; |
|
204 | 204 | } |
205 | 205 | break; |
206 | 206 | // missing a required field |
@@ -208,34 +208,34 @@ discard block |
||
208 | 208 | // get all merge variables in array, loop and str_replace error code with field name |
209 | 209 | $api_key = yikes_get_mc_api_key(); |
210 | 210 | $dash_position = strpos( $api_key, '-' ); |
211 | - if( $dash_position !== false ) { |
|
211 | + if ( $dash_position !== false ) { |
|
212 | 212 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/merge-vars.json'; |
213 | 213 | } |
214 | 214 | $merge_variables = wp_remote_post( $api_endpoint, array( |
215 | 215 | 'body' => array( |
216 | 216 | 'apikey' => $api_key, |
217 | - 'id' => array( $_POST['yikes-mailchimp-associated-list-id'] ) , |
|
217 | + 'id' => array( $_POST[ 'yikes-mailchimp-associated-list-id' ] ), |
|
218 | 218 | ), |
219 | 219 | 'timeout' => 10, |
220 | 220 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ), |
221 | 221 | ) ); |
222 | 222 | $merge_variables = json_decode( wp_remote_retrieve_body( $merge_variables ), true ); |
223 | - if( isset( $merge_variables['error'] ) ) { |
|
224 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
223 | + if ( isset( $merge_variables[ 'error' ] ) ) { |
|
224 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
225 | 225 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
226 | 226 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
227 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables['error'], __( "Get Merge Variables" , 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
227 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables[ 'error' ], __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), "process_form_submission.php" ); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | // re-store our data |
231 | - $merge_variables = $merge_variables['data'][0]['merge_vars']; |
|
231 | + $merge_variables = $merge_variables[ 'data' ][ 0 ][ 'merge_vars' ]; |
|
232 | 232 | $merge_variable_name_array = array(); |
233 | - foreach( $merge_variables as $merge_var ) { |
|
234 | - $merge_variables_name_array[$merge_var['tag']] = $merge_var['name']; |
|
233 | + foreach ( $merge_variables as $merge_var ) { |
|
234 | + $merge_variables_name_array[ $merge_var[ 'tag' ] ] = $merge_var[ 'name' ]; |
|
235 | 235 | } |
236 | - $error_message = $subscribe_response['error']; |
|
236 | + $error_message = $subscribe_response[ 'error' ]; |
|
237 | 237 | // replace tag with name in the error message. |
238 | - foreach( $merge_variables_name_array as $tag => $name ) { |
|
238 | + foreach ( $merge_variables_name_array as $tag => $name ) { |
|
239 | 239 | $error_message = str_replace( $tag, $name, $error_message ); |
240 | 240 | } |
241 | 241 | $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $error_message . '.</p>'; |
@@ -243,18 +243,18 @@ discard block |
||
243 | 243 | // [email protected] is not allowed |
244 | 244 | case '-99': |
245 | 245 | // generic error |
246 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . str_replace( ' and cannot be imported', '', str_replace( 'List_RoleEmailMember:', '', $subscribe_response['error'] ) ) . '</p>'; |
|
246 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . str_replace( ' and cannot be imported', '', str_replace( 'List_RoleEmailMember:', '', $subscribe_response[ 'error' ] ) ) . '</p>'; |
|
247 | 247 | break; |
248 | 248 | // invalid email (or no email at all) |
249 | 249 | case '-100': |
250 | - $process_submission_response = ( ! empty( $form_settings['error_messages']['invalid-email'] ) ) ? '<p class="yikes-easy-mc-error-message">' . $form_settings['error_messages']['invalid-email'] . '</p>' : '<p class="yikes-easy-mc-error-message">' . __( 'Please provide a valid email address.', 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
250 | + $process_submission_response = ( ! empty( $form_settings[ 'error_messages' ][ 'invalid-email' ] ) ) ? '<p class="yikes-easy-mc-error-message">' . $form_settings[ 'error_messages' ][ 'invalid-email' ] . '</p>' : '<p class="yikes-easy-mc-error-message">' . __( 'Please provide a valid email address.', 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
251 | 251 | break; |
252 | 252 | default: |
253 | 253 | // generic error |
254 | - if( ! empty( $form_settings['error_messages']['general-error'] ) ) { |
|
255 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $form_settings['error_messages']['general-error'] . '</p>'; |
|
254 | + if ( ! empty( $form_settings[ 'error_messages' ][ 'general-error' ] ) ) { |
|
255 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $form_settings[ 'error_messages' ][ 'general-error' ] . '</p>'; |
|
256 | 256 | } else { |
257 | - $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response['error'] . '</p>'; |
|
257 | + $process_submission_response = '<p class="yikes-easy-mc-error-message">' . $subscribe_response[ 'error' ] . '</p>'; |
|
258 | 258 | } |
259 | 259 | break; |
260 | 260 | } |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | $form_submitted = 1; |
266 | 266 | |
267 | 267 | // Display the success message |
268 | - if( ! empty( $form_settings['error_messages']['success'] ) ) { |
|
269 | - $process_submission_response = '<p class="yikes-easy-mc-success-message">' . apply_filters( 'yikes-mailchimp-success-response', stripslashes( esc_html( $form_settings['error_messages']['success'] ) ), $form_id, $merge_variables ) . '</p>'; |
|
268 | + if ( ! empty( $form_settings[ 'error_messages' ][ 'success' ] ) ) { |
|
269 | + $process_submission_response = '<p class="yikes-easy-mc-success-message">' . apply_filters( 'yikes-mailchimp-success-response', stripslashes( esc_html( $form_settings[ 'error_messages' ][ 'success' ] ) ), $form_id, $merge_variables ) . '</p>'; |
|
270 | 270 | // echo stripslashes( esc_html( $error_messages['success'] ) ); |
271 | 271 | } else { |
272 | - $default_success_response = ( 1 === $form_settings['optin_settings']['optin'] ) ? __( 'Thank you for subscribing! Check your email for the confirmation message.' , 'yikes-inc-easy-mailchimp-extender' ) : __( 'Thank you for subscribing!' , 'yikes-inc-easy-mailchimp-extender' ); |
|
272 | + $default_success_response = ( 1 === $form_settings[ 'optin_settings' ][ 'optin' ] ) ? __( 'Thank you for subscribing! Check your email for the confirmation message.', 'yikes-inc-easy-mailchimp-extender' ) : __( 'Thank you for subscribing!', 'yikes-inc-easy-mailchimp-extender' ); |
|
273 | 273 | $process_submission_response = '<p class="yikes-easy-mc-success-message">' . apply_filters( 'yikes-mailchimp-success-response', $default_success_response, $form_id, $merge_variables ) . '</p>'; |
274 | 274 | // echo $default_success_response; |
275 | 275 | } |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * optional @form - the ID of the form to filter |
283 | 283 | * @since 6.0.0 |
284 | 284 | */ |
285 | - do_action( 'yikes-mailchimp-after-submission' , $merge_variables ); |
|
286 | - do_action( 'yikes-mailchimp-after-submission-' . $form_id , $merge_variables ); |
|
285 | + do_action( 'yikes-mailchimp-after-submission', $merge_variables ); |
|
286 | + do_action( 'yikes-mailchimp-after-submission-' . $form_id, $merge_variables ); |
|
287 | 287 | |
288 | 288 | /* |
289 | 289 | * Non-AJAX redirects now handled in class-yikes-inc-easy-mailchimp-extender-public.php |
@@ -301,23 +301,23 @@ discard block |
||
301 | 301 | * @$notifications - the notification array |
302 | 302 | * @since 6.0.0 |
303 | 303 | */ |
304 | - do_action( 'yikes-mailchimp-form-submission' , $_POST['EMAIL'] , $merge_variables , $form_id , $form_settings['notifications'] ); |
|
305 | - do_action( 'yikes-mailchimp-form-submission-' . $form_id , $_POST['EMAIL'] , $merge_variables , $form_id , $form_settings['notifications'] ); |
|
304 | + do_action( 'yikes-mailchimp-form-submission', $_POST[ 'EMAIL' ], $merge_variables, $form_id, $form_settings[ 'notifications' ] ); |
|
305 | + do_action( 'yikes-mailchimp-form-submission-' . $form_id, $_POST[ 'EMAIL' ], $merge_variables, $form_id, $form_settings[ 'notifications' ] ); |
|
306 | 306 | |
307 | 307 | /* |
308 | 308 | * Increase the submission count for this form |
309 | 309 | * on a successful submission |
310 | 310 | * @since 6.0.0 |
311 | 311 | */ |
312 | - $form_settings['submissions']++; |
|
312 | + $form_settings[ 'submissions' ]++; |
|
313 | 313 | $wpdb->update( |
314 | 314 | $wpdb->prefix . 'yikes_easy_mc_forms', |
315 | 315 | array( |
316 | - 'submissions' => $form_settings['submissions'], |
|
316 | + 'submissions' => $form_settings[ 'submissions' ], |
|
317 | 317 | ), |
318 | 318 | array( 'ID' => $form_id ), |
319 | 319 | array( |
320 | - '%d', // send welcome email |
|
320 | + '%d', // send welcome email |
|
321 | 321 | ), |
322 | 322 | array( '%d' ) |
323 | 323 | ); |
@@ -12,42 +12,42 @@ discard block |
||
12 | 12 | array( |
13 | 13 | 'form' => '', // pass in a form, which will retreive the associated list ID -- takes precendence |
14 | 14 | 'list' => '', // pass in a specific list ID |
15 | - ), $attributes , 'yikes-mailchimp-subscriber-count' ) |
|
15 | + ), $attributes, 'yikes-mailchimp-subscriber-count' ) |
|
16 | 16 | ); |
17 | 17 | |
18 | 18 | /* If the user hasn't authenticated yet - bail */ |
19 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) != 'valid_api_key' ) { |
|
20 | - if( WP_DEBUG ) { |
|
19 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) != 'valid_api_key' ) { |
|
20 | + if ( WP_DEBUG ) { |
|
21 | 21 | return '<strong>' . __( "You don't appear to be connected to MailChimp.", "yikes-inc-easy-mailchimp-extender" ) . '</strong>'; |
22 | 22 | } |
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | - $form = ( ! empty( $attributes['form'] ) ) ? str_replace( '"', '', $attributes['form'] ) : false; // replace the sanitize quotes to perform a proper query |
|
27 | - $list_id = ( ! empty( $attributes['list'] ) ) ? $attributes['list'] : false; |
|
26 | + $form = ( ! empty( $attributes[ 'form' ] ) ) ? str_replace( '"', '', $attributes[ 'form' ] ) : false; // replace the sanitize quotes to perform a proper query |
|
27 | + $list_id = ( ! empty( $attributes[ 'list' ] ) ) ? $attributes[ 'list' ] : false; |
|
28 | 28 | |
29 | 29 | /* If no list ID was passed into the shortcode - bail */ |
30 | - if( ! $list_id && ! $form) { |
|
31 | - if( WP_DEBUG ) { |
|
30 | + if ( ! $list_id && ! $form ) { |
|
31 | + if ( WP_DEBUG ) { |
|
32 | 32 | return '<strong>' . __( 'You forgot to include the list or form ID.', 'yikes-inc-easy-mailchimp-extender' ) . '</strong>'; |
33 | 33 | } |
34 | 34 | return; |
35 | 35 | } |
36 | 36 | |
37 | 37 | /* if a form ID and a list ID were passed in, use the form ID */ |
38 | - if( ( $form ) || ( $form && $list_id ) ) { |
|
38 | + if ( ( $form ) || ( $form && $list_id ) ) { |
|
39 | 39 | global $wpdb; |
40 | 40 | // return it as an array, so we can work with it to build our form below |
41 | 41 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms WHERE id = ' . $form . '', ARRAY_A ); |
42 | 42 | // confirm we have some results, or return an error |
43 | - if( ! $form_results ) { |
|
44 | - if( WP_DEBUG ) { |
|
45 | - return __( "Oh no...This form doesn't exist. Head back to the manage forms page and select a different form." , 'yikes-inc-easy-mailchimp-extender' ); |
|
43 | + if ( ! $form_results ) { |
|
44 | + if ( WP_DEBUG ) { |
|
45 | + return __( "Oh no...This form doesn't exist. Head back to the manage forms page and select a different form.", 'yikes-inc-easy-mailchimp-extender' ); |
|
46 | 46 | } |
47 | 47 | return; |
48 | 48 | } |
49 | - $form_data = $form_results[0]; |
|
50 | - $list_id = sanitize_key( $form_data['list_id'] ); // associated list id (users who fill out the form will be subscribed to this list) |
|
49 | + $form_data = $form_results[ 0 ]; |
|
50 | + $list_id = sanitize_key( $form_data[ 'list_id' ] ); // associated list id (users who fill out the form will be subscribed to this list) |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // object buffer |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // get the api key |
60 | 60 | $api_key = yikes_get_mc_api_key(); |
61 | 61 | $dash_position = strpos( $api_key, '-' ); |
62 | - if( $dash_position !== false ) { |
|
62 | + if ( $dash_position !== false ) { |
|
63 | 63 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/list.json'; |
64 | 64 | } |
65 | 65 | |
@@ -76,23 +76,23 @@ discard block |
||
76 | 76 | ) ); |
77 | 77 | |
78 | 78 | $subscriber_count_response = json_decode( wp_remote_retrieve_body( $subscriber_count_response ), true ); |
79 | - if( isset( $subscriber_count_response['error'] ) ) { |
|
80 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
79 | + if ( isset( $subscriber_count_response[ 'error' ] ) ) { |
|
80 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
81 | 81 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
82 | 82 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
83 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_count_response['error'], __( "Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), "yikes-mailchimp-subscriber-count.php" ); |
|
83 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_count_response[ 'error' ], __( "Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), "yikes-mailchimp-subscriber-count.php" ); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | // if more than one list is returned, something went wrong - bail |
87 | - if( $subscriber_count_response['total'] != 1 ) { |
|
88 | - if( WP_DEBUG ) { |
|
87 | + if ( $subscriber_count_response[ 'total' ] != 1 ) { |
|
88 | + if ( WP_DEBUG ) { |
|
89 | 89 | return '<strong>' . sprintf( __( "It looks like this list wasn't found. Double check the list with with ID '%s' exists.", "yikes-inc-easy-mailchimp-extender" ), $list_id ) . '</strong>'; |
90 | 90 | } |
91 | 91 | return; |
92 | 92 | } |
93 | 93 | |
94 | 94 | /* type cast the returned value as an integer */ |
95 | - echo (int) apply_filters( 'yikes-mailchimp-subscriber-count-value', $subscriber_count_response['data'][0]['stats']['member_count'] ); |
|
95 | + echo (int) apply_filters( 'yikes-mailchimp-subscriber-count-value', $subscriber_count_response[ 'data' ][ 0 ][ 'stats' ][ 'member_count' ] ); |
|
96 | 96 | |
97 | 97 | } catch ( Exception $error ) { |
98 | 98 | echo $error->getMessage(); |
@@ -11,16 +11,16 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function __construct() { |
13 | 13 | // ajax process form submission |
14 | - add_action( 'wp_ajax_nopriv_process_form_submission', array( $this , 'process_form_submission' ), 10 ); |
|
15 | - add_action( 'wp_ajax_process_form_submission', array( $this , 'process_form_submission' ), 10 ); |
|
14 | + add_action( 'wp_ajax_nopriv_process_form_submission', array( $this, 'process_form_submission' ), 10 ); |
|
15 | + add_action( 'wp_ajax_process_form_submission', array( $this, 'process_form_submission' ), 10 ); |
|
16 | 16 | |
17 | 17 | // ajax send update emails |
18 | - add_action( 'wp_ajax_nopriv_easy_forms_send_email', array( $this , 'sendUpdateProfileEmail' ), 10 ); |
|
19 | - add_action( 'wp_ajax_easy_forms_send_email', array( $this , 'sendUpdateProfileEmail' ), 10 ); |
|
18 | + add_action( 'wp_ajax_nopriv_easy_forms_send_email', array( $this, 'sendUpdateProfileEmail' ), 10 ); |
|
19 | + add_action( 'wp_ajax_easy_forms_send_email', array( $this, 'sendUpdateProfileEmail' ), 10 ); |
|
20 | 20 | |
21 | 21 | // increase submission count for a given form on successful submit |
22 | - add_action( 'wp_ajax_nopriv_increase_submission_count' , array( $this , 'increase_submission_count' ), 10 ); |
|
23 | - add_action( 'wp_ajax_increase_submission_count' , array( $this , 'increase_submission_count' ), 10 ); |
|
22 | + add_action( 'wp_ajax_nopriv_increase_submission_count', array( $this, 'increase_submission_count' ), 10 ); |
|
23 | + add_action( 'wp_ajax_increase_submission_count', array( $this, 'increase_submission_count' ), 10 ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /* |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function increase_submission_count() { |
42 | 42 | // store our posted form ID |
43 | - $form_id = $_POST['form_id']; |
|
43 | + $form_id = $_POST[ 'form_id' ]; |
|
44 | 44 | global $wpdb; |
45 | 45 | // query the form |
46 | 46 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms WHERE id = ' . $form_id . '', ARRAY_A ); |
47 | - $form_data = $form_results[0]; |
|
47 | + $form_data = $form_results[ 0 ]; |
|
48 | 48 | // increase the submission |
49 | - $form_data['submissions']++; |
|
49 | + $form_data[ 'submissions' ]++; |
|
50 | 50 | // update the value in the database |
51 | 51 | $wpdb->update( |
52 | 52 | $wpdb->prefix . 'yikes_easy_mc_forms', |
53 | 53 | array( |
54 | - 'submissions' => $form_data['submissions'], |
|
54 | + 'submissions' => $form_data[ 'submissions' ], |
|
55 | 55 | ), |
56 | 56 | array( 'ID' => $form_id ), |
57 | 57 | array( |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | @since v6.0.4.1 |
69 | 69 | */ |
70 | 70 | public function sendUpdateProfileEmail() { |
71 | - $user_email = $_POST['user_email']; |
|
72 | - $list_id = $_POST['list_id']; |
|
71 | + $user_email = $_POST[ 'user_email' ]; |
|
72 | + $list_id = $_POST[ 'list_id' ]; |
|
73 | 73 | |
74 | 74 | $api_key = yikes_get_mc_api_key(); |
75 | 75 | $dash_position = strpos( $api_key, '-' ); |
76 | - $explode_key = explode( '-' , $api_key ); |
|
77 | - $data_center = $explode_key[1]; |
|
78 | - $full_site_url = get_bloginfo('url'); |
|
76 | + $explode_key = explode( '-', $api_key ); |
|
77 | + $data_center = $explode_key[ 1 ]; |
|
78 | + $full_site_url = get_bloginfo( 'url' ); |
|
79 | 79 | |
80 | 80 | // list details api call |
81 | - if( $dash_position !== false ) { |
|
81 | + if ( $dash_position !== false ) { |
|
82 | 82 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/list.json'; |
83 | 83 | } |
84 | 84 | $list_details = wp_remote_post( $api_endpoint, array( |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
93 | 93 | ) ); |
94 | 94 | $list_details = json_decode( wp_remote_retrieve_body( $list_details ), true ); |
95 | - if( isset( $list_details['error'] ) ) { |
|
96 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
95 | + if ( isset( $list_details[ 'error' ] ) ) { |
|
96 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
97 | 97 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
98 | 98 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
99 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_details['error'], __( "Send Update Profile Email - Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
99 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_details[ 'error' ], __( "Send Update Profile Email - Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | // account details api call |
104 | - if( $dash_position !== false ) { |
|
104 | + if ( $dash_position !== false ) { |
|
105 | 105 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/helper/account-details.json'; |
106 | 106 | } |
107 | 107 | $account_details = wp_remote_post( $api_endpoint, array( |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
113 | 113 | ) ); |
114 | 114 | $account_details = json_decode( wp_remote_retrieve_body( $account_details ), true ); |
115 | - if( isset( $account_details['error'] ) ) { |
|
116 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
115 | + if ( isset( $account_details[ 'error' ] ) ) { |
|
116 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
117 | 117 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
118 | 118 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
119 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $account_details['error'], __( "Send Update Profile Email - Get Account Details" , 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
119 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $account_details[ 'error' ], __( "Send Update Profile Email - Get Account Details", 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | 123 | // subscriber details api call |
124 | - if( $dash_position !== false ) { |
|
124 | + if ( $dash_position !== false ) { |
|
125 | 125 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/member-info.json'; |
126 | 126 | } |
127 | 127 | $subscriber_account_details = wp_remote_post( $api_endpoint, array( |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
137 | 137 | ) ); |
138 | 138 | $subscriber_account_details = json_decode( wp_remote_retrieve_body( $subscriber_account_details ), true ); |
139 | - if( isset( $subscriber_account_details['error'] ) ) { |
|
140 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
139 | + if ( isset( $subscriber_account_details[ 'error' ] ) ) { |
|
140 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
141 | 141 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
142 | 142 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
143 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_account_details['error'], __( "Send Update Profile Email - Get Member Info." , 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
143 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_account_details[ 'error' ], __( "Send Update Profile Email - Get Member Info.", 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | // check for errors in any of the calls |
148 | - if( isset( $list_details['error'] ) || isset( $account_details['error'] ) || isset( $subscriber_account_details['error'] ) ) { |
|
149 | - $error_message = ( isset( $list_details['error'] ) ) ? $list_details['error'] : false; |
|
150 | - if( ! $error_message ) { |
|
151 | - $error_message = ( isset( $account_details['error'] ) ) ? $account_details['error'] : false; |
|
152 | - if( ! $error_message ) { |
|
153 | - $error_message = ( isset( $subscriber_account_details['error'] ) ) ? $subscriber_account_details['error'] : false; |
|
154 | - if( ! $error_message ) { |
|
148 | + if ( isset( $list_details[ 'error' ] ) || isset( $account_details[ 'error' ] ) || isset( $subscriber_account_details[ 'error' ] ) ) { |
|
149 | + $error_message = ( isset( $list_details[ 'error' ] ) ) ? $list_details[ 'error' ] : false; |
|
150 | + if ( ! $error_message ) { |
|
151 | + $error_message = ( isset( $account_details[ 'error' ] ) ) ? $account_details[ 'error' ] : false; |
|
152 | + if ( ! $error_message ) { |
|
153 | + $error_message = ( isset( $subscriber_account_details[ 'error' ] ) ) ? $subscriber_account_details[ 'error' ] : false; |
|
154 | + if ( ! $error_message ) { |
|
155 | 155 | $error_message = ''; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | - $errorMessage = sprintf( __( 'Error sending update profile email. <strong>Error: %s</strong>. Please contact the site administrator.' , 'yikes-inc-easy-mailchimp-extender' ), $error_message ); |
|
159 | + $errorMessage = sprintf( __( 'Error sending update profile email. <strong>Error: %s</strong>. Please contact the site administrator.', 'yikes-inc-easy-mailchimp-extender' ), $error_message ); |
|
160 | 160 | wp_send_json_error( |
161 | 161 | array( |
162 | 162 | 'response_text' => '<div class="yikes-easy-mc-error-message">✕ ' . $errorMessage . '</div>', |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | // send the email! |
169 | - $subscriber_id = $subscriber_account_details['data'][0]['id']; |
|
170 | - $explode_url = explode( '.' , $account_details['contact']['url'] ); |
|
171 | - $update_link_href = 'http://' . $explode_url[1] . '.' . $data_center . '.list-manage1.com/profile?u=' . $account_details['user_id'] . '&id=' . $list_id .'&e=' . $subscriber_id; |
|
169 | + $subscriber_id = $subscriber_account_details[ 'data' ][ 0 ][ 'id' ]; |
|
170 | + $explode_url = explode( '.', $account_details[ 'contact' ][ 'url' ] ); |
|
171 | + $update_link_href = 'http://' . $explode_url[ 1 ] . '.' . $data_center . '.list-manage1.com/profile?u=' . $account_details[ 'user_id' ] . '&id=' . $list_id . '&e=' . $subscriber_id; |
|
172 | 172 | $subject = 'MailChimp Profile Update'; |
173 | - $headers = 'From: ' . $list_details['data'][0]['default_from_name'] . ' <' . $list_details['data'][0]['default_from_email'] . '>' . "\r\n"; |
|
173 | + $headers = 'From: ' . $list_details[ 'data' ][ 0 ][ 'default_from_name' ] . ' <' . $list_details[ 'data' ][ 0 ][ 'default_from_email' ] . '>' . "\r\n"; |
|
174 | 174 | $headers .= 'Content-type: text/html'; |
175 | 175 | $email_content = '<p>Greetings,</p> <p>A request has been made to update your MailChimp account profile information. To do so please use the following link: <a href="' . $update_link_href . '" title="Update MailChimp Profile">Update MailChimp Profile Info.</a>'; |
176 | 176 | $email_content .= "<p>If you did not request this update, please disregard this email.</p>"; |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | if ( wp_mail( $user_email, apply_filters( 'yikes-mailchimp-update-email-subject', $subject ), apply_filters( 'yikes-mailchimp-update-email-content', $email_content, $update_link_href ), $headers ) ) { |
184 | 184 | wp_send_json_success( |
185 | 185 | array( |
186 | - 'response_text' => '<div class="yikes-easy-mc-success-message">' . sprintf( __( '%s Update email successfully sent. Please check your inbox for the message.' , 'yikes-inc-easy-mailchimp-extender' ), '✔' ) . '</div>', |
|
186 | + 'response_text' => '<div class="yikes-easy-mc-success-message">' . sprintf( __( '%s Update email successfully sent. Please check your inbox for the message.', 'yikes-inc-easy-mailchimp-extender' ), '✔' ) . '</div>', |
|
187 | 187 | ) |
188 | 188 | ); |
189 | 189 | exit; |
190 | 190 | } else { |
191 | 191 | wp_send_json_error( |
192 | 192 | array( |
193 | - 'response_text' => '<div class="yikes-easy-mc-error-message">' . sprintf( __( '%s Email failed to send. Please contact the site administrator.' , 'yikes-inc-easy-mailchimp-extender' ), '✕' ) . '</div>', |
|
193 | + 'response_text' => '<div class="yikes-easy-mc-error-message">' . sprintf( __( '%s Email failed to send. Please contact the site administrator.', 'yikes-inc-easy-mailchimp-extender' ), '✕' ) . '</div>', |
|
194 | 194 | ) |
195 | 195 | ); |
196 | 196 | exit; |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | - * Get the checkbox for the given integration and render it on the front end |
|
106 | - * @return string |
|
107 | - * @since 6.0.0 |
|
108 | - */ |
|
105 | + * Get the checkbox for the given integration and render it on the front end |
|
106 | + * @return string |
|
107 | + * @since 6.0.0 |
|
108 | + */ |
|
109 | 109 | public function yikes_get_checkbox() { |
110 | 110 | // enqueue our checkbox styles whenever the checkbox is displayed |
111 | 111 | wp_enqueue_style( 'yikes-easy-mailchimp-checkbox-integration-styles', plugin_dir_url( __FILE__ ) . '../css/yikes-inc-easy-mailchimp-checkbox-integration.min.css' ); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * a new integration type is submitted |
136 | 136 | * |
137 | 137 | * @since 6.0.0 |
138 | - **/ |
|
138 | + **/ |
|
139 | 139 | public function subscribe_user_integration( $email, $type, $merge_vars ) { |
140 | 140 | // get checkbox data |
141 | 141 | $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
201 | - * Build merge varaibles array |
|
202 | - * @since 6.0.0 |
|
203 | - */ |
|
201 | + * Build merge varaibles array |
|
202 | + * @since 6.0.0 |
|
203 | + */ |
|
204 | 204 | public function user_merge_vars( WP_User $user ) { |
205 | 205 | // start with user_login as name, since that's always known |
206 | 206 | $merge_vars = array( |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | |
241 | 241 | |
242 | 242 | /** |
243 | - * Alter the registraton complete message |
|
244 | - * if the registration form checkbox integration is toggled on |
|
245 | - * @since 6.0.0 |
|
246 | - **/ |
|
243 | + * Alter the registraton complete message |
|
244 | + * if the registration form checkbox integration is toggled on |
|
245 | + * @since 6.0.0 |
|
246 | + **/ |
|
247 | 247 | public function yikes_reg_complete_msg( $errors, $redirect_to ) { |
248 | 248 | if( isset( $errors->errors['registered'] ) ) { |
249 | 249 | $email_error = get_option( 'yikes_register_subscription_error' , '' ); |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | unset( $tmp ); |
263 | 263 | delete_option( 'yikes_register_subscription_error' ); |
264 | 264 | } |
265 | - } |
|
266 | - return $errors; |
|
265 | + } |
|
266 | + return $errors; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Prevent direct access to the file |
8 | - defined('ABSPATH') or die( __( "Whoops, you shouldn't be accessing this file directly. Abort!" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
8 | + defined( 'ABSPATH' ) or die( __( "Whoops, you shouldn't be accessing this file directly. Abort!", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
9 | 9 | |
10 | 10 | class Yikes_Easy_MC_Checkbox_Integration_Class { |
11 | 11 | |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function is_user_already_subscribed( $integration_type ) { |
27 | 27 | // first check if the user is logged in |
28 | - if( is_user_logged_in() ) { |
|
29 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
28 | + if ( is_user_logged_in() ) { |
|
29 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
30 | 30 | $current_user = wp_get_current_user(); |
31 | 31 | $email = $current_user->user_email; |
32 | 32 | |
33 | 33 | $api_key = yikes_get_mc_api_key(); |
34 | 34 | $dash_position = strpos( $api_key, '-' ); |
35 | - if( $dash_position !== false ) { |
|
35 | + if ( $dash_position !== false ) { |
|
36 | 36 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/member-info.json'; |
37 | 37 | } |
38 | 38 | $already_subscribed = wp_remote_post( $api_endpoint, array( |
39 | 39 | 'body' => array( |
40 | 40 | 'apikey' => $api_key, |
41 | - 'id' => $checkbox_options[$integration_type]['associated-list'], |
|
41 | + 'id' => $checkbox_options[ $integration_type ][ 'associated-list' ], |
|
42 | 42 | 'emails' => array( array( 'email' => sanitize_email( $email ) ) ) |
43 | 43 | ), |
44 | 44 | 'timeout' => 10, |
45 | 45 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
46 | 46 | ) ); |
47 | 47 | $already_subscribed = json_decode( wp_remote_retrieve_body( $already_subscribed ), true ); |
48 | - if( isset( $already_subscribed['error'] ) ) { |
|
49 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
48 | + if ( isset( $already_subscribed[ 'error' ] ) ) { |
|
49 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
50 | 50 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
51 | 51 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
52 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed['error'], __( "Get Member Info" , 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
52 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed[ 'error' ], __( "Get Member Info", 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
53 | 53 | } |
54 | 54 | } |
55 | - if( ! Isset( $already_subscribed['error'] ) ) { |
|
56 | - return $already_subscribed['success_count']; |
|
55 | + if ( ! Isset( $already_subscribed[ 'error' ] ) ) { |
|
56 | + return $already_subscribed[ 'success_count' ]; |
|
57 | 57 | } |
58 | 58 | } else { |
59 | 59 | // if the user isn't logged in |
@@ -69,33 +69,33 @@ discard block |
||
69 | 69 | * @$email - users email address entered into the form |
70 | 70 | * @$integration_type - pass in the type of checkbox integration |
71 | 71 | */ |
72 | - public function is_new_registration_already_subscribed( $email , $integration_type ) { |
|
72 | + public function is_new_registration_already_subscribed( $email, $integration_type ) { |
|
73 | 73 | // first check if the user is logged in |
74 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
74 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
75 | 75 | try { |
76 | 76 | $api_key = yikes_get_mc_api_key(); |
77 | 77 | $dash_position = strpos( $api_key, '-' ); |
78 | - if( $dash_position !== false ) { |
|
78 | + if ( $dash_position !== false ) { |
|
79 | 79 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/member-info.json'; |
80 | 80 | } |
81 | 81 | $already_subscribed = wp_remote_post( $api_endpoint, array( |
82 | 82 | 'body' => array( |
83 | 83 | 'apikey' => $api_key, |
84 | - 'id' => $checkbox_options[$integration_type]['associated-list'], |
|
84 | + 'id' => $checkbox_options[ $integration_type ][ 'associated-list' ], |
|
85 | 85 | 'emails' => array( array( 'email' => sanitize_email( $email ) ) ) |
86 | 86 | ), |
87 | 87 | 'timeout' => 10, |
88 | 88 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
89 | 89 | ) ); |
90 | 90 | $already_subscribed = json_decode( wp_remote_retrieve_body( $already_subscribed ), true ); |
91 | - if( isset( $already_subscribed['error'] ) ) { |
|
92 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
91 | + if ( isset( $already_subscribed[ 'error' ] ) ) { |
|
92 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
93 | 93 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
94 | 94 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
95 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed['error'], __( "Get Member Info" , 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
95 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed[ 'error' ], __( "Get Member Info", 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
96 | 96 | } |
97 | 97 | } |
98 | - return $already_subscribed['success_count']; |
|
98 | + return $already_subscribed[ 'success_count' ]; |
|
99 | 99 | } catch ( Exception $error ) { |
100 | 100 | return $error->getMessage(); |
101 | 101 | } |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | // enqueue our checkbox styles whenever the checkbox is displayed |
111 | 111 | wp_enqueue_style( 'yikes-easy-mailchimp-checkbox-integration-styles', plugin_dir_url( __FILE__ ) . '../css/yikes-inc-easy-mailchimp-checkbox-integration.min.css' ); |
112 | 112 | // store our options |
113 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
114 | - if( isset( $checkbox_options[$this->type]['associated-list'] ) && $checkbox_options[$this->type]['associated-list'] != '-' ) { |
|
115 | - $checked = ( $checkbox_options[$this->type]['precheck'] == 'true' ) ? 'checked' : ''; |
|
113 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
114 | + if ( isset( $checkbox_options[ $this->type ][ 'associated-list' ] ) && $checkbox_options[ $this->type ][ 'associated-list' ] != '-' ) { |
|
115 | + $checked = ( $checkbox_options[ $this->type ][ 'precheck' ] == 'true' ) ? 'checked' : ''; |
|
116 | 116 | // before checkbox HTML (comment, ...) |
117 | 117 | $before = '<!-- Easy Forms for MailChimp by YIKES, Inc. - https://www.yikesinc.com/ -->'; |
118 | 118 | $before .= apply_filters( 'yikes-mailchimp-before-checkbox-html', '' ); |
119 | 119 | // checkbox |
120 | 120 | $content = '<p id="yikes-easy-mailchimp-' . $this->type . '-checkbox" class="yikes-easy-mailchimp-' . $this->type . '-checkbox">'; |
121 | 121 | $content .= '<label>'; |
122 | - $content .= '<input type="checkbox" name="yikes_mailchimp_checkbox_' . $this->type . '" value="1" '. $checked . ' /> '; |
|
123 | - $content .= ( isset( $checkbox_options[$this->type]['label'] ) && trim( $checkbox_options[$this->type]['label'] ) != '' ) ? trim( $checkbox_options[$this->type]['label'] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' ); |
|
122 | + $content .= '<input type="checkbox" name="yikes_mailchimp_checkbox_' . $this->type . '" value="1" ' . $checked . ' /> '; |
|
123 | + $content .= ( isset( $checkbox_options[ $this->type ][ 'label' ] ) && trim( $checkbox_options[ $this->type ][ 'label' ] ) != '' ) ? trim( $checkbox_options[ $this->type ][ 'label' ] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' ); |
|
124 | 124 | $content .= '</label>'; |
125 | 125 | $content .= '</p>'; |
126 | 126 | // after checkbox HTML (..., honeypot, closing comment) |
@@ -138,43 +138,43 @@ discard block |
||
138 | 138 | **/ |
139 | 139 | public function subscribe_user_integration( $email, $type, $merge_vars ) { |
140 | 140 | // get checkbox data |
141 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
142 | - if( $type != 'registration_form' ) { |
|
141 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
142 | + if ( $type != 'registration_form' ) { |
|
143 | 143 | $update = '1'; |
144 | 144 | } else { |
145 | 145 | $update = '0'; |
146 | 146 | } |
147 | 147 | // set ip address |
148 | - if( ! isset( $merge_vars['OPTIN_IP'] ) && isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
149 | - $merge_vars['OPTIN_IP'] = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
148 | + if ( ! isset( $merge_vars[ 'OPTIN_IP' ] ) && isset( $_SERVER[ 'REMOTE_ADDR' ] ) ) { |
|
149 | + $merge_vars[ 'OPTIN_IP' ] = sanitize_text_field( $_SERVER[ 'REMOTE_ADDR' ] ); |
|
150 | 150 | } |
151 | 151 | // set the optin time |
152 | - $merge_vars['OPTIN_TIME'] = current_time( 'Y-m-d H:i:s', 1 ); |
|
152 | + $merge_vars[ 'OPTIN_TIME' ] = current_time( 'Y-m-d H:i:s', 1 ); |
|
153 | 153 | // check for interest groups |
154 | - $interest_groups = ( isset( $checkbox_options[$type]['interest-groups'] ) ) ? $checkbox_options[$type]['interest-groups'] : false; |
|
154 | + $interest_groups = ( isset( $checkbox_options[ $type ][ 'interest-groups' ] ) ) ? $checkbox_options[ $type ][ 'interest-groups' ] : false; |
|
155 | 155 | // if interest groups were found, push them to the merge variable array |
156 | - if( $interest_groups ) { |
|
157 | - $merge_vars['groupings'] = array(); |
|
158 | - foreach( $interest_groups as $interest_group_id => $interest_group_selections ) { |
|
156 | + if ( $interest_groups ) { |
|
157 | + $merge_vars[ 'groupings' ] = array(); |
|
158 | + foreach ( $interest_groups as $interest_group_id => $interest_group_selections ) { |
|
159 | 159 | // merge variable interest groups array |
160 | - $merge_vars['groupings'][] = array( |
|
160 | + $merge_vars[ 'groupings' ][ ] = array( |
|
161 | 161 | 'id' => $interest_group_id, |
162 | 162 | 'groups' => $interest_group_selections, |
163 | 163 | ); |
164 | 164 | } |
165 | 165 | // replace the interest groups - to avoid any errors thrown if the admin switches lists, or interest groups |
166 | - $merge_vars['replace_interests'] = 1; |
|
166 | + $merge_vars[ 'replace_interests' ] = 1; |
|
167 | 167 | } |
168 | 168 | // initialize MailChimp API |
169 | 169 | $api_key = yikes_get_mc_api_key(); |
170 | 170 | $dash_position = strpos( $api_key, '-' ); |
171 | - if( $dash_position !== false ) { |
|
171 | + if ( $dash_position !== false ) { |
|
172 | 172 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/subscribe.json'; |
173 | 173 | } |
174 | 174 | $subscribe_response = wp_remote_post( $api_endpoint, array( |
175 | 175 | 'body' => apply_filters( 'yikes-mailchimp-checkbox-integration-subscribe-api-request', array( |
176 | 176 | 'apikey' => yikes_get_mc_api_key(), |
177 | - 'id' => $checkbox_options[$type]['associated-list'], |
|
177 | + 'id' => $checkbox_options[ $type ][ 'associated-list' ], |
|
178 | 178 | 'email' => array( 'email' => sanitize_email( $email ) ), |
179 | 179 | 'merge_vars' => apply_filters( 'yikes-mailchimp-checkbox-integration-merge-variables', $merge_vars, $type ), // filter merge variables |
180 | 180 | 'double_optin' => 1, |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | 'timeout' => 10, |
185 | 185 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
186 | 186 | ) ); |
187 | - if( ! Is_wp_error( $subscribe_response ) ) { |
|
187 | + if ( ! Is_wp_error( $subscribe_response ) ) { |
|
188 | 188 | $response_body = json_decode( wp_remote_retrieve_body( $subscribe_response ), true ); |
189 | - if( WP_DEBUG || isset( $response_body['error'] ) ) { |
|
190 | - if( get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
189 | + if ( WP_DEBUG || isset( $response_body[ 'error' ] ) ) { |
|
190 | + if ( get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
191 | 191 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
192 | 192 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
193 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $response_body['error'], __( "Checkbox Integration Subscribe User" , 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations" ); |
|
193 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $response_body[ 'error' ], __( "Checkbox Integration Subscribe User", 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations" ); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | $merge_vars = array( |
207 | 207 | 'NAME' => $user->user_login, |
208 | 208 | ); |
209 | - if( '' !== $user->first_name ) { |
|
210 | - $merge_vars['NAME'] = $user->first_name; |
|
211 | - $merge_vars['FNAME'] = $user->first_name; |
|
209 | + if ( '' !== $user->first_name ) { |
|
210 | + $merge_vars[ 'NAME' ] = $user->first_name; |
|
211 | + $merge_vars[ 'FNAME' ] = $user->first_name; |
|
212 | 212 | } |
213 | - if( '' !== $user->last_name ) { |
|
214 | - $merge_vars['LNAME'] = $user->last_name; |
|
213 | + if ( '' !== $user->last_name ) { |
|
214 | + $merge_vars[ 'LNAME' ] = $user->last_name; |
|
215 | 215 | } |
216 | - if( '' !== $user->first_name && '' !== $user->last_name ) { |
|
217 | - $merge_vars['NAME'] = sprintf( '%s %s', $user->first_name, $user->last_name ); |
|
216 | + if ( '' !== $user->first_name && '' !== $user->last_name ) { |
|
217 | + $merge_vars[ 'NAME' ] = sprintf( '%s %s', $user->first_name, $user->last_name ); |
|
218 | 218 | } |
219 | 219 | /** |
220 | 220 | * @filter `yikes-mailchimp-user-merge-vars` |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function was_checkbox_checked( $type ) { |
237 | 237 | // was sign-up checkbox checked - return the value |
238 | - return ( isset( $_POST[ 'yikes_mailchimp_checkbox_'.$type ] ) && $_POST[ 'yikes_mailchimp_checkbox_'.$type ] == 1 ); |
|
238 | + return ( isset( $_POST[ 'yikes_mailchimp_checkbox_' . $type ] ) && $_POST[ 'yikes_mailchimp_checkbox_' . $type ] == 1 ); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | * @since 6.0.0 |
246 | 246 | **/ |
247 | 247 | public function yikes_reg_complete_msg( $errors, $redirect_to ) { |
248 | - if( isset( $errors->errors['registered'] ) ) { |
|
249 | - $email_error = get_option( 'yikes_register_subscription_error' , '' ); |
|
250 | - if( isset( $email_error ) && $email_error != '' ) { |
|
248 | + if ( isset( $errors->errors[ 'registered' ] ) ) { |
|
249 | + $email_error = get_option( 'yikes_register_subscription_error', '' ); |
|
250 | + if ( isset( $email_error ) && $email_error != '' ) { |
|
251 | 251 | // Use the magic __get method to retrieve the errors array: |
252 | 252 | $tmp = $errors->errors; |
253 | 253 | $old = 'Registration complete. Please check your e-mail.'; |
254 | - foreach( $tmp['registered'] as $index => $msg ) { |
|
255 | - if( $msg === $old ) { |
|
256 | - $tmp['registered'][$index] = $old . ' <p class="message"><strong>' . __( 'Note' , 'yikes-inc-easy-mailchimp-extender' ) . '</strong>: ' . $email_error . '</p>'; |
|
254 | + foreach ( $tmp[ 'registered' ] as $index => $msg ) { |
|
255 | + if ( $msg === $old ) { |
|
256 | + $tmp[ 'registered' ][ $index ] = $old . ' <p class="message"><strong>' . __( 'Note', 'yikes-inc-easy-mailchimp-extender' ) . '</strong>: ' . $email_error . '</p>'; |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | // Use the magic __set method to override the errors property: |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | $this->yikes_inc_easy_mailchimp_extender = $yikes_inc_easy_mailchimp_extender; |
39 | 39 | $this->version = $version; |
40 | 40 | // check for old plugin options and migrate if exist |
41 | - add_action( 'admin_menu' , array( $this , 'register_admin_pages' ) , 11 ); |
|
41 | + add_action( 'admin_menu', array( $this, 'register_admin_pages' ), 11 ); |
|
42 | 42 | // check for old plugin options and migrate if exist |
43 | - add_action( 'admin_init' , array( $this , 'check_for_old_yks_mc_options' ) ); |
|
43 | + add_action( 'admin_init', array( $this, 'check_for_old_yks_mc_options' ) ); |
|
44 | 44 | // Ajax function to update new options... |
45 | - add_action( 'wp_ajax_migrate_old_plugin_settings', array( $this , 'migrate_archived_options' ) ); |
|
45 | + add_action( 'wp_ajax_migrate_old_plugin_settings', array( $this, 'migrate_archived_options' ) ); |
|
46 | 46 | // Ajax function to migrate our forms |
47 | - add_action( 'wp_ajax_migrate_prevoious_forms', array( $this , 'migrate_previously_setup_forms' ) ); |
|
47 | + add_action( 'wp_ajax_migrate_prevoious_forms', array( $this, 'migrate_previously_setup_forms' ) ); |
|
48 | 48 | // fix menu icon spacing |
49 | - add_action( 'admin_head' , array( $this , 'fix_menu_icon_spacing' ) ); |
|
49 | + add_action( 'admin_head', array( $this, 'fix_menu_icon_spacing' ) ); |
|
50 | 50 | // register our plugin settings |
51 | - add_action( 'admin_init', array( $this , 'yikes_easy_mc_settings_init' ) ); |
|
51 | + add_action( 'admin_init', array( $this, 'yikes_easy_mc_settings_init' ) ); |
|
52 | 52 | // plugin redirect on activation |
53 | - add_action( 'admin_init' , array( $this , 'yikes_easy_mc_activation_redirect' ) ); |
|
53 | + add_action( 'admin_init', array( $this, 'yikes_easy_mc_activation_redirect' ) ); |
|
54 | 54 | // Include Third Party Extensions |
55 | 55 | include_once( YIKES_MC_PATH . 'includes/third-party-integrations/third-party-init.php' ); |
56 | 56 | // Include our dashboard widget class |
@@ -60,111 +60,111 @@ discard block |
||
60 | 60 | // Include our ajax processing class |
61 | 61 | include_once( YIKES_MC_PATH . 'admin/partials/ajax/class.ajax.php' ); |
62 | 62 | // load up our helper class |
63 | - add_action( 'admin_init' , array( $this , 'yikes_mailchimp_load_helper_class' ) ); |
|
63 | + add_action( 'admin_init', array( $this, 'yikes_mailchimp_load_helper_class' ) ); |
|
64 | 64 | // process the subscriber count shortcode in form descriptions |
65 | 65 | add_action( 'yikes-mailchimp-form-description', array( $this, 'process_subscriber_count_shortcode_in_form_descriptions' ), 10, 2 ); |
66 | 66 | /***********************/ |
67 | 67 | /** Create A Form **/ |
68 | 68 | /**********************/ |
69 | 69 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-create-form' ) { |
70 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_create_form' ) ); |
|
70 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_create_form' ) ); |
|
71 | 71 | } |
72 | 72 | /***********************/ |
73 | 73 | /** Delete A Form **/ |
74 | 74 | /**********************/ |
75 | 75 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-delete-form' ) { |
76 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_delete_form' ) ); |
|
76 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_delete_form' ) ); |
|
77 | 77 | } |
78 | 78 | /**********************************/ |
79 | 79 | /** Duplicate/Clone A Form **/ |
80 | 80 | /********************************/ |
81 | 81 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-duplicate-form' ) { |
82 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_duplicate_form' ) ); |
|
82 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_duplicate_form' ) ); |
|
83 | 83 | } |
84 | 84 | /*************************************/ |
85 | 85 | /** Reset Form Impression Stats **/ |
86 | 86 | /***********************************/ |
87 | 87 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-reset-stats' ) { |
88 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_reset_impression_stats' ) ); |
|
88 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_reset_impression_stats' ) ); |
|
89 | 89 | } |
90 | 90 | /**********************************/ |
91 | 91 | /** Update A Form **/ |
92 | 92 | /********************************/ |
93 | 93 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-update-form' ) { |
94 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_update_form' ) ); |
|
94 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_update_form' ) ); |
|
95 | 95 | } |
96 | 96 | /**************************************************/ |
97 | 97 | /** Clear Store MailChimp Transient Data **/ |
98 | 98 | /*************************************************/ |
99 | 99 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-clear-transient-data' ) { |
100 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_clear_transient_data' ) ); |
|
100 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_clear_transient_data' ) ); |
|
101 | 101 | } |
102 | 102 | /*******************************************/ |
103 | 103 | /** Remove a user from a mailing list **/ |
104 | 104 | /*****************************************/ |
105 | 105 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-unsubscribe-user' ) { |
106 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_unsubscribe_user' ) ); |
|
106 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_unsubscribe_user' ) ); |
|
107 | 107 | } |
108 | 108 | /*******************************************/ |
109 | 109 | /** Create misisng error log file **/ |
110 | 110 | /*****************************************/ |
111 | 111 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-create-error-log' ) { |
112 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_create_missing_error_log' ) ); |
|
112 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_create_missing_error_log' ) ); |
|
113 | 113 | } |
114 | 114 | /*******************************************/ |
115 | 115 | /** TinyMCE Initialization Functions **/ |
116 | 116 | /*****************************************/ |
117 | - add_action( 'admin_head' , array( $this, 'add_tinyMCE_buttons' ) ); |
|
117 | + add_action( 'admin_head', array( $this, 'add_tinyMCE_buttons' ) ); |
|
118 | 118 | // pass our lists data to tinyMCE button for use |
119 | - foreach ( array('post.php','post-new.php') as $hook ) { |
|
119 | + foreach ( array( 'post.php', 'post-new.php' ) as $hook ) { |
|
120 | 120 | add_action( "admin_head-$hook", array( $this, 'tinymce_yikes_easy_mc' ) ); |
121 | 121 | } |
122 | 122 | // display an admin notice for users on PHP < 5.3 |
123 | - if( phpversion() < '5.3' ) { |
|
123 | + if ( phpversion() < '5.3' ) { |
|
124 | 124 | add_action( "admin_notices", array( $this, 'display_php_warning' ), 999 ); |
125 | 125 | } |
126 | 126 | // two week , dismissable notification - check the users plugin installation date |
127 | - add_action( 'admin_init', array( $this , 'yikes_easy_mailchimp_check_installation_date' ) ); |
|
127 | + add_action( 'admin_init', array( $this, 'yikes_easy_mailchimp_check_installation_date' ) ); |
|
128 | 128 | // dismissable notice admin side |
129 | - add_action( 'admin_init', array( $this , 'yikes_easy_mailchimp_stop_bugging_me' ), 5 ); |
|
129 | + add_action( 'admin_init', array( $this, 'yikes_easy_mailchimp_stop_bugging_me' ), 5 ); |
|
130 | 130 | /**************************************************/ |
131 | 131 | /** Clear MailChimp Error Log Data **/ |
132 | 132 | /*************************************************/ |
133 | 133 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-clear-error-log' ) { |
134 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_clear_error_log' ) ); |
|
134 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_clear_error_log' ) ); |
|
135 | 135 | } |
136 | 136 | /*********************************************/ |
137 | 137 | /** Export MailChimp Opt-in Forms **/ |
138 | 138 | /*******************************************/ |
139 | 139 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-export-forms' ) { |
140 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_export_forms' ) ); |
|
140 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_export_forms' ) ); |
|
141 | 141 | } |
142 | 142 | /*********************************************/ |
143 | 143 | /** Export Plugin Settings **/ |
144 | 144 | /*******************************************/ |
145 | 145 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-export-settings' ) { |
146 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_export_plugin_settings' ) ); |
|
146 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_export_plugin_settings' ) ); |
|
147 | 147 | } |
148 | 148 | /*******************************************/ |
149 | 149 | /** Import Class Inclusion **/ |
150 | 150 | /*****************************************/ |
151 | 151 | if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-import-forms' ) { |
152 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_import_forms' ) ); |
|
152 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_import_forms' ) ); |
|
153 | 153 | } |
154 | 154 | /*******************************************/ |
155 | 155 | /** Premium Support Request **/ |
156 | 156 | /*****************************************/ |
157 | 157 | if ( isset( $_POST[ 'submit-premium-support-request' ] ) ) { |
158 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_premium_support_request' ) ); |
|
158 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_premium_support_request' ) ); |
|
159 | 159 | } |
160 | 160 | /****************************************/ |
161 | 161 | /** Dismiss Options Migrations **/ |
162 | 162 | /****************************************/ |
163 | - if( isset( $_REQUEST['dismiss_migration_nonce'] ) ) { |
|
164 | - add_action( 'init' , array( $this , 'yikes_easy_mailchimp_dismiss_option_migrate' ) ); |
|
163 | + if ( isset( $_REQUEST[ 'dismiss_migration_nonce' ] ) ) { |
|
164 | + add_action( 'init', array( $this, 'yikes_easy_mailchimp_dismiss_option_migrate' ) ); |
|
165 | 165 | } |
166 | 166 | /** Parse default value into usable dynamic data **/ |
167 | - add_filter( 'yikes-mailchimp-process-default-tag' , array( $this , 'parse_mailchimp_default_tag' ) ); |
|
167 | + add_filter( 'yikes-mailchimp-process-default-tag', array( $this, 'parse_mailchimp_default_tag' ) ); |
|
168 | 168 | /** Add a disclaimer to ensure that we let people know we are not endorsed/backed by MailChimp at all **/ |
169 | 169 | add_filter( 'admin_footer_text', array( $this, 'yikes_easy_forms_admin_disclaimer' ) ); |
170 | 170 | /** Add custom plugin action links **/ |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @ return array $links New array of plugin actions |
185 | 185 | */ |
186 | 186 | public function easy_forms_plugin_action_links( $links ) { |
187 | - $links[] = '<a href="'. esc_url( get_admin_url(null, 'admin.php?page=yikes-inc-easy-mailchimp-settings') ) .'">' . __( 'Settings', 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
188 | - $links[] = '<a href="' . esc_url( 'http://www.yikesplugins.com?utm_source=plugins-page&utm_medium=plugin-row&utm_campaign=admin' ) . '" target="_blank">' . __( 'More plugins by YIKES' , 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
187 | + $links[ ] = '<a href="' . esc_url( get_admin_url( null, 'admin.php?page=yikes-inc-easy-mailchimp-settings' ) ) . '">' . __( 'Settings', 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
188 | + $links[ ] = '<a href="' . esc_url( 'http://www.yikesplugins.com?utm_source=plugins-page&utm_medium=plugin-row&utm_campaign=admin' ) . '" target="_blank">' . __( 'More plugins by YIKES', 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
189 | 189 | return $links; |
190 | 190 | } |
191 | 191 | |
@@ -218,29 +218,29 @@ discard block |
||
218 | 218 | * @return parsed tag content |
219 | 219 | */ |
220 | 220 | public function parse_mailchimp_default_tag( $default_tag ) { |
221 | - if( ! $default_tag || $default_tag == '' ) { |
|
221 | + if ( ! $default_tag || $default_tag == '' ) { |
|
222 | 222 | return $default_tag; |
223 | 223 | } |
224 | 224 | global $post; |
225 | 225 | // page title |
226 | - if( $default_tag == '{page_title}' ) { |
|
226 | + if ( $default_tag == '{page_title}' ) { |
|
227 | 227 | $default_tag = get_the_title( $post->ID ); |
228 | 228 | } |
229 | 229 | // page id |
230 | - if( $default_tag == '{page_title}' ) { |
|
230 | + if ( $default_tag == '{page_title}' ) { |
|
231 | 231 | $default_tag = $post->ID; |
232 | 232 | } |
233 | 233 | // page url |
234 | - if( $default_tag == '{page_url}' ) { |
|
234 | + if ( $default_tag == '{page_url}' ) { |
|
235 | 235 | $default_tag = get_permalink( $post->ID ); |
236 | 236 | } |
237 | 237 | // blog name |
238 | - if( $default_tag == '{blog_name}' ) { |
|
238 | + if ( $default_tag == '{blog_name}' ) { |
|
239 | 239 | $default_tag = get_bloginfo( 'name' ); |
240 | 240 | } |
241 | 241 | // is user logged in |
242 | - if( $default_tag == '{user_logged_in}' ) { |
|
243 | - if( is_user_logged_in() ) { |
|
242 | + if ( $default_tag == '{user_logged_in}' ) { |
|
243 | + if ( is_user_logged_in() ) { |
|
244 | 244 | $default_tag = 'Registered User'; |
245 | 245 | } else { |
246 | 246 | $default_tag = 'Guest User'; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function yikes_easy_mailchimp_clear_error_log() { |
260 | 260 | // file put contents $returned error + other data |
261 | - if( file_exists( YIKES_MC_PATH . 'includes/error_log/yikes-easy-mailchimp-error-log.php' ) ) { |
|
261 | + if ( file_exists( YIKES_MC_PATH . 'includes/error_log/yikes-easy-mailchimp-error-log.php' ) ) { |
|
262 | 262 | $clear_log = file_put_contents( |
263 | 263 | YIKES_MC_PATH . 'includes/error_log/yikes-easy-mailchimp-error-log.php', |
264 | 264 | '' |
265 | 265 | ); |
266 | - if( $clear_log === false ) { |
|
266 | + if ( $clear_log === false ) { |
|
267 | 267 | // redirect the user to the manage forms page, display error message |
268 | 268 | wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=debug-settings&error-log-cleared=false' ) ) ); |
269 | 269 | } else { |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function yikes_easy_mailchimp_export_forms() { |
283 | 283 | // grab our nonce |
284 | - $nonce = $_REQUEST['nonce']; |
|
284 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
285 | 285 | // grab the forms |
286 | - $forms = isset( $_REQUEST['export_forms'] ) ? $_REQUEST['export_forms'] : 'all'; |
|
286 | + $forms = isset( $_REQUEST[ 'export_forms' ] ) ? $_REQUEST[ 'export_forms' ] : 'all'; |
|
287 | 287 | // validate nonce |
288 | - if( ! wp_verify_nonce( $nonce, 'export-forms' ) ) { |
|
289 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
288 | + if ( ! wp_verify_nonce( $nonce, 'export-forms' ) ) { |
|
289 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
290 | 290 | } |
291 | 291 | // include the export class |
292 | - if( ! class_exists( 'Yikes_Inc_Easy_MailChimp_Export_Class' ) ) { |
|
292 | + if ( ! class_exists( 'Yikes_Inc_Easy_MailChimp_Export_Class' ) ) { |
|
293 | 293 | include_once( YIKES_MC_PATH . 'includes/import-export/yikes-easy-mailchimp-export.class.php' ); |
294 | 294 | } |
295 | 295 | // run the export function |
296 | 296 | // parameters: ( $table_name, $form_ids, $file_name ) |
297 | - Yikes_Inc_Easy_MailChimp_Export_Class::yikes_mailchimp_form_export( 'yikes_easy_mc_forms' , $forms, 'Yikes-Inc-Easy-MailChimp-Forms-Export' ); |
|
297 | + Yikes_Inc_Easy_MailChimp_Export_Class::yikes_mailchimp_form_export( 'yikes_easy_mc_forms', $forms, 'Yikes-Inc-Easy-MailChimp-Forms-Export' ); |
|
298 | 298 | // re-direct the user back to the page |
299 | 299 | wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=import-export-forms' ) ) ); |
300 | 300 | die(); |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function yikes_easy_mailchimp_export_plugin_settings() { |
310 | 310 | // grab our nonce |
311 | - $nonce = $_REQUEST['nonce']; |
|
311 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
312 | 312 | // validate nonce |
313 | - if( ! wp_verify_nonce( $nonce, 'export-settings' ) ) { |
|
314 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
313 | + if ( ! wp_verify_nonce( $nonce, 'export-settings' ) ) { |
|
314 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
315 | 315 | } |
316 | 316 | // include the export class |
317 | - if( ! class_exists( 'Yikes_Inc_Easy_MailChimp_Export_Class' ) ) { |
|
317 | + if ( ! class_exists( 'Yikes_Inc_Easy_MailChimp_Export_Class' ) ) { |
|
318 | 318 | include_once( YIKES_MC_PATH . 'includes/import-export/yikes-easy-mailchimp-export.class.php' ); |
319 | 319 | } |
320 | 320 | // run the export function |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function yikes_easy_mailchimp_import_forms() { |
333 | 333 | // grab our nonce |
334 | - $nonce = $_REQUEST['nonce']; |
|
334 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
335 | 335 | // validate nonce |
336 | - if( ! wp_verify_nonce( $nonce, 'import-forms' ) ) { |
|
337 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
336 | + if ( ! wp_verify_nonce( $nonce, 'import-forms' ) ) { |
|
337 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
338 | 338 | } |
339 | 339 | // include the export class |
340 | - if( ! class_exists( 'Yikes_Inc_Easy_MailChimp_Import_Class' ) ) { |
|
340 | + if ( ! class_exists( 'Yikes_Inc_Easy_MailChimp_Import_Class' ) ) { |
|
341 | 341 | include_once( YIKES_MC_PATH . 'includes/import-export/yikes-easy-mailchimp-import.class.php' ); |
342 | 342 | } |
343 | 343 | // run the import function |
@@ -355,15 +355,15 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function yikes_easy_mailchimp_premium_support_request() { |
357 | 357 | |
358 | - if( isset( $_POST['action'] ) && $_POST['action'] != 'yikes-support-request' ) { |
|
359 | - return __( 'We encountered an error. Please contact the YIKES Inc. support team.' , 'yikes-inc-easy-mailchimp-extender' ); |
|
358 | + if ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] != 'yikes-support-request' ) { |
|
359 | + return __( 'We encountered an error. Please contact the YIKES Inc. support team.', 'yikes-inc-easy-mailchimp-extender' ); |
|
360 | 360 | } |
361 | 361 | |
362 | - $license = $_POST['license_key']; |
|
363 | - $user_email = $_POST['user-email']; |
|
364 | - $support_topic = $_POST['support-topic']; |
|
365 | - $support_priority = $_POST['support-priority']; |
|
366 | - $support_content = $_POST['support-content']; |
|
362 | + $license = $_POST[ 'license_key' ]; |
|
363 | + $user_email = $_POST[ 'user-email' ]; |
|
364 | + $support_topic = $_POST[ 'support-topic' ]; |
|
365 | + $support_priority = $_POST[ 'support-priority' ]; |
|
366 | + $support_content = $_POST[ 'support-content' ]; |
|
367 | 367 | |
368 | 368 | // wp_die( print_r( $support_content) ); |
369 | 369 | |
@@ -379,18 +379,18 @@ discard block |
||
379 | 379 | |
380 | 380 | $yikes_plugin_support_url = 'https://yikesplugins.com'; |
381 | 381 | |
382 | - if( $license != 'plugin-core' ) { |
|
382 | + if ( $license != 'plugin-core' ) { |
|
383 | 383 | $split_license = explode( '|', $license ); |
384 | 384 | // first let's check that the license key is actually active |
385 | 385 | $is_license_key_active = wp_remote_post( esc_url( $yikes_plugin_support_url ), array( |
386 | 386 | 'action' => 'check_license', |
387 | - 'product_name' => urlencode( str_replace( '-', '', $split_license[1] ) . 'for Easy MailChimp' ), |
|
388 | - 'license' => $split_license[0], |
|
387 | + 'product_name' => urlencode( str_replace( '-', '', $split_license[ 1 ] ) . 'for Easy MailChimp' ), |
|
388 | + 'license' => $split_license[ 0 ], |
|
389 | 389 | ) ); |
390 | 390 | |
391 | - $response_body = wp_remote_retrieve_body( $is_license_key_active ); |
|
392 | - if( $response_body ) { |
|
393 | - if( $response_body->status != 'valid' ) { |
|
391 | + $response_body = wp_remote_retrieve_body( $is_license_key_active ); |
|
392 | + if ( $response_body ) { |
|
393 | + if ( $response_body->status != 'valid' ) { |
|
394 | 394 | wp_die( 'Invalid License Key...' ); |
395 | 395 | } |
396 | 396 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | ) ); |
405 | 405 | |
406 | 406 | // catch the error |
407 | - if( is_wp_error( $response ) ) { |
|
407 | + if ( is_wp_error( $response ) ) { |
|
408 | 408 | wp_die( $create_ticket_request->getMessage() ); |
409 | 409 | return; |
410 | 410 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | $create_ticket_response = wp_remote_retrieve_body( $response ); |
414 | 414 | |
415 | 415 | // display it |
416 | - if( $create_ticket_response ) |
|
416 | + if ( $create_ticket_response ) |
|
417 | 417 | echo $create_ticket_response; |
418 | 418 | |
419 | 419 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | // delete the options and allow the user to manually updadte things |
428 | 428 | |
429 | 429 | // Verify the NONCE is valid |
430 | - check_admin_referer( 'yikes-mc-dismiss-migration' , 'dismiss_migration_nonce' ); |
|
430 | + check_admin_referer( 'yikes-mc-dismiss-migration', 'dismiss_migration_nonce' ); |
|
431 | 431 | |
432 | 432 | // re-direct the user back to the page |
433 | 433 | wp_redirect( esc_url_raw( admin_url( 'index.php?yikes-mc-options-migration-dismissed="true"' ) ) ); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * @since 6.0.0 |
443 | 443 | */ |
444 | 444 | public function load_error_logging_class() { |
445 | - if( get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
445 | + if ( get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
446 | 446 | // if error logging is enabled we should include our error logging class |
447 | 447 | /* Generate oure error logging table */ |
448 | 448 | require_once YIKES_MC_PATH . '/includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
@@ -461,17 +461,17 @@ discard block |
||
461 | 461 | // add a new option to store the plugin activation date/time |
462 | 462 | // @since v6.0.0 |
463 | 463 | // this is used to notify the user that they should review after 2 weeks |
464 | - if ( !get_option( 'yikes_easy_mailchimp_activation_date' ) ) { |
|
464 | + if ( ! get_option( 'yikes_easy_mailchimp_activation_date' ) ) { |
|
465 | 465 | add_option( 'yikes_easy_mailchimp_activation_date', strtotime( "now" ) ); |
466 | 466 | } |
467 | 467 | |
468 | 468 | $stop_bugging_me = get_option( 'yikes_easy_mailchimp_review_stop_bugging_me' ); |
469 | 469 | |
470 | - if( !$stop_bugging_me ) { |
|
470 | + if ( ! $stop_bugging_me ) { |
|
471 | 471 | $install_date = get_option( 'yikes_easy_mailchimp_activation_date' ); |
472 | 472 | $past_date = strtotime( '-14 days' ); |
473 | 473 | if ( $past_date >= $install_date && current_user_can( 'install_plugins' ) ) { |
474 | - add_action( 'admin_notices', array( $this , 'yikes_easy_mailchimp_display_review_us_notice' ) ); |
|
474 | + add_action( 'admin_notices', array( $this, 'yikes_easy_mailchimp_display_review_us_notice' ) ); |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
@@ -484,13 +484,13 @@ discard block |
||
484 | 484 | */ |
485 | 485 | public function yikes_easy_mailchimp_display_review_us_notice() { |
486 | 486 | /* Lets only display our admin notice on YT4WP pages to not annoy the hell out of people :) */ |
487 | - if ( in_array( get_current_screen()->base , array( 'dashboard' , 'post' , 'edit' ) ) || strpos( get_current_screen()->base ,'yikes-inc-easy-mailchimp') !== false ) { |
|
487 | + if ( in_array( get_current_screen()->base, array( 'dashboard', 'post', 'edit' ) ) || strpos( get_current_screen()->base, 'yikes-inc-easy-mailchimp' ) !== false ) { |
|
488 | 488 | // Review URL - Change to the URL of your plugin on WordPress.org |
489 | 489 | $reviewurl = 'https://wordpress.org/support/view/plugin-reviews/yikes-inc-easy-mailchimp-extender'; |
490 | 490 | $addons_url = esc_url( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-addons' ) ); |
491 | 491 | $nobugurl = esc_url_raw( add_query_arg( 'yikes_easy_mc_icons_nobug', '1', admin_url() ) ); |
492 | 492 | $review_message = '<div id="yikes-mailchimp-logo"></div>'; |
493 | - $review_message .= sprintf( __( "It looks like you've been using %s for 2 weeks now. We hope you're enjoying the features included with the free version. If so, please consider leaving us a review. Reviews only help to catch other users attention as well as provide us with feedback to grow and improve upon. If you're really enjoying the plugin, consider buying an add-on or developer license for some really awesome features and premium support." , 'yikes-inc-easy-mailchimp-extender' ) . "<span class='button-container'> <a href='%s' target='_blank' class='button-secondary'><span class='dashicons dashicons-star-filled'></span>" . __( "Leave A Review" , 'yikes-inc-easy-mailchimp-extender' ) . "</a> <a href='%s' class='button-secondary'><span class='dashicons dashicons-upload'></span>" . __( "View Addons" , 'yikes-inc-easy-mailchimp-extender' ) . "</a> <a href='%s' class='button-secondary'><span class='dashicons dashicons-no-alt'></span>" . __( "Dismiss" , 'yikes-inc-easy-mailchimp-extender' ) . "</a> </span>", '<strong>Easy Forms for MailChimp by YIKES Inc.</strong>', $reviewurl, $addons_url, $nobugurl ) . ''; |
|
493 | + $review_message .= sprintf( __( "It looks like you've been using %s for 2 weeks now. We hope you're enjoying the features included with the free version. If so, please consider leaving us a review. Reviews only help to catch other users attention as well as provide us with feedback to grow and improve upon. If you're really enjoying the plugin, consider buying an add-on or developer license for some really awesome features and premium support.", 'yikes-inc-easy-mailchimp-extender' ) . "<span class='button-container'> <a href='%s' target='_blank' class='button-secondary'><span class='dashicons dashicons-star-filled'></span>" . __( "Leave A Review", 'yikes-inc-easy-mailchimp-extender' ) . "</a> <a href='%s' class='button-secondary'><span class='dashicons dashicons-upload'></span>" . __( "View Addons", 'yikes-inc-easy-mailchimp-extender' ) . "</a> <a href='%s' class='button-secondary'><span class='dashicons dashicons-no-alt'></span>" . __( "Dismiss", 'yikes-inc-easy-mailchimp-extender' ) . "</a> </span>", '<strong>Easy Forms for MailChimp by YIKES Inc.</strong>', $reviewurl, $addons_url, $nobugurl ) . ''; |
|
494 | 494 | ?> |
495 | 495 | <div id="review-yikes-easy-mailchimp-notice"> |
496 | 496 | <?php echo $review_message; ?> |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | */ |
507 | 507 | public function yikes_easy_mailchimp_stop_bugging_me() { |
508 | 508 | $nobug = ""; |
509 | - if ( isset( $_GET['yikes_easy_mc_icons_nobug'] ) ) { |
|
510 | - $nobug = (int) esc_attr( $_GET['yikes_easy_mc_icons_nobug'] ); |
|
509 | + if ( isset( $_GET[ 'yikes_easy_mc_icons_nobug' ] ) ) { |
|
510 | + $nobug = (int) esc_attr( $_GET[ 'yikes_easy_mc_icons_nobug' ] ); |
|
511 | 511 | } |
512 | 512 | if ( 1 == $nobug ) { |
513 | 513 | add_option( 'yikes_easy_mailchimp_review_stop_bugging_me', TRUE ); |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | |
519 | 519 | /* Display a warning users who are using PHP < 5.3 */ |
520 | 520 | public function display_php_warning() { |
521 | - $message = __( 'YIKES Inc. Easy Forms for MailChimp requires a minimum of PHP 5.3. The plugin will not function properly until you update. Reach out to your host provider for assistance.' , 'yikes-inc-easy-mailchimp-extender' ); |
|
521 | + $message = __( 'YIKES Inc. Easy Forms for MailChimp requires a minimum of PHP 5.3. The plugin will not function properly until you update. Reach out to your host provider for assistance.', 'yikes-inc-easy-mailchimp-extender' ); |
|
522 | 522 | echo "<div class='error'> <p><span class='dashicons dashicons-no-alt' style='color:rgb(231, 98, 98)'></span> $message</p></div>"; |
523 | 523 | } |
524 | 524 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | public function add_tinyMCE_buttons() { |
530 | 530 | global $typenow; |
531 | 531 | // only on Post Type: post and page |
532 | - if( ! in_array( $typenow, array( 'post', 'page' ) ) ) { |
|
532 | + if ( ! in_array( $typenow, array( 'post', 'page' ) ) ) { |
|
533 | 533 | return; |
534 | 534 | } |
535 | 535 | add_filter( 'mce_buttons', array( $this, 'yks_mc_add_tinymce_button' ) ); |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | |
546 | 546 | // inlcude the js for tinymce |
547 | 547 | public function yks_mc_add_tinymce_plugin( $plugin_array ) { |
548 | - $plugin_array['yks_mc_tinymce_button'] = plugins_url( '/js/min/yikes-inc-easy-mailchimp-tinymce-button.min.js', __FILE__ ); |
|
548 | + $plugin_array[ 'yks_mc_tinymce_button' ] = plugins_url( '/js/min/yikes-inc-easy-mailchimp-tinymce-button.min.js', __FILE__ ); |
|
549 | 549 | // Print all plugin js path |
550 | 550 | // var_dump( $plugin_array ); |
551 | 551 | return $plugin_array; |
@@ -558,25 +558,25 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public function tinymce_yikes_easy_mc() { |
560 | 560 | // check capabilities |
561 | - if( ! current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
561 | + if ( ! current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
562 | 562 | return; |
563 | 563 | } |
564 | 564 | global $wpdb; |
565 | 565 | $list_data = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms', ARRAY_A ); |
566 | 566 | $lists = array(); |
567 | 567 | $i = 0; |
568 | - if( !empty( $list_data ) ) { |
|
568 | + if ( ! empty( $list_data ) ) { |
|
569 | 569 | // build an array to pass to our javascript |
570 | - foreach( $list_data as $form ) { |
|
571 | - $lists[$i] = array( |
|
572 | - 'text' => urlencode( $form['form_name'] ), |
|
573 | - 'value' => $form['id'] |
|
570 | + foreach ( $list_data as $form ) { |
|
571 | + $lists[ $i ] = array( |
|
572 | + 'text' => urlencode( $form[ 'form_name' ] ), |
|
573 | + 'value' => $form[ 'id' ] |
|
574 | 574 | ); |
575 | 575 | $i++; |
576 | 576 | } |
577 | 577 | } else { |
578 | - $lists[0] = array( |
|
579 | - 'text' => __( 'Please Import Some MailChimp Lists' , 'yikes-inc-easy-mailchimp-extender' ), |
|
578 | + $lists[ 0 ] = array( |
|
579 | + 'text' => __( 'Please Import Some MailChimp Lists', 'yikes-inc-easy-mailchimp-extender' ), |
|
580 | 580 | 'value' => '-' |
581 | 581 | ); |
582 | 582 | } |
@@ -589,10 +589,10 @@ discard block |
||
589 | 589 | var localized_data = { |
590 | 590 | 'button_title' : '<?php _e( 'Easy Forms for MailChimp by YIKES', 'yikes-inc-easy-mailchimp-extender' ); ?>', |
591 | 591 | 'popup_title' : '<?php _e( 'Easy Forms for MailChimp by YIKES', 'yikes-inc-easy-mailchimp-extender' ); ?>', |
592 | - 'list_id_label' : '<?php _e( 'MailChimp Opt-In Form' , 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
593 | - 'show_title_label' : '<?php _e( 'Display Form Title' , 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
594 | - 'show_description_label' : '<?php _e( 'Display Form Description' , 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
595 | - 'submit_button_text_label' : '<?php _e( 'Submit Button Text' , 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
592 | + 'list_id_label' : '<?php _e( 'MailChimp Opt-In Form', 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
593 | + 'show_title_label' : '<?php _e( 'Display Form Title', 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
594 | + 'show_description_label' : '<?php _e( 'Display Form Description', 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
595 | + 'submit_button_text_label' : '<?php _e( 'Submit Button Text', 'yikes-inc-easy-mailchimp-extender' ); ?>', |
|
596 | 596 | }; |
597 | 597 | <?php |
598 | 598 | $link = sprintf( __( 'You need to <a href="%s" title="%s">create a form</a> before you can add one to a page or post.', 'yikes-inc-easy-mailchimp-extender' ), esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ), __( 'Create a form', 'yikes-inc-easy-mailchimp-extender' ) ); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | if ( get_option( 'yikes_mailchimp_activation_redirect', 'true' ) == 'true' ) { |
612 | 612 | update_option( 'yikes_mailchimp_activation_redirect', 'false' ); |
613 | 613 | /* If the user had this plugin activated prior to today, redirect to 'Whats New' */ |
614 | - if( get_option( 'yikes_easy_mailchimp_activation_date', strtotime( 'now' ) ) == strtotime( 'now' ) ) { |
|
614 | + if ( get_option( 'yikes_easy_mailchimp_activation_date', strtotime( 'now' ) ) == strtotime( 'now' ) ) { |
|
615 | 615 | wp_redirect( esc_url( admin_url( 'admin.php?page=yikes-mailchimp-welcome' ) ) ); |
616 | 616 | } else { |
617 | 617 | /* Else redirect the user over to the 'Getting Started' tab */ |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | /** |
668 | 668 | * Enqueue our scripts across the dashboard as needed |
669 | 669 | */ |
670 | - wp_register_script( 'yikes-inc-easy-mailchimp-extender-admin-js', plugin_dir_url( __FILE__ ) . 'js/min/yikes-inc-easy-mailchimp-extender-admin.min.js', array( 'jquery' , 'jquery-ui-sortable' ), $this->version, false ); |
|
670 | + wp_register_script( 'yikes-inc-easy-mailchimp-extender-admin-js', plugin_dir_url( __FILE__ ) . 'js/min/yikes-inc-easy-mailchimp-extender-admin.min.js', array( 'jquery', 'jquery-ui-sortable' ), $this->version, false ); |
|
671 | 671 | $localized_data = array( |
672 | 672 | 'admin_url' => esc_url_raw( admin_url() ), |
673 | 673 | 'ajax_url' => esc_url_raw( admin_url( 'admin-ajax.php' ) ), |
@@ -675,19 +675,19 @@ discard block |
||
675 | 675 | 'search_preloader_url' => YIKES_MC_URL . 'includes/images/search-interest-group-preloader.gif', |
676 | 676 | 'preloader_url' => esc_url_raw( admin_url( '/images/wpspin_light.gif' ) ) |
677 | 677 | ); |
678 | - wp_localize_script( 'yikes-inc-easy-mailchimp-extender-admin-js' , 'object_data' , $localized_data ); |
|
678 | + wp_localize_script( 'yikes-inc-easy-mailchimp-extender-admin-js', 'object_data', $localized_data ); |
|
679 | 679 | wp_enqueue_script( 'yikes-inc-easy-mailchimp-extender-admin-js' ); |
680 | 680 | |
681 | 681 | |
682 | 682 | /* |
683 | 683 | * Enqueue required scripts for the form editor |
684 | 684 | */ |
685 | - if( get_current_screen()->base == 'admin_page_yikes-mailchimp-edit-form' ) { |
|
685 | + if ( get_current_screen()->base == 'admin_page_yikes-mailchimp-edit-form' ) { |
|
686 | 686 | global $wp_locale; |
687 | 687 | wp_enqueue_style( 'wp-color-picker' ); |
688 | 688 | wp_enqueue_script( 'wp-color-picker' ); |
689 | - wp_enqueue_script( 'jquery.timepicker.js',YIKES_MC_URL . 'admin/js/jquery.timepicker.min.js' , array( 'jquery' ) , $this->version, false ); |
|
690 | - wp_register_script( 'edit-form-js' , YIKES_MC_URL . 'admin/js/min/yikes-inc-easy-mailchimp-extender-edit-form.min.js' , array( 'jquery.timepicker.js', 'jquery-ui-datepicker' ) , $this->version, false ); |
|
689 | + wp_enqueue_script( 'jquery.timepicker.js', YIKES_MC_URL . 'admin/js/jquery.timepicker.min.js', array( 'jquery' ), $this->version, false ); |
|
690 | + wp_register_script( 'edit-form-js', YIKES_MC_URL . 'admin/js/min/yikes-inc-easy-mailchimp-extender-edit-form.min.js', array( 'jquery.timepicker.js', 'jquery-ui-datepicker' ), $this->version, false ); |
|
691 | 691 | $localized_data = array( |
692 | 692 | 'ajax_url' => esc_url_raw( admin_url( 'admin-ajax.php' ) ), |
693 | 693 | 'no_fields_assigned' => __( 'No fields assigned to this form. Select some fields to add to this form from the right hand column.', 'yikes-inc-easy-mailchimp-extender' ), |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | 'isRTL' => $wp_locale->is_rtl(), |
709 | 709 | 'start_date_exceeds_end_date_error' => __( 'Error: The start date and time cannot occur after the end date and time. Chosen date reverted to previous selection.', 'yikes-inc-easy-mailchimp-extender' ), |
710 | 710 | ); |
711 | - wp_localize_script( 'edit-form-js' , 'object' , $localized_data ); |
|
711 | + wp_localize_script( 'edit-form-js', 'object', $localized_data ); |
|
712 | 712 | wp_enqueue_script( 'edit-form-js' ); |
713 | 713 | } |
714 | 714 | |
@@ -728,8 +728,8 @@ discard block |
||
728 | 728 | * the datepicker wants a numerical index. This function replaces the index with a number |
729 | 729 | */ |
730 | 730 | public function yikes_jQuery_datepicker_strip_array_indices( $ArrayToStrip ) { |
731 | - foreach( $ArrayToStrip as $objArrayItem) { |
|
732 | - $NewArray[] = $objArrayItem; |
|
731 | + foreach ( $ArrayToStrip as $objArrayItem ) { |
|
732 | + $NewArray[ ] = $objArrayItem; |
|
733 | 733 | } |
734 | 734 | return( $NewArray ); |
735 | 735 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | * Convert the php date format string to a js date format |
794 | 794 | */ |
795 | 795 | public function yikes_jQuery_datepicker_date_format( $site_option ) { |
796 | - switch( $site_option ) { |
|
796 | + switch ( $site_option ) { |
|
797 | 797 | //Predefined WP date formats |
798 | 798 | default: |
799 | 799 | case 'F j, Y': |
@@ -820,9 +820,9 @@ discard block |
||
820 | 820 | |
821 | 821 | /* Top Level Menu 'Easy MailChimp' */ |
822 | 822 | add_menu_page( |
823 | - __( 'Easy Forms' , 'yikes-inc-easy-mailchimp-extender' ), |
|
823 | + __( 'Easy Forms', 'yikes-inc-easy-mailchimp-extender' ), |
|
824 | 824 | 'Easy Forms', |
825 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
825 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
826 | 826 | 'yikes-inc-easy-mailchimp', |
827 | 827 | '', // no callback, |
828 | 828 | YIKES_MC_URL . 'includes/images/MailChimp_Assets/Freddie_wink_icon.png' |
@@ -836,9 +836,9 @@ discard block |
||
836 | 836 | /* YIKES Inc. Easy MailChimp Manage Forms */ |
837 | 837 | add_submenu_page( |
838 | 838 | 'yikes-inc-easy-mailchimp', |
839 | - __( 'Opt-in Forms' , 'yikes-inc-easy-mailchimp-extender' ), |
|
840 | - __( 'Opt-in Forms' , 'yikes-inc-easy-mailchimp-extender' ), |
|
841 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
839 | + __( 'Opt-in Forms', 'yikes-inc-easy-mailchimp-extender' ), |
|
840 | + __( 'Opt-in Forms', 'yikes-inc-easy-mailchimp-extender' ), |
|
841 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
842 | 842 | 'yikes-inc-easy-mailchimp', |
843 | 843 | array( $this, 'generateManageFormsPage' ) |
844 | 844 | ); |
@@ -846,9 +846,9 @@ discard block |
||
846 | 846 | /* YIKES Inc. Easy MailChimp Manage Lists */ |
847 | 847 | add_submenu_page( |
848 | 848 | 'yikes-inc-easy-mailchimp', |
849 | - __( 'Mailing Lists' , 'yikes-inc-easy-mailchimp-extender' ), |
|
850 | - __( 'Mailing Lists' , 'yikes-inc-easy-mailchimp-extender' ), |
|
851 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
849 | + __( 'Mailing Lists', 'yikes-inc-easy-mailchimp-extender' ), |
|
850 | + __( 'Mailing Lists', 'yikes-inc-easy-mailchimp-extender' ), |
|
851 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
852 | 852 | 'yikes-inc-easy-mailchimp-lists', |
853 | 853 | array( $this, 'generateManageListsPage' ) |
854 | 854 | ); |
@@ -862,13 +862,13 @@ discard block |
||
862 | 862 | |
863 | 863 | |
864 | 864 | /* YIKES Inc. Easy MailChimp Account Overview */ |
865 | - if ( get_option('yikes-mc-api-validation') == 'valid_api_key' ) { |
|
865 | + if ( get_option( 'yikes-mc-api-validation' ) == 'valid_api_key' ) { |
|
866 | 866 | /* YIKES Inc. Easy MailChimp Settings */ |
867 | 867 | add_submenu_page( |
868 | 868 | 'yikes-inc-easy-mailchimp', |
869 | - __( 'Account' , 'yikes-inc-easy-mailchimp-extender' ), |
|
870 | - __( 'Account' , 'yikes-inc-easy-mailchimp-extender' ), |
|
871 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
869 | + __( 'Account', 'yikes-inc-easy-mailchimp-extender' ), |
|
870 | + __( 'Account', 'yikes-inc-easy-mailchimp-extender' ), |
|
871 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
872 | 872 | 'yikes-inc-easy-mailchimp-account-overview', |
873 | 873 | array( $this, 'generateAccountDetailsPage' ) |
874 | 874 | ); |
@@ -878,9 +878,9 @@ discard block |
||
878 | 878 | /* YIKES Inc. Easy MailChimp Settings */ |
879 | 879 | add_submenu_page( |
880 | 880 | 'yikes-inc-easy-mailchimp', |
881 | - __( 'Settings.' , 'yikes-inc-easy-mailchimp-extender' ), |
|
882 | - __( 'Settings' , 'yikes-inc-easy-mailchimp-extender' ), |
|
883 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
881 | + __( 'Settings.', 'yikes-inc-easy-mailchimp-extender' ), |
|
882 | + __( 'Settings', 'yikes-inc-easy-mailchimp-extender' ), |
|
883 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
884 | 884 | 'yikes-inc-easy-mailchimp-settings', |
885 | 885 | array( $this, 'generatePageOptions' ) |
886 | 886 | ); |
@@ -888,9 +888,9 @@ discard block |
||
888 | 888 | /* Support Page */ |
889 | 889 | add_submenu_page( |
890 | 890 | 'yikes-inc-easy-mailchimp', |
891 | - __( 'Support' , 'yikes-inc-easy-mailchimp-extender' ), |
|
892 | - __( 'Support' , 'yikes-inc-easy-mailchimp-extender' ), |
|
893 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
891 | + __( 'Support', 'yikes-inc-easy-mailchimp-extender' ), |
|
892 | + __( 'Support', 'yikes-inc-easy-mailchimp-extender' ), |
|
893 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
894 | 894 | 'yikes-inc-easy-mailchimp-support', |
895 | 895 | array( $this, 'generateSupportPage' ) |
896 | 896 | ); |
@@ -898,11 +898,11 @@ discard block |
||
898 | 898 | /* Add-Ons Page */ |
899 | 899 | add_submenu_page( |
900 | 900 | 'yikes-inc-easy-mailchimp', |
901 | - __( 'Add-Ons' , 'yikes-inc-easy-mailchimp-extender' ), |
|
902 | - __( 'Add-Ons' , 'yikes-inc-easy-mailchimp-extender' ), |
|
903 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
901 | + __( 'Add-Ons', 'yikes-inc-easy-mailchimp-extender' ), |
|
902 | + __( 'Add-Ons', 'yikes-inc-easy-mailchimp-extender' ), |
|
903 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
904 | 904 | 'yikes-inc-easy-mailchimp-addons', |
905 | - array( $this , 'generateAddOnsPage' ) |
|
905 | + array( $this, 'generateAddOnsPage' ) |
|
906 | 906 | ); |
907 | 907 | |
908 | 908 | /** Hidden Pages **/ |
@@ -910,9 +910,9 @@ discard block |
||
910 | 910 | /* Add Hidden Edit Form Page */ |
911 | 911 | add_submenu_page( |
912 | 912 | 'options.php', |
913 | - __( 'Edit Form' , 'yikes-inc-easy-mailchimp-extender' ), |
|
914 | - __( 'Edit Form' , 'yikes-inc-easy-mailchimp-extender' ), |
|
915 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
913 | + __( 'Edit Form', 'yikes-inc-easy-mailchimp-extender' ), |
|
914 | + __( 'Edit Form', 'yikes-inc-easy-mailchimp-extender' ), |
|
915 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
916 | 916 | 'yikes-mailchimp-edit-form', |
917 | 917 | array( $this, 'generateEditFormPage' ) |
918 | 918 | ); |
@@ -920,19 +920,19 @@ discard block |
||
920 | 920 | /* Add Hidden Migrate Options Page */ |
921 | 921 | add_submenu_page( |
922 | 922 | 'options-writing.php', |
923 | - __( 'YIKES Inc. Easy Forms for MailChimp Upgrade Options Structure' , 'yikes-inc-easy-mailchimp-extender' ), |
|
923 | + __( 'YIKES Inc. Easy Forms for MailChimp Upgrade Options Structure', 'yikes-inc-easy-mailchimp-extender' ), |
|
924 | 924 | 'YIKES Inc. Easy Forms for MailChimp Upgrade Options Structure', |
925 | 925 | 'manage_options', |
926 | - 'yikes-inc-easy-mailchimp-update' , |
|
927 | - array( $this , 'migrate_old_yks_mc_options' ) |
|
926 | + 'yikes-inc-easy-mailchimp-update', |
|
927 | + array( $this, 'migrate_old_yks_mc_options' ) |
|
928 | 928 | ); |
929 | 929 | |
930 | 930 | /* Add Hidden Welcome Page */ |
931 | 931 | add_submenu_page( |
932 | 932 | 'options.php', |
933 | - __( 'Welcome' , 'yikes-inc-easy-mailchimp-extender' ), |
|
934 | - __( 'Welcome' , 'yikes-inc-easy-mailchimp-extender' ), |
|
935 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
933 | + __( 'Welcome', 'yikes-inc-easy-mailchimp-extender' ), |
|
934 | + __( 'Welcome', 'yikes-inc-easy-mailchimp-extender' ), |
|
935 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
936 | 936 | 'yikes-mailchimp-welcome', |
937 | 937 | array( $this, 'generateWelcomePage' ) |
938 | 938 | ); |
@@ -940,9 +940,9 @@ discard block |
||
940 | 940 | /* Add Hidden 'View List' Page */ |
941 | 941 | add_submenu_page( |
942 | 942 | 'options.php', |
943 | - __( 'View List' , 'yikes-inc-easy-mailchimp-extender' ), |
|
944 | - __( 'View List' , 'yikes-inc-easy-mailchimp-extender' ), |
|
945 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
943 | + __( 'View List', 'yikes-inc-easy-mailchimp-extender' ), |
|
944 | + __( 'View List', 'yikes-inc-easy-mailchimp-extender' ), |
|
945 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
946 | 946 | 'yikes-mailchimp-view-list', |
947 | 947 | array( $this, 'generateViewListPage' ) |
948 | 948 | ); |
@@ -950,9 +950,9 @@ discard block |
||
950 | 950 | /* Add Hidden View User Page */ |
951 | 951 | add_submenu_page( |
952 | 952 | 'options.php', |
953 | - __( 'View User' , 'yikes-inc-easy-mailchimp-extender' ), |
|
954 | - __( 'View User' , 'yikes-inc-easy-mailchimp-extender' ), |
|
955 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), |
|
953 | + __( 'View User', 'yikes-inc-easy-mailchimp-extender' ), |
|
954 | + __( 'View User', 'yikes-inc-easy-mailchimp-extender' ), |
|
955 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ), |
|
956 | 956 | 'yikes-mailchimp-view-user', |
957 | 957 | array( $this, 'generateViewUserPage' ) |
958 | 958 | ); |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | |
1050 | 1050 | /* Register General Settings Section */ |
1051 | 1051 | |
1052 | - register_setting( 'yikes_inc_easy_mc_general_settings_page', 'yikes-mc-api-key', array( $this , 'yikes_mc_validate_api_key' ) ); |
|
1052 | + register_setting( 'yikes_inc_easy_mc_general_settings_page', 'yikes-mc-api-key', array( $this, 'yikes_mc_validate_api_key' ) ); |
|
1053 | 1053 | |
1054 | 1054 | add_settings_section( |
1055 | 1055 | 'yikes_easy_mc_settings_general_section_callback', |
@@ -1092,16 +1092,16 @@ discard block |
||
1092 | 1092 | add_settings_field( |
1093 | 1093 | 'optin-checkbox-init', |
1094 | 1094 | __( 'Select Checkboxes to Generate', 'yikes-inc-easy-mailchimp-extender' ), |
1095 | - '', // callback + validation inside of admin/partials/menu/options.php |
|
1095 | + '', // callback + validation inside of admin/partials/menu/options.php |
|
1096 | 1096 | 'yikes_inc_easy_mc_checkbox_settings' |
1097 | 1097 | ); |
1098 | 1098 | /* End Checkbox Settings */ |
1099 | 1099 | |
1100 | 1100 | /* reCAPTCHA Settings */ |
1101 | 1101 | |
1102 | - register_setting( 'yikes_inc_easy_mc_recaptcha_settings_page' , 'yikes-mc-recaptcha-status' ); |
|
1103 | - register_setting( 'yikes_inc_easy_mc_recaptcha_settings_page' , 'yikes-mc-recaptcha-site-key' ); |
|
1104 | - register_setting( 'yikes_inc_easy_mc_recaptcha_settings_page' , 'yikes-mc-recaptcha-secret-key' ); |
|
1102 | + register_setting( 'yikes_inc_easy_mc_recaptcha_settings_page', 'yikes-mc-recaptcha-status' ); |
|
1103 | + register_setting( 'yikes_inc_easy_mc_recaptcha_settings_page', 'yikes-mc-recaptcha-site-key' ); |
|
1104 | + register_setting( 'yikes_inc_easy_mc_recaptcha_settings_page', 'yikes-mc-recaptcha-secret-key' ); |
|
1105 | 1105 | |
1106 | 1106 | /* Register reCAPTCHA Settings Section */ |
1107 | 1107 | add_settings_section( |
@@ -1114,28 +1114,28 @@ discard block |
||
1114 | 1114 | add_settings_field( |
1115 | 1115 | 'yikes-mc-recaptcha-site-key', |
1116 | 1116 | __( 'Enter reCAPTCHA Site Key', 'yikes-inc-easy-mailchimp-extender' ), |
1117 | - '', // callback + validation inside of admin/partials/menu/options.php |
|
1117 | + '', // callback + validation inside of admin/partials/menu/options.php |
|
1118 | 1118 | 'yikes_easy_mc_settings_recpatcha_section' |
1119 | 1119 | ); |
1120 | 1120 | |
1121 | 1121 | add_settings_field( |
1122 | 1122 | 'yikes-mc-recaptcha-secret-key', |
1123 | 1123 | __( 'Enter reCAPTCHA Secret Key', 'yikes-inc-easy-mailchimp-extender' ), |
1124 | - '', // callback + validation inside of admin/partials/menu/options.php |
|
1124 | + '', // callback + validation inside of admin/partials/menu/options.php |
|
1125 | 1125 | 'yikes_easy_mc_settings_recpatcha_section' |
1126 | 1126 | ); |
1127 | 1127 | |
1128 | 1128 | add_settings_field( |
1129 | 1129 | 'yikes-mc-recaptcha-status', |
1130 | 1130 | __( 'Enable ReCaptcha', 'yikes-inc-easy-mailchimp-extender' ), |
1131 | - '', // callback + validation inside of admin/partials/menu/options.php |
|
1131 | + '', // callback + validation inside of admin/partials/menu/options.php |
|
1132 | 1132 | 'yikes_easy_mc_settings_recpatcha_section' |
1133 | 1133 | ); |
1134 | 1134 | |
1135 | 1135 | /* End reCAPTCHA Settings */ |
1136 | 1136 | |
1137 | 1137 | /* Debug Settings */ |
1138 | - register_setting( 'yikes_inc_easy_mc_debug_settings_page' , 'yikes-mailchimp-debug-status' ); |
|
1138 | + register_setting( 'yikes_inc_easy_mc_debug_settings_page', 'yikes-mailchimp-debug-status' ); |
|
1139 | 1139 | |
1140 | 1140 | /* Register Debug Settings Section */ |
1141 | 1141 | add_settings_section( |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | add_settings_field( |
1149 | 1149 | 'yikes-mailchimp-debug-status', |
1150 | 1150 | __( 'Enable Debugging', 'yikes-inc-easy-mailchimp-extender' ), |
1151 | - '', // callback + validation inside of admin/partials/menu/options.php |
|
1151 | + '', // callback + validation inside of admin/partials/menu/options.php |
|
1152 | 1152 | 'yikes_easy_mc_settings_debug_section' |
1153 | 1153 | ); |
1154 | 1154 | |
@@ -1164,17 +1164,17 @@ discard block |
||
1164 | 1164 | * @since complete re-write |
1165 | 1165 | **/ |
1166 | 1166 | function yikes_mc_validate_api_key( $input ) { |
1167 | - if( $input === '' ) { |
|
1168 | - update_option( 'yikes-mc-api-validation' , 'invalid_api_key' ); |
|
1167 | + if ( $input === '' ) { |
|
1168 | + update_option( 'yikes-mc-api-validation', 'invalid_api_key' ); |
|
1169 | 1169 | return; |
1170 | 1170 | } |
1171 | 1171 | $api_key = trim( $input ); |
1172 | 1172 | $dash_position = strpos( trim( $input ), '-' ); |
1173 | - if( $dash_position !== false ) { |
|
1173 | + if ( $dash_position !== false ) { |
|
1174 | 1174 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/helper/ping.json'; |
1175 | 1175 | } else { |
1176 | 1176 | update_option( 'yikes-mc-api-invalid-key-response', __( 'Your API key appears to be invalid.', 'yikes-inc-easy-mailchimp-extender' ) ); |
1177 | - update_option( 'yikes-mc-api-validation' , 'invalid_api_key' ); |
|
1177 | + update_option( 'yikes-mc-api-validation', 'invalid_api_key' ); |
|
1178 | 1178 | return $api_key; |
1179 | 1179 | } |
1180 | 1180 | $request_args = array( |
@@ -1185,17 +1185,17 @@ discard block |
||
1185 | 1185 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ), |
1186 | 1186 | ); |
1187 | 1187 | $api_key_response = wp_remote_post( $api_endpoint, $request_args ); |
1188 | - if( ! is_wp_error( $api_key_response ) ) { |
|
1188 | + if ( ! is_wp_error( $api_key_response ) ) { |
|
1189 | 1189 | $body = json_decode( wp_remote_retrieve_body( $api_key_response ), true ); |
1190 | - if( isset( $body['msg'] ) && $body['msg'] == "Everything's Chimpy!" ) { |
|
1191 | - update_option( 'yikes-mc-api-validation' , 'valid_api_key' ); |
|
1190 | + if ( isset( $body[ 'msg' ] ) && $body[ 'msg' ] == "Everything's Chimpy!" ) { |
|
1191 | + update_option( 'yikes-mc-api-validation', 'valid_api_key' ); |
|
1192 | 1192 | } |
1193 | - } else { |
|
1193 | + } else { |
|
1194 | 1194 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
1195 | 1195 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
1196 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $api_key_response->get_error_message() , __( "Connecting to MailChimp" , 'yikes-inc-easy-mailchimp-extender' ) , __( "Settings Page/General Settings" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
1197 | - update_option( 'yikes-mc-api-invalid-key-response' , $api_key_response->get_error_message() ); |
|
1198 | - update_option( 'yikes-mc-api-validation' , 'invalid_api_key' ); |
|
1196 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $api_key_response->get_error_message(), __( "Connecting to MailChimp", 'yikes-inc-easy-mailchimp-extender' ), __( "Settings Page/General Settings", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
1197 | + update_option( 'yikes-mc-api-invalid-key-response', $api_key_response->get_error_message() ); |
|
1198 | + update_option( 'yikes-mc-api-validation', 'invalid_api_key' ); |
|
1199 | 1199 | } |
1200 | 1200 | // returned the api key |
1201 | 1201 | return $api_key; |
@@ -1216,13 +1216,13 @@ discard block |
||
1216 | 1216 | * to form fields. (input, dropdowns, buttons etc.) |
1217 | 1217 | * @since v5.5 re-write |
1218 | 1218 | **/ |
1219 | - public function is_user_mc_api_valid_form( $echo=true ) { |
|
1220 | - if( $echo == true ) { |
|
1221 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
1219 | + public function is_user_mc_api_valid_form( $echo = true ) { |
|
1220 | + if ( $echo == true ) { |
|
1221 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
1222 | 1222 | echo 'disabled="disabled"'; |
1223 | 1223 | } |
1224 | 1224 | } else { |
1225 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
1225 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
1226 | 1226 | return false; |
1227 | 1227 | } else { |
1228 | 1228 | return true; |
@@ -1242,11 +1242,11 @@ discard block |
||
1242 | 1242 | public function check_for_old_yks_mc_options() { |
1243 | 1243 | $old_plugin_options = get_option( 'ykseme_storage' ); |
1244 | 1244 | // only perform options migrations if the site is not a multi-site setup |
1245 | - if ( !is_multisite() ) { |
|
1246 | - if( apply_filters( 'yikes_mc_old_options_filter' , $old_plugin_options ) ) { |
|
1245 | + if ( ! is_multisite() ) { |
|
1246 | + if ( apply_filters( 'yikes_mc_old_options_filter', $old_plugin_options ) ) { |
|
1247 | 1247 | // display a notice to the user that they should 'migrate' |
1248 | 1248 | // from the old plugin settings to the new ones |
1249 | - add_action( 'admin_notices', array( $this , 'display_options_migrate_notice' ) , 11 ); |
|
1249 | + add_action( 'admin_notices', array( $this, 'display_options_migrate_notice' ), 11 ); |
|
1250 | 1250 | } |
1251 | 1251 | } |
1252 | 1252 | } |
@@ -1279,11 +1279,11 @@ discard block |
||
1279 | 1279 | |
1280 | 1280 | // Confirm that the necessary forms table in the database exists, else bail |
1281 | 1281 | global $wpdb; |
1282 | - if( $wpdb->get_var("show tables like '" . $wpdb->prefix . "yikes_easy_mc_forms'") != $wpdb->prefix . "yikes_easy_mc_forms" ) { |
|
1282 | + if ( $wpdb->get_var( "show tables like '" . $wpdb->prefix . "yikes_easy_mc_forms'" ) != $wpdb->prefix . "yikes_easy_mc_forms" ) { |
|
1283 | 1283 | return; |
1284 | 1284 | } |
1285 | 1285 | |
1286 | - if( isset( $_GET['yikes-mc-options-migration-dismissed'] ) && $_GET['yikes-mc-options-migration-dismissed'] == 'true' ) { |
|
1286 | + if ( isset( $_GET[ 'yikes-mc-options-migration-dismissed' ] ) && $_GET[ 'yikes-mc-options-migration-dismissed' ] == 'true' ) { |
|
1287 | 1287 | // Delete the options, start a-new! (this will disable the migration notice altogether) |
1288 | 1288 | delete_option( 'widget_yikes_mc_widget' ); |
1289 | 1289 | delete_option( 'api_validation' ); |
@@ -1297,18 +1297,18 @@ discard block |
||
1297 | 1297 | } else { |
1298 | 1298 | ?> |
1299 | 1299 | <div class="yikes-easy-mc-updated migrate-options-notice"> |
1300 | - <p><?php printf( __( "It looks like you're upgrading from a previous version of %s.", 'yikes-inc-easy-mailchimp-extender' ), '<strong>YIKES Inc. Easy Forms for MailChimp</strong>' ); ?> <?php printf( __( "In the newest version of %s, the options data structure has changed. We've also moved the mailing lists into its own database table to allow for some higher level customization. Now you can easily create multiple forms and assign them to the same mailing list." , 'yikes-inc-easy-mailchimp-extender' ), '<strong>YIKES Inc. Easy Forms for MailChimp</strong>' ); ?></p> |
|
1300 | + <p><?php printf( __( "It looks like you're upgrading from a previous version of %s.", 'yikes-inc-easy-mailchimp-extender' ), '<strong>YIKES Inc. Easy Forms for MailChimp</strong>' ); ?> <?php printf( __( "In the newest version of %s, the options data structure has changed. We've also moved the mailing lists into its own database table to allow for some higher level customization. Now you can easily create multiple forms and assign them to the same mailing list.", 'yikes-inc-easy-mailchimp-extender' ), '<strong>YIKES Inc. Easy Forms for MailChimp</strong>' ); ?></p> |
|
1301 | 1301 | <p><?php _e( "Before you continue, it's strongly recommended you the perform the migration to ensure the plugin continues to function properly.", 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
1302 | 1302 | <p><em><?php _e( "It's also strongly recommended that you take a backup of your database.", 'yikes-inc-easy-mailchimp-extender' ); ?></em></p> |
1303 | 1303 | <section id="migration-buttons"> |
1304 | 1304 | <!-- migrate button --> |
1305 | 1305 | <form> |
1306 | 1306 | <input type="hidden" name="yikes-mc-update-option-structure" value="yikes-mc-update-option-structure" /> |
1307 | - <a href="<?php echo wp_nonce_url( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-update' ) ), 'yikes-mc-migrate-options' , 'migrate_options_nonce' ); ?>" class="button-secondary"><?php _e( 'Perform Migration' , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
1307 | + <a href="<?php echo wp_nonce_url( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-update' ) ), 'yikes-mc-migrate-options', 'migrate_options_nonce' ); ?>" class="button-secondary"><?php _e( 'Perform Migration', 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
1308 | 1308 | </form> |
1309 | 1309 | <!-- dismiss button --> |
1310 | 1310 | <form> |
1311 | - <a href="<?php echo wp_nonce_url( esc_url_raw( admin_url() ), 'yikes-mc-dismiss-migration' , 'dismiss_migration_nonce' ); ?>" class="button-secondary"><?php _e( 'Dismiss Notice' , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
1311 | + <a href="<?php echo wp_nonce_url( esc_url_raw( admin_url() ), 'yikes-mc-dismiss-migration', 'dismiss_migration_nonce' ); ?>" class="button-secondary"><?php _e( 'Dismiss Notice', 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
1312 | 1312 | </form> |
1313 | 1313 | </section> |
1314 | 1314 | |
@@ -1322,9 +1322,9 @@ discard block |
||
1322 | 1322 | * and return the index ( used to find the list name assigned to a form ) |
1323 | 1323 | * - http://stackoverflow.com/questions/6661530/php-multi-dimensional-array-search |
1324 | 1324 | */ |
1325 | - function findMCListID($id, $array) { |
|
1326 | - foreach ($array as $key => $val) { |
|
1327 | - if ($val['id'] === $id) { |
|
1325 | + function findMCListID( $id, $array ) { |
|
1326 | + foreach ( $array as $key => $val ) { |
|
1327 | + if ( $val[ 'id' ] === $id ) { |
|
1328 | 1328 | return $key; |
1329 | 1329 | } |
1330 | 1330 | } |
@@ -1334,9 +1334,9 @@ discard block |
||
1334 | 1334 | /* Ajax Migrate Options */ |
1335 | 1335 | function migrate_archived_options() { |
1336 | 1336 | // all options prefixed with 'yikes-mc-' |
1337 | - $option_name = 'yikes-mc-'.$_POST['option_name']; |
|
1338 | - $option_value = $_POST['option_value']; |
|
1339 | - if( json_decode( $option_value ) ) { |
|
1337 | + $option_name = 'yikes-mc-' . $_POST[ 'option_name' ]; |
|
1338 | + $option_value = $_POST[ 'option_value' ]; |
|
1339 | + if ( json_decode( $option_value ) ) { |
|
1340 | 1340 | // decode our lists() array, and store it |
1341 | 1341 | $opt_value = json_decode( $option_value, true ); |
1342 | 1342 | } else { |
@@ -1349,24 +1349,24 @@ discard block |
||
1349 | 1349 | |
1350 | 1350 | /* Ajax Migrate Forms */ |
1351 | 1351 | function migrate_previously_setup_forms() { |
1352 | - $option_name = $_POST['option_name']; |
|
1353 | - $done = $_POST['done_import']; |
|
1352 | + $option_name = $_POST[ 'option_name' ]; |
|
1353 | + $done = $_POST[ 'done_import' ]; |
|
1354 | 1354 | // Create some starter forms for the user |
1355 | 1355 | // based on previously imported lists (to our old version) |
1356 | - if( $option_name == 'yikes-mc-lists' ) { |
|
1356 | + if ( $option_name == 'yikes-mc-lists' ) { |
|
1357 | 1357 | global $wpdb; |
1358 | - $option_value = $_POST['option_value']; |
|
1359 | - $new_options = json_decode( stripslashes_deep( $option_value ) , true ); |
|
1358 | + $option_value = $_POST[ 'option_value' ]; |
|
1359 | + $new_options = json_decode( stripslashes_deep( $option_value ), true ); |
|
1360 | 1360 | |
1361 | - $list_id = $new_options['id']; |
|
1362 | - $form_name = $new_options['name']; |
|
1363 | - $fields = $new_options['fields']; // our fields array |
|
1361 | + $list_id = $new_options[ 'id' ]; |
|
1362 | + $form_name = $new_options[ 'name' ]; |
|
1363 | + $fields = $new_options[ 'fields' ]; // our fields array |
|
1364 | 1364 | |
1365 | - $custom_styles = isset( $new_options['custom_styles'] ) ? json_encode( $new_options['custom_styles'] ) : '0'; // store as an array with all of our styles |
|
1366 | - $custom_template = isset( $new_options['custom_template'] ) ? json_encode( $new_options['custom_template'] ) : '0'; // store template data as an array ( active , template used ) |
|
1367 | - $send_welcome_email = isset( $new_options['yks_mailchimp_send_welcome_'.$list_id] ) ? '0' : '1'; |
|
1368 | - $redirect_user_on_submit = isset( $new_options['yks_mailchimp_redirect_'.$list_id] ) ? '1' : '0'; |
|
1369 | - $redirect_page = isset( $new_options['page_id_'.$list_id] ) ? $new_options['page_id_'.$list_id] : ''; |
|
1365 | + $custom_styles = isset( $new_options[ 'custom_styles' ] ) ? json_encode( $new_options[ 'custom_styles' ] ) : '0'; // store as an array with all of our styles |
|
1366 | + $custom_template = isset( $new_options[ 'custom_template' ] ) ? json_encode( $new_options[ 'custom_template' ] ) : '0'; // store template data as an array ( active , template used ) |
|
1367 | + $send_welcome_email = isset( $new_options[ 'yks_mailchimp_send_welcome_' . $list_id ] ) ? '0' : '1'; |
|
1368 | + $redirect_user_on_submit = isset( $new_options[ 'yks_mailchimp_redirect_' . $list_id ] ) ? '1' : '0'; |
|
1369 | + $redirect_page = isset( $new_options[ 'page_id_' . $list_id ] ) ? $new_options[ 'page_id_' . $list_id ] : ''; |
|
1370 | 1370 | |
1371 | 1371 | /* Insert Forms Function */ |
1372 | 1372 | $wpdb->insert( |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | ) |
1392 | 1392 | ); |
1393 | 1393 | } |
1394 | - if( $done == 'done' ) { |
|
1394 | + if ( $done == 'done' ) { |
|
1395 | 1395 | wp_send_json( array( 'form_name' => $form_name, 'completed_import' => true ) ); |
1396 | 1396 | } else { |
1397 | 1397 | wp_send_json( array( 'form_name' => $form_name, 'completed_import' => false ) ); |
@@ -1406,35 +1406,35 @@ discard block |
||
1406 | 1406 | * @since v5.6 - complete re-write |
1407 | 1407 | */ |
1408 | 1408 | public function generate_options_pages_sidebar_menu() { |
1409 | - if( isset( $_REQUEST['section'] ) ) { |
|
1410 | - $selected = $_REQUEST['section']; |
|
1409 | + if ( isset( $_REQUEST[ 'section' ] ) ) { |
|
1410 | + $selected = $_REQUEST[ 'section' ]; |
|
1411 | 1411 | } |
1412 | - $installed_addons = get_option( 'yikes-easy-mc-active-addons' , array() ); |
|
1412 | + $installed_addons = get_option( 'yikes-easy-mc-active-addons', array() ); |
|
1413 | 1413 | // sort our addons array alphabetically so they appear in similar orders across all sites |
1414 | 1414 | asort( $installed_addons ); |
1415 | 1415 | ?> |
1416 | - <h3><span><?php _e( 'Additional Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></span></h3> |
|
1416 | + <h3><span><?php _e( 'Additional Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></span></h3> |
|
1417 | 1417 | <div class="inside"> |
1418 | 1418 | <ul id="settings-nav"> |
1419 | - <li><?php if( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 'general-settings' || !isset( $_REQUEST['section'] ) ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'general-settings' ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=general-settings' ) ) ); ?>"><?php _e( 'General Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1420 | - <li><?php if( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 'integration-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'integration-settings' ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=integration-settings' ) ) ); ?>"><?php _e( 'Integration Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1421 | - <li><?php if( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 'recaptcha-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'recaptcha-settings' ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=recaptcha-settings' ) ) ); ?>"><?php _e( 'ReCaptcha Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1422 | - <li><?php if( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 'api-cache-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'api-cache-settings' ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=api-cache-settings' ) ) ); ?>"><?php _e( 'API Cache Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1423 | - <li><?php if( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 'debug-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'debug-settings' ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=debug-settings' ) ) ); ?>"><?php _e( 'Debug Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1424 | - <li><?php if( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 'import-export-forms' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'import-export-forms' ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=import-export-forms' ) ) ); ?>"><?php _e( 'Import/Export' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1419 | + <li><?php if ( isset( $_REQUEST[ 'section' ] ) && $_REQUEST[ 'section' ] == 'general-settings' || ! isset( $_REQUEST[ 'section' ] ) ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'general-settings' ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=general-settings' ) ) ); ?>"><?php _e( 'General Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1420 | + <li><?php if ( isset( $_REQUEST[ 'section' ] ) && $_REQUEST[ 'section' ] == 'integration-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'integration-settings' ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=integration-settings' ) ) ); ?>"><?php _e( 'Integration Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1421 | + <li><?php if ( isset( $_REQUEST[ 'section' ] ) && $_REQUEST[ 'section' ] == 'recaptcha-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'recaptcha-settings' ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=recaptcha-settings' ) ) ); ?>"><?php _e( 'ReCaptcha Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1422 | + <li><?php if ( isset( $_REQUEST[ 'section' ] ) && $_REQUEST[ 'section' ] == 'api-cache-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'api-cache-settings' ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=api-cache-settings' ) ) ); ?>"><?php _e( 'API Cache Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1423 | + <li><?php if ( isset( $_REQUEST[ 'section' ] ) && $_REQUEST[ 'section' ] == 'debug-settings' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'debug-settings' ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=debug-settings' ) ) ); ?>"><?php _e( 'Debug Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1424 | + <li><?php if ( isset( $_REQUEST[ 'section' ] ) && $_REQUEST[ 'section' ] == 'import-export-forms' ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => 'import-export-forms' ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=import-export-forms' ) ) ); ?>"><?php _e( 'Import/Export', 'yikes-inc-easy-mailchimp-extender' ); ?></a></li> |
|
1425 | 1425 | </ul> |
1426 | 1426 | <?php |
1427 | 1427 | // create our add-on settings pages |
1428 | - if( !empty( $installed_addons ) ) { |
|
1428 | + if ( ! empty( $installed_addons ) ) { |
|
1429 | 1429 | ?> |
1430 | 1430 | <hr class="add-on-settings-divider" /> |
1431 | - <strong><?php _e( 'Addon Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1431 | + <strong><?php _e( 'Addon Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1432 | 1432 | <ul id="addon-settings-nav"> |
1433 | 1433 | <?php |
1434 | - foreach( $installed_addons as $addon_name ) { |
|
1434 | + foreach ( $installed_addons as $addon_name ) { |
|
1435 | 1435 | ?> |
1436 | 1436 | <li> |
1437 | - <?php if( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == $addon_name ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => $addon_name, 'addon' => 'true' ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion='.$addon_name ) ) ); ?>"><?php echo ucwords( str_replace( '-' , ' ' , $addon_name ) ); ?></a></li> |
|
1437 | + <?php if ( isset( $_REQUEST[ 'section' ] ) && $_REQUEST[ 'section' ] == $addon_name ) { ?><div class="option-menu-selected-arrow"></div><?php } ?><a href="<?php echo esc_url_raw( add_query_arg( array( 'section' => $addon_name, 'addon' => 'true' ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=' . $addon_name ) ) ); ?>"><?php echo ucwords( str_replace( '-', ' ', $addon_name ) ); ?></a></li> |
|
1438 | 1438 | <?php |
1439 | 1439 | } |
1440 | 1440 | ?> |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | ) |
1463 | 1463 | ); |
1464 | 1464 | ?> |
1465 | - <h3><?php _e( 'Create a New Signup Form' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
1465 | + <h3><?php _e( 'Create a New Signup Form', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
1466 | 1466 | |
1467 | 1467 | <div class="inside"> |
1468 | 1468 | |
@@ -1471,31 +1471,31 @@ discard block |
||
1471 | 1471 | <form id="import-list-to-site" method="POST" action="<?php echo $url; ?>"> |
1472 | 1472 | <input type="hidden" name="import-list-to-site" value="1" /> |
1473 | 1473 | <!-- Name your new form --> |
1474 | - <label for="form-name"><strong><?php _e( 'Form Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1475 | - <input type="text" class="widefat input-field" placeholder="<?php _e( 'Form Name' , 'yikes-inc-easy-mailchimp-extender' ); ?>" name="form-name" id="form-name" <?php $this->is_user_mc_api_valid_form( true ); ?> required> |
|
1474 | + <label for="form-name"><strong><?php _e( 'Form Name', 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1475 | + <input type="text" class="widefat input-field" placeholder="<?php _e( 'Form Name', 'yikes-inc-easy-mailchimp-extender' ); ?>" name="form-name" id="form-name" <?php $this->is_user_mc_api_valid_form( true ); ?> required> |
|
1476 | 1476 | </label> |
1477 | 1477 | <!-- Name your new form --> |
1478 | - <label for="form-description"><strong><?php _e( 'Form Description' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1479 | - <textarea class="widefat input-field form-description" placeholder="<?php _e( 'Form Description' , 'yikes-inc-easy-mailchimp-extender' ); ?>" name="form-description" id="form-description" <?php $this->is_user_mc_api_valid_form( true ); ?>></textarea> |
|
1478 | + <label for="form-description"><strong><?php _e( 'Form Description', 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1479 | + <textarea class="widefat input-field form-description" placeholder="<?php _e( 'Form Description', 'yikes-inc-easy-mailchimp-extender' ); ?>" name="form-description" id="form-description" <?php $this->is_user_mc_api_valid_form( true ); ?>></textarea> |
|
1480 | 1480 | </label> |
1481 | 1481 | <!-- Associate this form with a list! --> |
1482 | - <label for="associated-list"><strong><?php _e( 'Associated List' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1483 | - <select name="associated-list" id="associated-list" class=" input-field" <?php $this->is_user_mc_api_valid_form( true ); if( isset( $lists ) && empty( $lists ) ) { echo 'disabled="disabled"'; } ?>> |
|
1482 | + <label for="associated-list"><strong><?php _e( 'Associated List', 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
|
1483 | + <select name="associated-list" id="associated-list" class=" input-field" <?php $this->is_user_mc_api_valid_form( true ); if ( isset( $lists ) && empty( $lists ) ) { echo 'disabled="disabled"'; } ?>> |
|
1484 | 1484 | <?php |
1485 | - if( isset( $lists ) && !empty( $lists ) ) { |
|
1486 | - foreach( $lists as $mailing_list ) { |
|
1485 | + if ( isset( $lists ) && ! empty( $lists ) ) { |
|
1486 | + foreach ( $lists as $mailing_list ) { |
|
1487 | 1487 | ?> |
1488 | - <option value="<?php echo $mailing_list['id']; ?>"><?php echo stripslashes( $mailing_list['name'] ) . ' (' . $mailing_list['stats']['member_count'] . ') '; ?></option> |
|
1488 | + <option value="<?php echo $mailing_list[ 'id' ]; ?>"><?php echo stripslashes( $mailing_list[ 'name' ] ) . ' (' . $mailing_list[ 'stats' ][ 'member_count' ] . ') '; ?></option> |
|
1489 | 1489 | <?php |
1490 | 1490 | } |
1491 | 1491 | } else { |
1492 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
1492 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
1493 | 1493 | ?> |
1494 | - <option><?php echo __( "Please enter a valid API key." , 'yikes-inc-easy-mailchimp-extender' ); ?></option> |
|
1494 | + <option><?php echo __( "Please enter a valid API key.", 'yikes-inc-easy-mailchimp-extender' ); ?></option> |
|
1495 | 1495 | <?php |
1496 | 1496 | } else { |
1497 | 1497 | ?> |
1498 | - <option><?php echo __( "No lists were found on the account." , 'yikes-inc-easy-mailchimp-extender' ); ?></option> |
|
1498 | + <option><?php echo __( "No lists were found on the account.", 'yikes-inc-easy-mailchimp-extender' ); ?></option> |
|
1499 | 1499 | <?php |
1500 | 1500 | |
1501 | 1501 | } |
@@ -1504,8 +1504,8 @@ discard block |
||
1504 | 1504 | </select> |
1505 | 1505 | |
1506 | 1506 | <?php |
1507 | - if ( isset( $_GET['transient-cleared'] ) ) { |
|
1508 | - if ( 'true' === $_GET['transient-cleared'] ) { |
|
1507 | + if ( isset( $_GET[ 'transient-cleared' ] ) ) { |
|
1508 | + if ( 'true' === $_GET[ 'transient-cleared' ] ) { |
|
1509 | 1509 | ?> |
1510 | 1510 | <div class="yikes-list-refreshed-notice"> |
1511 | 1511 | <p><?php esc_attr_e( 'MailChimp list data has been succesfully refreshed.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
@@ -1514,11 +1514,11 @@ discard block |
||
1514 | 1514 | } |
1515 | 1515 | } |
1516 | 1516 | |
1517 | - if( isset( $lists ) && empty( $lists ) ) { |
|
1518 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) != 'invalid_api_key' ) { |
|
1517 | + if ( isset( $lists ) && empty( $lists ) ) { |
|
1518 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) != 'invalid_api_key' ) { |
|
1519 | 1519 | ?> |
1520 | 1520 | <p class="description"> |
1521 | - <?php printf( __( 'Head over to <a href="http://www.MailChimp.com" title="%s">MailChimp</a> to create a new list.', 'yikes-inc-easy-mailchimp-extender' ) , __( 'Create a list' , 'yikes-inc-easy-mailchimp-extender' ) ); ?> |
|
1521 | + <?php printf( __( 'Head over to <a href="http://www.MailChimp.com" title="%s">MailChimp</a> to create a new list.', 'yikes-inc-easy-mailchimp-extender' ), __( 'Create a list', 'yikes-inc-easy-mailchimp-extender' ) ); ?> |
|
1522 | 1522 | </p> |
1523 | 1523 | <?php |
1524 | 1524 | } |
@@ -1526,12 +1526,12 @@ discard block |
||
1526 | 1526 | ?> |
1527 | 1527 | </label> |
1528 | 1528 | <?php |
1529 | - if( $this->is_user_mc_api_valid_form( false ) ) { |
|
1530 | - echo submit_button( __( 'Create', 'yikes-inc-easy-mailchimp-extender' ) , 'primary' , '' , false , array( 'style' => 'margin:.75em 0 .5em 0;' ) ); |
|
1529 | + if ( $this->is_user_mc_api_valid_form( false ) ) { |
|
1530 | + echo submit_button( __( 'Create', 'yikes-inc-easy-mailchimp-extender' ), 'primary', '', false, array( 'style' => 'margin:.75em 0 .5em 0;' ) ); |
|
1531 | 1531 | } else { |
1532 | - echo '<p class="description">' . __( "Please enter a valid MailChimp API key to get started." , 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
1532 | + echo '<p class="description">' . __( "Please enter a valid MailChimp API key to get started.", 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
1533 | 1533 | ?> |
1534 | - <a href="<?php echo esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings&settings-updated=true' ) ); ?>"><?php _e( 'general settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
1534 | + <a href="<?php echo esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings&settings-updated=true' ) ); ?>"><?php _e( 'general settings', 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
1535 | 1535 | <?php |
1536 | 1536 | } |
1537 | 1537 | ?> |
@@ -1539,10 +1539,10 @@ discard block |
||
1539 | 1539 | |
1540 | 1540 | <!-- Clear API CACHE --> |
1541 | 1541 | <?php |
1542 | - if( isset( $lists ) && ! empty( $lists ) ) { |
|
1542 | + if ( isset( $lists ) && ! empty( $lists ) ) { |
|
1543 | 1543 | if ( false !== get_transient( 'yikes-easy-mailchimp-list-data' ) ) { ?> |
1544 | - <form action="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-clear-transient-data' , 'nonce' => wp_create_nonce( 'clear-mc-transient-data' ) ) ) ); ?>" method="post"> |
|
1545 | - <input type="submit" class="button-secondary clear-mailchimp-api-cache" value="<?php _e( 'Refresh Lists' , 'yikes-inc-easy-mailchimp-extender' ); ?>" /> |
|
1544 | + <form action="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-clear-transient-data', 'nonce' => wp_create_nonce( 'clear-mc-transient-data' ) ) ) ); ?>" method="post"> |
|
1545 | + <input type="submit" class="button-secondary clear-mailchimp-api-cache" value="<?php _e( 'Refresh Lists', 'yikes-inc-easy-mailchimp-extender' ); ?>" /> |
|
1546 | 1546 | </form> |
1547 | 1547 | <?php } |
1548 | 1548 | } |
@@ -1558,14 +1558,14 @@ discard block |
||
1558 | 1558 | public function generate_page_redirect_dropdown( $redirect, $redirect_page, $custom_redirect_url ) { |
1559 | 1559 | $post_types = get_post_types(); |
1560 | 1560 | ?> |
1561 | - <label id="redirect-user-to-selection-label" for="redirect-user-to-selection" class="<?php if( $redirect == '0' ) { echo 'yikes-easy-mc-hidden'; } ?>"> |
|
1562 | - <?php _e( "Select A Page or Post" , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1561 | + <label id="redirect-user-to-selection-label" for="redirect-user-to-selection" class="<?php if ( $redirect == '0' ) { echo 'yikes-easy-mc-hidden'; } ?>"> |
|
1562 | + <?php _e( "Select A Page or Post", 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1563 | 1563 | <select id="redirect-user-to-selection" name="redirect-user-to-selection" onchange="shouldWeDisplayCustomURL( this );return;"> |
1564 | 1564 | <?php |
1565 | 1565 | // loop over registered post types, and query! |
1566 | - foreach( $post_types as $registered_post_type ) { |
|
1566 | + foreach ( $post_types as $registered_post_type ) { |
|
1567 | 1567 | // exclude a few built in custom post types |
1568 | - if( ! in_array( $registered_post_type , array( 'attachment' , 'revision' , 'nav_menu_item' ) ) ) { |
|
1568 | + if ( ! in_array( $registered_post_type, array( 'attachment', 'revision', 'nav_menu_item' ) ) ) { |
|
1569 | 1569 | // run our query, to retreive the posts |
1570 | 1570 | $pages = get_posts( array( |
1571 | 1571 | 'order' => 'ASC', |
@@ -1575,12 +1575,12 @@ discard block |
||
1575 | 1575 | 'numberposts' => -1 |
1576 | 1576 | ) ); |
1577 | 1577 | // only show cpt's that have posts assigned |
1578 | - if( !empty( $pages ) ) { |
|
1578 | + if ( ! empty( $pages ) ) { |
|
1579 | 1579 | ?> |
1580 | - <optgroup label="<?php echo ucwords( str_replace( '_' , ' ' , $registered_post_type ) ); ?>"> |
|
1580 | + <optgroup label="<?php echo ucwords( str_replace( '_', ' ', $registered_post_type ) ); ?>"> |
|
1581 | 1581 | <?php |
1582 | - foreach( $pages as $page ) { |
|
1583 | - ?><option <?php selected( $redirect_page , $page->ID ); ?> value="<?php echo $page->ID; ?>"><?php echo $page->post_title; ?></option><?php |
|
1582 | + foreach ( $pages as $page ) { |
|
1583 | + ?><option <?php selected( $redirect_page, $page->ID ); ?> value="<?php echo $page->ID; ?>"><?php echo $page->post_title; ?></option><?php |
|
1584 | 1584 | } |
1585 | 1585 | ?> |
1586 | 1586 | <option <?php selected( $redirect_page, 'custom_url' ); ?> value="custom_url"><?php echo __( 'Custom URL', 'yikes-inc-easy-mailchimp-extender' ); ?></option> |
@@ -1592,8 +1592,8 @@ discard block |
||
1592 | 1592 | ?> |
1593 | 1593 | </select> |
1594 | 1594 | |
1595 | - <label name="custom-redirect-url" class="custom_redirect_url_label" <?php if( ! isset( $redirect_page ) || $redirect_page != 'custom_url' ) { echo 'style="display:none;"'; } ?>> |
|
1596 | - <?php _e( "Enter Custom URL" , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1595 | + <label name="custom-redirect-url" class="custom_redirect_url_label" <?php if ( ! isset( $redirect_page ) || $redirect_page != 'custom_url' ) { echo 'style="display:none;"'; } ?>> |
|
1596 | + <?php _e( "Enter Custom URL", 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1597 | 1597 | <input type="text" class="widefat custom-redirect-url" name="custom-redirect-url" value="<?php echo $custom_redirect_url; ?>" /> |
1598 | 1598 | </label> |
1599 | 1599 | |
@@ -1610,11 +1610,11 @@ discard block |
||
1610 | 1610 | public function generate_show_some_love_container() { |
1611 | 1611 | // if no active add-ons are installed, |
1612 | 1612 | // lets display our branding and add-on sidebar |
1613 | - if( get_option( 'yikes-easy-mc-active-addons' , array() ) == array() ) { |
|
1613 | + if ( get_option( 'yikes-easy-mc-active-addons', array() ) == array() ) { |
|
1614 | 1614 | |
1615 | 1615 | /* On Edit Forms Page Display Upsell to Customizer */ |
1616 | 1616 | $screen = get_current_screen(); |
1617 | - if( isset( $screen ) && $screen->base == 'admin_page_yikes-mailchimp-edit-form' ) { |
|
1617 | + if ( isset( $screen ) && $screen->base == 'admin_page_yikes-mailchimp-edit-form' ) { |
|
1618 | 1618 | ?> |
1619 | 1619 | |
1620 | 1620 | <div class="postbox yikes-easy-mc-postbox show-some-love-container"> |
@@ -1628,11 +1628,11 @@ discard block |
||
1628 | 1628 | <div class="postbox yikes-easy-mc-postbox show-some-love-container"> |
1629 | 1629 | |
1630 | 1630 | <!-- review us container --> |
1631 | - <h3 data-alt-text="<?php _e( 'About YIKES Inc.', 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( 'Show YIKES Inc. Some Love' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
1631 | + <h3 data-alt-text="<?php _e( 'About YIKES Inc.', 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( 'Show YIKES Inc. Some Love', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
1632 | 1632 | <div id="review-yikes-easy-mc" class="inside"> |
1633 | 1633 | |
1634 | 1634 | <p> |
1635 | - <?php _e( 'Leave a review' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1635 | + <?php _e( 'Leave a review', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1636 | 1636 | <p class="star-container"> |
1637 | 1637 | <a href="https://wordpress.org/support/view/plugin-reviews/yikes-inc-easy-mailchimp-extender" target="_blank"> |
1638 | 1638 | <b class="dashicons dashicons-star-filled"></b> |
@@ -1644,21 +1644,21 @@ discard block |
||
1644 | 1644 | </p> |
1645 | 1645 | </p> |
1646 | 1646 | |
1647 | - <?php _e( 'Tweet about it' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1647 | + <?php _e( 'Tweet about it', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1648 | 1648 | <p class="sidebar-container"> |
1649 | 1649 | <a href="https://twitter.com/share" class="twitter-share-button" data-url="https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/" data-text="I'm using the Easy Forms for MailChimp plugin by @YikesInc to grow my mailing list - it's awesome! -" data-hashtags="MailChimp">Tweet</a> |
1650 | 1650 | <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> |
1651 | 1651 | </p> |
1652 | 1652 | |
1653 | - <?php _e( 'Vote that the plugin works' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1653 | + <?php _e( 'Vote that the plugin works', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1654 | 1654 | <p class="sidebar-container"> |
1655 | 1655 | <a href="https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/" target="_blank"> |
1656 | - <?php _e( 'Vote for Compatibility' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1656 | + <?php _e( 'Vote for Compatibility', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1657 | 1657 | </a> |
1658 | 1658 | </p> |
1659 | 1659 | </div> |
1660 | 1660 | |
1661 | - <p class="description sidebar-footer-text"><?php printf( __( "This plugin made with %s by %s" , 'yikes-inc-easy-mailchimp-extender' ), '<span class="dashicons dashicons-heart yikes-love"></span>', '<a href="http://www.yikesinc.com" target="_blank" title="YIKES Inc.">YIKES Inc.</a>' ); ?> </p> |
|
1661 | + <p class="description sidebar-footer-text"><?php printf( __( "This plugin made with %s by %s", 'yikes-inc-easy-mailchimp-extender' ), '<span class="dashicons dashicons-heart yikes-love"></span>', '<a href="http://www.yikesinc.com" target="_blank" title="YIKES Inc.">YIKES Inc.</a>' ); ?> </p> |
|
1662 | 1662 | |
1663 | 1663 | <section id="about-yikes-inc" class="inside"> |
1664 | 1664 | <a href="https://www.yikesinc.com" target="_blank" title="YIKES Inc."> |
@@ -1674,10 +1674,10 @@ discard block |
||
1674 | 1674 | <div class="postbox yikes-easy-mc-postbox"> |
1675 | 1675 | |
1676 | 1676 | <!-- review us container --> |
1677 | - <h3><?php _e( 'Easy Forms for MailChimp Add-Ons' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
1677 | + <h3><?php _e( 'Easy Forms for MailChimp Add-Ons', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
1678 | 1678 | <div id="review-yikes-easy-mc" class="inside"> |
1679 | - <p><?php _e( "Check out available add-ons for some seriously enhanced features." , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
1680 | - <p><a class="button-secondary" href="<?php echo esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-addons' ) ); ?>" title="<?php _e( 'View Add-Ons' , 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( 'View Add-Ons' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></p> |
|
1679 | + <p><?php _e( "Check out available add-ons for some seriously enhanced features.", 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
1680 | + <p><a class="button-secondary" href="<?php echo esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-addons' ) ); ?>" title="<?php _e( 'View Add-Ons', 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( 'View Add-Ons', 'yikes-inc-easy-mailchimp-extender' ); ?></a></p> |
|
1681 | 1681 | </div> |
1682 | 1682 | |
1683 | 1683 | </div> |
@@ -1702,76 +1702,76 @@ discard block |
||
1702 | 1702 | public function generate_form_editor( $form_fields, $list_id, $merge_variables, $interest_groups ) { |
1703 | 1703 | |
1704 | 1704 | // if no list id, die! |
1705 | - if( ! $list_id ) { |
|
1706 | - die( __( "We've encountered an error. No list ID was sent." , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
1705 | + if ( ! $list_id ) { |
|
1706 | + die( __( "We've encountered an error. No list ID was sent.", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
1707 | 1707 | } |
1708 | 1708 | |
1709 | - if( ! $merge_variables ) { |
|
1710 | - die( __( "We've encountered an error. Reload the page and try again. If the error persists, please reach out to support." , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
1709 | + if ( ! $merge_variables ) { |
|
1710 | + die( __( "We've encountered an error. Reload the page and try again. If the error persists, please reach out to support.", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
1711 | 1711 | } |
1712 | 1712 | |
1713 | - if( ! empty( $form_fields ) ) { |
|
1713 | + if ( ! empty( $form_fields ) ) { |
|
1714 | 1714 | |
1715 | 1715 | // find any fields that are assigned to this form, that don't exist in MailChimp |
1716 | 1716 | // or else were going to run into issues when we submit the form |
1717 | 1717 | $available_merge_variables = array(); |
1718 | 1718 | $available_interest_groups = array(); |
1719 | 1719 | |
1720 | - $assigned_fields= array(); |
|
1720 | + $assigned_fields = array(); |
|
1721 | 1721 | |
1722 | 1722 | // loop over merge variables |
1723 | - if( ! empty( $merge_variables['data'][0]['merge_vars'] ) ) { |
|
1724 | - foreach( $merge_variables['data'][0]['merge_vars'] as $merge_tag ) { |
|
1725 | - $available_merge_variables[] = $merge_tag['tag']; |
|
1723 | + if ( ! empty( $merge_variables[ 'data' ][ 0 ][ 'merge_vars' ] ) ) { |
|
1724 | + foreach ( $merge_variables[ 'data' ][ 0 ][ 'merge_vars' ] as $merge_tag ) { |
|
1725 | + $available_merge_variables[ ] = $merge_tag[ 'tag' ]; |
|
1726 | 1726 | } |
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | // loop over interest groups |
1730 | - if( ! empty( $interest_groups ) && ! isset( $interest_groups['error'] ) ) { |
|
1731 | - foreach( $interest_groups as $interest_group ) { |
|
1732 | - $available_interest_groups[] = $interest_group['id']; |
|
1730 | + if ( ! empty( $interest_groups ) && ! isset( $interest_groups[ 'error' ] ) ) { |
|
1731 | + foreach ( $interest_groups as $interest_group ) { |
|
1732 | + $available_interest_groups[ ] = $interest_group[ 'id' ]; |
|
1733 | 1733 | } |
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | // build our assigned fields |
1737 | - foreach( $form_fields as $field => $value ) { |
|
1738 | - $assigned_fields[] = $field; |
|
1737 | + foreach ( $form_fields as $field => $value ) { |
|
1738 | + $assigned_fields[ ] = $field; |
|
1739 | 1739 | } |
1740 | 1740 | |
1741 | - $merged_fields = array_merge( $available_merge_variables , $available_interest_groups ); |
|
1742 | - $excluded_fields = array_diff( $assigned_fields , $merged_fields ); |
|
1741 | + $merged_fields = array_merge( $available_merge_variables, $available_interest_groups ); |
|
1742 | + $excluded_fields = array_diff( $assigned_fields, $merged_fields ); |
|
1743 | 1743 | |
1744 | 1744 | $i = 1; |
1745 | - foreach( $form_fields as $field ) { |
|
1745 | + foreach ( $form_fields as $field ) { |
|
1746 | 1746 | |
1747 | - if( isset( $field['merge'] ) ) { |
|
1747 | + if ( isset( $field[ 'merge' ] ) ) { |
|
1748 | 1748 | ?> |
1749 | - <section class="draggable" id="<?php echo $field['merge']; ?>"> |
|
1749 | + <section class="draggable" id="<?php echo $field[ 'merge' ]; ?>"> |
|
1750 | 1750 | <!-- top --> |
1751 | 1751 | <a href="#" class="expansion-section-title settings-sidebar"> |
1752 | - <span class="dashicons dashicons-plus"></span><?php echo stripslashes( $field['label'] ); ?> |
|
1753 | - <?php if( in_array( $field['merge'] , $excluded_fields ) ) { ?> |
|
1754 | - <img src="<?php echo YIKES_MC_URL . 'includes/images/warning.svg'; ?>" class="field-doesnt-exist-notice" title="<?php _e( 'Field no longer exists.' , 'yikes-inc-easy-mailchimp-extender' ); ?>" alt="<?php _e( 'Field no longer exists.' , 'yikes-inc-easy-mailchimp-extender' ); ?>"> |
|
1752 | + <span class="dashicons dashicons-plus"></span><?php echo stripslashes( $field[ 'label' ] ); ?> |
|
1753 | + <?php if ( in_array( $field[ 'merge' ], $excluded_fields ) ) { ?> |
|
1754 | + <img src="<?php echo YIKES_MC_URL . 'includes/images/warning.svg'; ?>" class="field-doesnt-exist-notice" title="<?php _e( 'Field no longer exists.', 'yikes-inc-easy-mailchimp-extender' ); ?>" alt="<?php _e( 'Field no longer exists.', 'yikes-inc-easy-mailchimp-extender' ); ?>"> |
|
1755 | 1755 | <?php } ?> |
1756 | - <span class="field-type-text"><small><?php echo __( 'type' , 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $field['type']; ?></small></span> |
|
1756 | + <span class="field-type-text"><small><?php echo __( 'type', 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $field[ 'type' ]; ?></small></span> |
|
1757 | 1757 | </a> |
1758 | 1758 | <!-- expansion section --> |
1759 | 1759 | <div class="yikes-mc-settings-expansion-section"> |
1760 | 1760 | |
1761 | - <?php if( in_array( $field['merge'] , $excluded_fields ) ) { ?> |
|
1762 | - <p class="yikes-mc-warning-message"><?php _e( "This field no longer exists in this list. Delete this field from the form to prevent issues on your website." , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
1761 | + <?php if ( in_array( $field[ 'merge' ], $excluded_fields ) ) { ?> |
|
1762 | + <p class="yikes-mc-warning-message"><?php _e( "This field no longer exists in this list. Delete this field from the form to prevent issues on your website.", 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
1763 | 1763 | <?php } ?> |
1764 | 1764 | |
1765 | 1765 | <!-- store the label --> |
1766 | - <input type="hidden" name="field[<?php echo $field['merge']; ?>][label]" value="<?php echo $field['label']; ?>" /> |
|
1767 | - <input type="hidden" name="field[<?php echo $field['merge']; ?>][type]" value="<?php echo $field['type']; ?>" /> |
|
1768 | - <input type="hidden" name="field[<?php echo $field['merge']; ?>][merge]" value="<?php echo $field['merge']; ?>" /> |
|
1769 | - <input type="hidden" class="field-<?php echo $field['merge']; ?>-position position-input" name="field[<?php echo $field['merge']; ?>][position]" value="<?php echo $i++; ?>" /> |
|
1766 | + <input type="hidden" name="field[<?php echo $field[ 'merge' ]; ?>][label]" value="<?php echo $field[ 'label' ]; ?>" /> |
|
1767 | + <input type="hidden" name="field[<?php echo $field[ 'merge' ]; ?>][type]" value="<?php echo $field[ 'type' ]; ?>" /> |
|
1768 | + <input type="hidden" name="field[<?php echo $field[ 'merge' ]; ?>][merge]" value="<?php echo $field[ 'merge' ]; ?>" /> |
|
1769 | + <input type="hidden" class="field-<?php echo $field[ 'merge' ]; ?>-position position-input" name="field[<?php echo $field[ 'merge' ]; ?>][position]" value="<?php echo $i++; ?>" /> |
|
1770 | 1770 | |
1771 | - <?php if ( $field['type'] == 'radio' || $field['type'] == 'dropdown' || $field['type'] == 'select' ) { |
|
1772 | - $choices = json_decode( $field['choices'], true ); |
|
1771 | + <?php if ( $field[ 'type' ] == 'radio' || $field[ 'type' ] == 'dropdown' || $field[ 'type' ] == 'select' ) { |
|
1772 | + $choices = json_decode( $field[ 'choices' ], true ); |
|
1773 | 1773 | ?> |
1774 | - <input type="hidden" name="field[<?php echo $field['merge']; ?>][choices]" value='<?php echo esc_attr( json_encode( $choices ) ); ?>' /> |
|
1774 | + <input type="hidden" name="field[<?php echo $field[ 'merge' ]; ?>][choices]" value='<?php echo esc_attr( json_encode( $choices ) ); ?>' /> |
|
1775 | 1775 | <?php } ?> |
1776 | 1776 | |
1777 | 1777 | <!-- Single or Double Opt-in --> |
@@ -1783,16 +1783,16 @@ discard block |
||
1783 | 1783 | <tr valign="top"> |
1784 | 1784 | <td scope="row"> |
1785 | 1785 | <label for="merge-tag"> |
1786 | - <?php _e( 'Merge Tag' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1786 | + <?php _e( 'Merge Tag', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1787 | 1787 | </label> |
1788 | 1788 | </td> |
1789 | 1789 | <td> |
1790 | - <input class="widefat merge-tag-text" type="text" readonly value="<?php echo $field['merge']; ?>"> |
|
1790 | + <input class="widefat merge-tag-text" type="text" readonly value="<?php echo $field[ 'merge' ]; ?>"> |
|
1791 | 1791 | </td> |
1792 | 1792 | </tr> |
1793 | 1793 | |
1794 | 1794 | <!-- Placeholder Value --> |
1795 | - <?php switch( $field['type'] ) { |
|
1795 | + <?php switch ( $field[ 'type' ] ) { |
|
1796 | 1796 | |
1797 | 1797 | case 'text': |
1798 | 1798 | case 'email': |
@@ -1807,12 +1807,12 @@ discard block |
||
1807 | 1807 | <tr valign="top"> |
1808 | 1808 | <td scope="row"> |
1809 | 1809 | <label for="placeholder"> |
1810 | - <?php _e( 'Placeholder' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1810 | + <?php _e( 'Placeholder', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1811 | 1811 | </label> |
1812 | 1812 | </td> |
1813 | 1813 | <td> |
1814 | - <input type="text" class="widefat" name="field[<?php echo $field['merge']; ?>][placeholder]" value="<?php echo isset( $field['placeholder'] ) ? $field['placeholder'] : '' ; ?>" /> |
|
1815 | - <p class="description"><small><?php _e( "Assign a placeholder value to this field.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1814 | + <input type="text" class="widefat" name="field[<?php echo $field[ 'merge' ]; ?>][placeholder]" value="<?php echo isset( $field[ 'placeholder' ] ) ? $field[ 'placeholder' ] : ''; ?>" /> |
|
1815 | + <p class="description"><small><?php _e( "Assign a placeholder value to this field.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1816 | 1816 | </td> |
1817 | 1817 | </tr> |
1818 | 1818 | <?php |
@@ -1821,7 +1821,7 @@ discard block |
||
1821 | 1821 | ?> |
1822 | 1822 | |
1823 | 1823 | <!-- Default Value --> |
1824 | - <?php switch( $field['type'] ) { |
|
1824 | + <?php switch ( $field[ 'type' ] ) { |
|
1825 | 1825 | default: |
1826 | 1826 | case 'text': |
1827 | 1827 | case 'number': |
@@ -1830,17 +1830,17 @@ discard block |
||
1830 | 1830 | <tr valign="top"> |
1831 | 1831 | <td scope="row"> |
1832 | 1832 | <label for="placeholder"> |
1833 | - <?php _e( 'Default Value' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1833 | + <?php _e( 'Default Value', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1834 | 1834 | </label> |
1835 | 1835 | </td> |
1836 | 1836 | <td> |
1837 | - <input <?php if( $field['type'] != 'number' ) { ?> type="text" <?php } else { ?> type="number" <?php } ?> class="widefat" name="field[<?php echo $field['merge']; ?>][default]" <?php if( $field['type'] != 'url' ) { ?> value="<?php echo isset( $field['default'] ) ? stripslashes( wp_strip_all_tags( $field['default'] ) ) : ''; ?>" <?php } else { ?> value="<?php echo isset( $field['default'] ) ? stripslashes( wp_strip_all_tags( esc_url_raw( $field['default'] ) ) ) : ''; ?>" <?php } ?> /> |
|
1838 | - <p class="description"><small><?php _e( "Assign a default value to populate this field with on initial page load.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1837 | + <input <?php if ( $field[ 'type' ] != 'number' ) { ?> type="text" <?php } else { ?> type="number" <?php } ?> class="widefat" name="field[<?php echo $field[ 'merge' ]; ?>][default]" <?php if ( $field[ 'type' ] != 'url' ) { ?> value="<?php echo isset( $field[ 'default' ] ) ? stripslashes( wp_strip_all_tags( $field[ 'default' ] ) ) : ''; ?>" <?php } else { ?> value="<?php echo isset( $field[ 'default' ] ) ? stripslashes( wp_strip_all_tags( esc_url_raw( $field[ 'default' ] ) ) ) : ''; ?>" <?php } ?> /> |
|
1838 | + <p class="description"><small><?php _e( "Assign a default value to populate this field with on initial page load.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1839 | 1839 | <?php |
1840 | - switch( $field['type'] ) { |
|
1840 | + switch ( $field[ 'type' ] ) { |
|
1841 | 1841 | case 'text': |
1842 | 1842 | ?> |
1843 | - <p><small class="pre-defined-tag-link"><a href="#TB_inline?width=600&height=550&inlineId=pre-defined-tag-container" onclick="storeGlobalClicked( jQuery( this ) );" class="thickbox"><?php _e( 'View Pre-Defined Tags' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></small></p> |
|
1843 | + <p><small class="pre-defined-tag-link"><a href="#TB_inline?width=600&height=550&inlineId=pre-defined-tag-container" onclick="storeGlobalClicked( jQuery( this ) );" class="thickbox"><?php _e( 'View Pre-Defined Tags', 'yikes-inc-easy-mailchimp-extender' ); ?></a></small></p> |
|
1844 | 1844 | <?php |
1845 | 1845 | break; |
1846 | 1846 | } ?> |
@@ -1854,18 +1854,18 @@ discard block |
||
1854 | 1854 | <tr valign="top"> |
1855 | 1855 | <td scope="row"> |
1856 | 1856 | <label for="placeholder"> |
1857 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1857 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1858 | 1858 | </label> |
1859 | 1859 | </td> |
1860 | 1860 | <td> |
1861 | - <?php if( ! isset( $field['default_choice'] ) || empty( $field['default_choice'] ) ) { $decode = json_decode( $field['choices'], true ); $field['default_choice'] = $decode[0]; } |
|
1861 | + <?php if ( ! isset( $field[ 'default_choice' ] ) || empty( $field[ 'default_choice' ] ) ) { $decode = json_decode( $field[ 'choices' ], true ); $field[ 'default_choice' ] = $decode[ 0 ]; } |
|
1862 | 1862 | $x = 0; |
1863 | - foreach( json_decode( $field['choices'], true ) as $choice => $value ) { ?> |
|
1864 | - <label for="<?php echo $field['merge'].'-'.$x; ?>"> |
|
1865 | - <input id="<?php echo $field['merge'].'-'.$x; ?>" type="radio" name="field[<?php echo $field['merge']; ?>][default_choice]" value="<?php echo $x; ?>" <?php checked( $field['default_choice'], $x ); ?>><?php echo $value; ?> |
|
1863 | + foreach ( json_decode( $field[ 'choices' ], true ) as $choice => $value ) { ?> |
|
1864 | + <label for="<?php echo $field[ 'merge' ] . '-' . $x; ?>"> |
|
1865 | + <input id="<?php echo $field[ 'merge' ] . '-' . $x; ?>" type="radio" name="field[<?php echo $field[ 'merge' ]; ?>][default_choice]" value="<?php echo $x; ?>" <?php checked( $field[ 'default_choice' ], $x ); ?>><?php echo $value; ?> |
|
1866 | 1866 | </label> |
1867 | 1867 | <?php $x++; } ?> |
1868 | - <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1868 | + <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1869 | 1869 | </td> |
1870 | 1870 | </tr> |
1871 | 1871 | |
@@ -1877,16 +1877,16 @@ discard block |
||
1877 | 1877 | <tr valign="top"> |
1878 | 1878 | <td scope="row"> |
1879 | 1879 | <label for="placeholder"> |
1880 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1880 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1881 | 1881 | </label> |
1882 | 1882 | </td> |
1883 | 1883 | <td> |
1884 | - <select type="default" name="field[<?php echo $field['merge']; ?>][default_choice]"> |
|
1885 | - <?php foreach( json_decode( $field['choices'], true ) as $choice => $value ) { ?> |
|
1886 | - <option value="<?php echo $choice; ?>" <?php selected( $field['default_choice'] , $choice ); ?>><?php echo $value; ?></option> |
|
1884 | + <select type="default" name="field[<?php echo $field[ 'merge' ]; ?>][default_choice]"> |
|
1885 | + <?php foreach ( json_decode( $field[ 'choices' ], true ) as $choice => $value ) { ?> |
|
1886 | + <option value="<?php echo $choice; ?>" <?php selected( $field[ 'default_choice' ], $choice ); ?>><?php echo $value; ?></option> |
|
1887 | 1887 | <?php } ?> |
1888 | 1888 | </select> |
1889 | - <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1889 | + <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1890 | 1890 | </td> |
1891 | 1891 | </tr> |
1892 | 1892 | |
@@ -1906,69 +1906,69 @@ discard block |
||
1906 | 1906 | <tr valign="top"> |
1907 | 1907 | <td scope="row"> |
1908 | 1908 | <label for="placeholder"> |
1909 | - <?php _e( 'Description' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1909 | + <?php _e( 'Description', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1910 | 1910 | </label> |
1911 | 1911 | </td> |
1912 | 1912 | <td> |
1913 | - <textarea class="widefat field-description-input" name="field[<?php echo $field['merge']; ?>][description]"><?php echo isset( $field['description'] ) ? stripslashes( esc_html( $field['description'] ) ) : '' ; ?></textarea> |
|
1914 | - <p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and will provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1913 | + <textarea class="widefat field-description-input" name="field[<?php echo $field[ 'merge' ]; ?>][description]"><?php echo isset( $field[ 'description' ] ) ? stripslashes( esc_html( $field[ 'description' ] ) ) : ''; ?></textarea> |
|
1914 | + <p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and will provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1915 | 1915 | </td> |
1916 | 1916 | </tr> |
1917 | 1917 | <!-- Additional Classes --> |
1918 | 1918 | <tr valign="top"> |
1919 | 1919 | <td scope="row"> |
1920 | 1920 | <label for="placeholder"> |
1921 | - <?php _e( 'Additional Classes' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1921 | + <?php _e( 'Additional Classes', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1922 | 1922 | </label> |
1923 | 1923 | </td> |
1924 | 1924 | <td> |
1925 | - <input type="text" class="widefat" name="field[<?php echo $field['merge']; ?>][additional-classes]" value="<?php echo isset( $field['additional-classes'] ) ? stripslashes( wp_strip_all_tags( $field['additional-classes'] ) ) : '' ; ?>" /> |
|
1926 | - <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' );?></small></p> |
|
1925 | + <input type="text" class="widefat" name="field[<?php echo $field[ 'merge' ]; ?>][additional-classes]" value="<?php echo isset( $field[ 'additional-classes' ] ) ? stripslashes( wp_strip_all_tags( $field[ 'additional-classes' ] ) ) : ''; ?>" /> |
|
1926 | + <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); ?></small></p> |
|
1927 | 1927 | </td> |
1928 | 1928 | </tr> |
1929 | 1929 | <!-- Required Toggle --> |
1930 | 1930 | <tr valign="top"> |
1931 | 1931 | <td scope="row"> |
1932 | 1932 | <label for="field-required"> |
1933 | - <?php _e( 'Field Required?' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1933 | + <?php _e( 'Field Required?', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1934 | 1934 | </label> |
1935 | 1935 | </td> |
1936 | 1936 | <td> |
1937 | - <?php $checked = isset( $field['require'] ) ? $field['require'] : '0'; ?> |
|
1938 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field['merge']; ?>][require]" <?php checked( $checked , 1 ); ?> <?php if( $field['merge'] == 'EMAIL' ) { ?> disabled="disabled" checked="checked" title="<?php echo __( 'Email is a required field.' , 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
1939 | - <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1937 | + <?php $checked = isset( $field[ 'require' ] ) ? $field[ 'require' ] : '0'; ?> |
|
1938 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field[ 'merge' ]; ?>][require]" <?php checked( $checked, 1 ); ?> <?php if ( $field[ 'merge' ] == 'EMAIL' ) { ?> disabled="disabled" checked="checked" title="<?php echo __( 'Email is a required field.', 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
1939 | + <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1940 | 1940 | </td> |
1941 | 1941 | </tr> |
1942 | 1942 | <!-- Visible Toggle --> |
1943 | 1943 | <tr valign="top"> |
1944 | 1944 | <td scope="row"> |
1945 | 1945 | <label for="hide-field"> |
1946 | - <?php _e( 'Hide Field' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1946 | + <?php _e( 'Hide Field', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1947 | 1947 | </label> |
1948 | 1948 | </td> |
1949 | 1949 | <td> |
1950 | - <?php $hide = isset( $field['hide'] ) ? $field['hide'] : '0'; ?> |
|
1951 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field['merge']; ?>][hide]" <?php checked( $hide , 1 ); ?> <?php if( $field['merge'] == 'EMAIL' ) { ?> disabled="disabled" title="<?php echo __( 'Cannot toggle email field visibility.' , 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
1952 | - <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1950 | + <?php $hide = isset( $field[ 'hide' ] ) ? $field[ 'hide' ] : '0'; ?> |
|
1951 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field[ 'merge' ]; ?>][hide]" <?php checked( $hide, 1 ); ?> <?php if ( $field[ 'merge' ] == 'EMAIL' ) { ?> disabled="disabled" title="<?php echo __( 'Cannot toggle email field visibility.', 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
1952 | + <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1953 | 1953 | </td> |
1954 | 1954 | </tr> |
1955 | 1955 | <!-- Toggle Field Label Visibility --> |
1956 | 1956 | <tr valign="top"> |
1957 | 1957 | <td scope="row"> |
1958 | 1958 | <label for="placeholder"> |
1959 | - <?php _e( 'Hide Label' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1959 | + <?php _e( 'Hide Label', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
1960 | 1960 | </label> |
1961 | 1961 | </td> |
1962 | 1962 | <td> |
1963 | - <?php $hide_label = isset( $field['hide-label'] ) ? $field['hide-label'] : '0'; ?> |
|
1964 | - <input type="checkbox" name="field[<?php echo $field['merge']; ?>][hide-label]" value="1" <?php checked( $hide_label , 1 ); ?>/> |
|
1965 | - <p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
1963 | + <?php $hide_label = isset( $field[ 'hide-label' ] ) ? $field[ 'hide-label' ] : '0'; ?> |
|
1964 | + <input type="checkbox" name="field[<?php echo $field[ 'merge' ]; ?>][hide-label]" value="1" <?php checked( $hide_label, 1 ); ?>/> |
|
1965 | + <p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
1966 | 1966 | </td> |
1967 | 1967 | </tr> |
1968 | 1968 | <!-- Display Phone/Date Formats back to the user --> |
1969 | 1969 | <!-- Phone Format Initial Load --> |
1970 | 1970 | <?php |
1971 | - switch( $field['type'] ) { |
|
1971 | + switch ( $field[ 'type' ] ) { |
|
1972 | 1972 | /* Store the phone format, for properly regex pattern */ |
1973 | 1973 | case 'phone': |
1974 | 1974 | case 'birthday': |
@@ -1978,23 +1978,23 @@ discard block |
||
1978 | 1978 | <td scope="row"> |
1979 | 1979 | <label for="placeholder"> |
1980 | 1980 | <?php |
1981 | - switch( $field['type'] ) { |
|
1981 | + switch ( $field[ 'type' ] ) { |
|
1982 | 1982 | default: |
1983 | 1983 | case 'birthday': |
1984 | - $type = __( 'Date Format' , 'yikes-inc-easy-mailchimp-extender' ); |
|
1985 | - $format = ( isset( $field['date_format'] ) ) ? $field['date_format'] : 'MM/DD'; |
|
1984 | + $type = __( 'Date Format', 'yikes-inc-easy-mailchimp-extender' ); |
|
1985 | + $format = ( isset( $field[ 'date_format' ] ) ) ? $field[ 'date_format' ] : 'MM/DD'; |
|
1986 | 1986 | $format_name = 'date_format'; |
1987 | 1987 | break; |
1988 | 1988 | |
1989 | 1989 | case 'date': |
1990 | - $type = __( 'Date Format' , 'yikes-inc-easy-mailchimp-extender' ); |
|
1991 | - $format = ( isset( $field['date_format'] ) ) ? $field['date_format'] : 'MM/DD/YYYY'; |
|
1990 | + $type = __( 'Date Format', 'yikes-inc-easy-mailchimp-extender' ); |
|
1991 | + $format = ( isset( $field[ 'date_format' ] ) ) ? $field[ 'date_format' ] : 'MM/DD/YYYY'; |
|
1992 | 1992 | $format_name = 'date_format'; |
1993 | 1993 | break; |
1994 | 1994 | |
1995 | 1995 | case 'phone': |
1996 | - $type = __( 'Phone Format' , 'yikes-inc-easy-mailchimp-extender' ); |
|
1997 | - $format = ( ( $field['phone_format'] == 'none' ) ? __( 'International', 'yikes-inc-easy-mailchimp-extender' ) : $field['phone_format'] . ' - (###) ### - ####' ); |
|
1996 | + $type = __( 'Phone Format', 'yikes-inc-easy-mailchimp-extender' ); |
|
1997 | + $format = ( ( $field[ 'phone_format' ] == 'none' ) ? __( 'International', 'yikes-inc-easy-mailchimp-extender' ) : $field[ 'phone_format' ] . ' - (###) ### - ####' ); |
|
1998 | 1998 | $format_name = 'phone_format'; |
1999 | 1999 | break; |
2000 | 2000 | } |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | </td> |
2005 | 2005 | <td> |
2006 | 2006 | <strong><?php echo $format; ?></strong> |
2007 | - <input type="hidden" name="field[<?php echo $field['merge']; ?>][<?php echo $format_name; ?>]" value="<?php echo $format; ?>" /> |
|
2007 | + <input type="hidden" name="field[<?php echo $field[ 'merge' ]; ?>][<?php echo $format_name; ?>]" value="<?php echo $format; ?>" /> |
|
2008 | 2008 | <p class="description"><small> |
2009 | 2009 | <?php printf( __( 'To change the %s please head over to <a href="%s" title="MailChimp" target="_blank">MailChimp</a>. If you alter the format, you should re-import this field.', 'yikes-inc-easy-mailchimp-extender' ), strtolower( $type ), esc_url( 'http://www.mailchimp.com' ) ); ?> |
2010 | 2010 | </small></p> |
@@ -2025,8 +2025,8 @@ discard block |
||
2025 | 2025 | </td> |
2026 | 2026 | <td> |
2027 | 2027 | <span class="toggle-container"> |
2028 | - <a href="#" class="close-form-expansion"><?php _e( "Close" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
2029 | - <a href="#" class="remove-field" alt="<?php echo $field['merge']; ?>"><?php _e( "Remove Field" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
2028 | + <a href="#" class="close-form-expansion"><?php _e( "Close", 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
2029 | + <a href="#" class="remove-field" alt="<?php echo $field[ 'merge' ]; ?>"><?php _e( "Remove Field", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
2030 | 2030 | </span> |
2031 | 2031 | </td> |
2032 | 2032 | </tr> |
@@ -2042,35 +2042,35 @@ discard block |
||
2042 | 2042 | } else { // THIS IS AN INTEREST GROUP! |
2043 | 2043 | |
2044 | 2044 | ?> |
2045 | - <section class="draggable" id="<?php echo $field['group_id']; ?>"> |
|
2045 | + <section class="draggable" id="<?php echo $field[ 'group_id' ]; ?>"> |
|
2046 | 2046 | <!-- top --> |
2047 | 2047 | <a href="#" class="expansion-section-title settings-sidebar"> |
2048 | - <span class="dashicons dashicons-plus"></span><?php echo stripslashes( $field['label'] ); ?> |
|
2049 | - <?php if( in_array( $field['group_id'] , $excluded_fields ) ) { ?> |
|
2050 | - <img src="<?php echo YIKES_MC_URL . 'includes/images/warning.svg'; ?>" class="field-no-longer-exists-warning" title="<?php _e( 'Field no longer exists.' , 'yikes-inc-easy-mailchimp-extender' ); ?>" alt="<?php _e( 'Field no longer exists.' , 'yikes-inc-easy-mailchimp-extender' ); ?>"> |
|
2048 | + <span class="dashicons dashicons-plus"></span><?php echo stripslashes( $field[ 'label' ] ); ?> |
|
2049 | + <?php if ( in_array( $field[ 'group_id' ], $excluded_fields ) ) { ?> |
|
2050 | + <img src="<?php echo YIKES_MC_URL . 'includes/images/warning.svg'; ?>" class="field-no-longer-exists-warning" title="<?php _e( 'Field no longer exists.', 'yikes-inc-easy-mailchimp-extender' ); ?>" alt="<?php _e( 'Field no longer exists.', 'yikes-inc-easy-mailchimp-extender' ); ?>"> |
|
2051 | 2051 | <?php } ?> |
2052 | - <span class="field-type-text"><small><?php echo __( 'type' , 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $field['type']; ?></small></span> |
|
2052 | + <span class="field-type-text"><small><?php echo __( 'type', 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $field[ 'type' ]; ?></small></span> |
|
2053 | 2053 | </a> |
2054 | 2054 | <!-- expansion section --> |
2055 | 2055 | <div class="yikes-mc-settings-expansion-section"> |
2056 | 2056 | |
2057 | 2057 | <!-- check if this field exists in the available interest group array --> |
2058 | - <?php if( in_array( $field['group_id'] , $excluded_fields ) ) { ?> |
|
2059 | - <p class="yikes-mc-warning-message"><?php _e( "This field no longer exists in this list. Delete this field from the form to prevent issues on the front end." , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
2058 | + <?php if ( in_array( $field[ 'group_id' ], $excluded_fields ) ) { ?> |
|
2059 | + <p class="yikes-mc-warning-message"><?php _e( "This field no longer exists in this list. Delete this field from the form to prevent issues on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
2060 | 2060 | <?php } ?> |
2061 | 2061 | |
2062 | 2062 | <!-- store the label --> |
2063 | - <input type="hidden" name="field[<?php echo $field['group_id']; ?>][label]" value="<?php echo $field['label']; ?>" /> |
|
2064 | - <input type="hidden" name="field[<?php echo $field['group_id']; ?>][type]" value="<?php echo $field['type']; ?>" /> |
|
2065 | - <input type="hidden" name="field[<?php echo $field['group_id']; ?>][group_id]" value="<?php echo $field['group_id']; ?>" /> |
|
2066 | - <input type="hidden" name="field[<?php echo $field['group_id']; ?>][groups]" value='<?php echo esc_attr( json_encode( json_decode( $field['groups'], true ) ) ); ?>' /> |
|
2063 | + <input type="hidden" name="field[<?php echo $field[ 'group_id' ]; ?>][label]" value="<?php echo $field[ 'label' ]; ?>" /> |
|
2064 | + <input type="hidden" name="field[<?php echo $field[ 'group_id' ]; ?>][type]" value="<?php echo $field[ 'type' ]; ?>" /> |
|
2065 | + <input type="hidden" name="field[<?php echo $field[ 'group_id' ]; ?>][group_id]" value="<?php echo $field[ 'group_id' ]; ?>" /> |
|
2066 | + <input type="hidden" name="field[<?php echo $field[ 'group_id' ]; ?>][groups]" value='<?php echo esc_attr( json_encode( json_decode( $field[ 'groups' ], true ) ) ); ?>' /> |
|
2067 | 2067 | |
2068 | 2068 | <!-- Single or Double Opt-in --> |
2069 | 2069 | <p class="type-container"><!-- necessary to prevent skipping on slideToggle(); --> |
2070 | 2070 | |
2071 | 2071 | <table class="form-table form-field-container"> |
2072 | 2072 | <!-- Default Value --> |
2073 | - <?php switch( $field['type'] ) { |
|
2073 | + <?php switch ( $field[ 'type' ] ) { |
|
2074 | 2074 | |
2075 | 2075 | default: |
2076 | 2076 | case 'radio': |
@@ -2079,26 +2079,26 @@ discard block |
||
2079 | 2079 | <tr valign="top"> |
2080 | 2080 | <td scope="row"> |
2081 | 2081 | <label for="placeholder"> |
2082 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2082 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2083 | 2083 | </label> |
2084 | 2084 | </td> |
2085 | 2085 | <td> |
2086 | 2086 | <?php |
2087 | - if( $field['type'] != 'checkboxes' ) { |
|
2088 | - if( !isset( $field['default_choice'] ) ) { $field['default_choice'] = json_decode( stripslashes( $field['groups'] ) , true ); } |
|
2087 | + if ( $field[ 'type' ] != 'checkboxes' ) { |
|
2088 | + if ( ! isset( $field[ 'default_choice' ] ) ) { $field[ 'default_choice' ] = json_decode( stripslashes( $field[ 'groups' ] ), true ); } |
|
2089 | 2089 | } else { |
2090 | - if( !isset( $field['default_choice'] ) ) { $field['default_choice'] = array(); } |
|
2090 | + if ( ! isset( $field[ 'default_choice' ] ) ) { $field[ 'default_choice' ] = array(); } |
|
2091 | 2091 | } |
2092 | 2092 | $i = 0; |
2093 | - foreach( json_decode( $field['groups'], true ) as $group ) { ?> |
|
2094 | - <label for="<?php echo $field['group_id'].'-'.$i; ?>"> |
|
2095 | - <input id="<?php echo $field['group_id'].'-'.$i; ?>" type="<?php if( $field['type'] == 'radio' || $field['type'] == 'hidden' ) { ?>radio<?php } else if( $field['type'] == 'checkboxes' ) { ?>checkbox<?php } ?>" name="field[<?php echo $field['group_id']; ?>][default_choice]<?php if( $field['type'] == 'checkboxes' ) {echo '[]';}?>" value="<?php echo $i; ?>" <?php if( $field['type'] == 'radio' || $field['type'] == 'hidden' ) { checked( $field['default_choice'][0] , $i ); } else if( $field['type'] == 'checkboxes' ) { if( in_array( $i , $field['default_choice'] ) ) { echo 'checked="checked"'; } }?>><?php echo stripslashes( str_replace( '' , '\'' , $group['name'] ) ); ?> |
|
2093 | + foreach ( json_decode( $field[ 'groups' ], true ) as $group ) { ?> |
|
2094 | + <label for="<?php echo $field[ 'group_id' ] . '-' . $i; ?>"> |
|
2095 | + <input id="<?php echo $field[ 'group_id' ] . '-' . $i; ?>" type="<?php if ( $field[ 'type' ] == 'radio' || $field[ 'type' ] == 'hidden' ) { ?>radio<?php } else if ( $field[ 'type' ] == 'checkboxes' ) { ?>checkbox<?php } ?>" name="field[<?php echo $field[ 'group_id' ]; ?>][default_choice]<?php if ( $field[ 'type' ] == 'checkboxes' ) {echo '[]'; }?>" value="<?php echo $i; ?>" <?php if ( $field[ 'type' ] == 'radio' || $field[ 'type' ] == 'hidden' ) { checked( $field[ 'default_choice' ][ 0 ], $i ); } else if ( $field[ 'type' ] == 'checkboxes' ) { if ( in_array( $i, $field[ 'default_choice' ] ) ) { echo 'checked="checked"'; } }?>><?php echo stripslashes( str_replace( '', '\'', $group[ 'name' ] ) ); ?> |
|
2096 | 2096 | </label> |
2097 | 2097 | <?php |
2098 | 2098 | $i++; |
2099 | 2099 | } |
2100 | 2100 | ?> |
2101 | - <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
2101 | + <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
2102 | 2102 | </td> |
2103 | 2103 | </tr> |
2104 | 2104 | |
@@ -2110,16 +2110,16 @@ discard block |
||
2110 | 2110 | <tr valign="top"> |
2111 | 2111 | <td scope="row"> |
2112 | 2112 | <label for="placeholder"> |
2113 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2113 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2114 | 2114 | </label> |
2115 | 2115 | </td> |
2116 | 2116 | <td> |
2117 | - <select type="default" name="field[<?php echo $field['group_id']; ?>][default_choice]"> |
|
2118 | - <?php $i = 0; foreach( json_decode( stripslashes_deep( $field['groups'] ) , true ) as $group ) { ?> |
|
2119 | - <option value="<?php echo $i; ?>" <?php selected( $field['default_choice'] , $i ); ?>><?php echo stripslashes( $group['name'] ); ?></option> |
|
2117 | + <select type="default" name="field[<?php echo $field[ 'group_id' ]; ?>][default_choice]"> |
|
2118 | + <?php $i = 0; foreach ( json_decode( stripslashes_deep( $field[ 'groups' ] ), true ) as $group ) { ?> |
|
2119 | + <option value="<?php echo $i; ?>" <?php selected( $field[ 'default_choice' ], $i ); ?>><?php echo stripslashes( $group[ 'name' ] ); ?></option> |
|
2120 | 2120 | <?php $i++; } ?> |
2121 | 2121 | </select> |
2122 | - <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
2122 | + <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
2123 | 2123 | </td> |
2124 | 2124 | </tr> |
2125 | 2125 | |
@@ -2133,12 +2133,12 @@ discard block |
||
2133 | 2133 | <tr valign="top"> |
2134 | 2134 | <td scope="row"> |
2135 | 2135 | <label for="placeholder"> |
2136 | - <?php _e( 'Description' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2136 | + <?php _e( 'Description', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2137 | 2137 | </label> |
2138 | 2138 | </td> |
2139 | 2139 | <td> |
2140 | - <textarea class="widefat field-description-input" name="field[<?php echo $field['group_id']; ?>][description]"><?php echo isset( $field['description'] ) ? stripslashes( esc_html( $field['description'] ) ) : '' ; ?></textarea> |
|
2141 | - <p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
2140 | + <textarea class="widefat field-description-input" name="field[<?php echo $field[ 'group_id' ]; ?>][description]"><?php echo isset( $field[ 'description' ] ) ? stripslashes( esc_html( $field[ 'description' ] ) ) : ''; ?></textarea> |
|
2141 | + <p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
2142 | 2142 | </td> |
2143 | 2143 | </tr> |
2144 | 2144 | |
@@ -2146,51 +2146,51 @@ discard block |
||
2146 | 2146 | <tr valign="top"> |
2147 | 2147 | <td scope="row"> |
2148 | 2148 | <label for="placeholder"> |
2149 | - <?php _e( 'Additional Classes' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2149 | + <?php _e( 'Additional Classes', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2150 | 2150 | </label> |
2151 | 2151 | </td> |
2152 | 2152 | <td> |
2153 | - <input type="text" class="widefat" name="field[<?php echo $field['group_id']; ?>][additional-classes]" value="<?php echo isset( $field['additional-classes'] ) ? stripslashes( wp_strip_all_tags( $field['additional-classes'] ) ) : '' ; ?>" /> |
|
2154 | - <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' );?></small></p> |
|
2153 | + <input type="text" class="widefat" name="field[<?php echo $field[ 'group_id' ]; ?>][additional-classes]" value="<?php echo isset( $field[ 'additional-classes' ] ) ? stripslashes( wp_strip_all_tags( $field[ 'additional-classes' ] ) ) : ''; ?>" /> |
|
2154 | + <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); ?></small></p> |
|
2155 | 2155 | </td> |
2156 | 2156 | </tr> |
2157 | 2157 | <!-- Required Toggle --> |
2158 | 2158 | <tr valign="top"> |
2159 | 2159 | <td scope="row"> |
2160 | 2160 | <label for="field-required"> |
2161 | - <?php _e( 'Field Required?' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2161 | + <?php _e( 'Field Required?', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2162 | 2162 | </label> |
2163 | 2163 | </td> |
2164 | 2164 | <td> |
2165 | - <?php $checked = isset( $field['require'] ) ? $field['require'] : '0'; ?> |
|
2166 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field['group_id']; ?>][require]" <?php checked( $checked , 1 ); ?>> |
|
2167 | - <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
2165 | + <?php $checked = isset( $field[ 'require' ] ) ? $field[ 'require' ] : '0'; ?> |
|
2166 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field[ 'group_id' ]; ?>][require]" <?php checked( $checked, 1 ); ?>> |
|
2167 | + <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
2168 | 2168 | </td> |
2169 | 2169 | </tr> |
2170 | 2170 | <!-- Visible Toggle --> |
2171 | 2171 | <tr valign="top"> |
2172 | 2172 | <td scope="row"> |
2173 | 2173 | <label for="hide-field"> |
2174 | - <?php _e( 'Hide Field' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2174 | + <?php _e( 'Hide Field', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2175 | 2175 | </label> |
2176 | 2176 | </td> |
2177 | 2177 | <td> |
2178 | - <?php $hide = isset( $field['hide'] ) ? $field['hide'] : '0'; ?> |
|
2179 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field['group_id']; ?>][hide]" <?php checked( $hide , 1 ); ?>> |
|
2180 | - <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
2178 | + <?php $hide = isset( $field[ 'hide' ] ) ? $field[ 'hide' ] : '0'; ?> |
|
2179 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $field[ 'group_id' ]; ?>][hide]" <?php checked( $hide, 1 ); ?>> |
|
2180 | + <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
2181 | 2181 | </td> |
2182 | 2182 | </tr> |
2183 | 2183 | <!-- Toggle Field Label Visibility --> |
2184 | 2184 | <tr valign="top"> |
2185 | 2185 | <td scope="row"> |
2186 | 2186 | <label for="placeholder"> |
2187 | - <?php _e( 'Hide Label' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2187 | + <?php _e( 'Hide Label', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
2188 | 2188 | </label> |
2189 | 2189 | </td> |
2190 | 2190 | <td> |
2191 | - <?php $hide = isset( $field['hide-label'] ) ? $field['hide-label'] : '0'; ?> |
|
2192 | - <input type="checkbox" name="field[<?php echo $field['group_id']; ?>][hide-label]" value="1" <?php checked( $hide , 1 ); ?>/> |
|
2193 | - <p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
2191 | + <?php $hide = isset( $field[ 'hide-label' ] ) ? $field[ 'hide-label' ] : '0'; ?> |
|
2192 | + <input type="checkbox" name="field[<?php echo $field[ 'group_id' ]; ?>][hide-label]" value="1" <?php checked( $hide, 1 ); ?>/> |
|
2193 | + <p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
2194 | 2194 | </td> |
2195 | 2195 | </tr> |
2196 | 2196 | <!-- Toggle Buttons --> |
@@ -2200,8 +2200,8 @@ discard block |
||
2200 | 2200 | </td> |
2201 | 2201 | <td> |
2202 | 2202 | <span class="toggle-container"> |
2203 | - <a href="#" class="close-form-expansion"><?php _e( "Close" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
2204 | - <a href="#" class="remove-field" alt="<?php echo $field['group_id']; ?>"><?php _e( "Remove Field" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
2203 | + <a href="#" class="close-form-expansion"><?php _e( "Close", 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
2204 | + <a href="#" class="remove-field" alt="<?php echo $field[ 'group_id' ]; ?>"><?php _e( "Remove Field", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
2205 | 2205 | </span> |
2206 | 2206 | </td> |
2207 | 2207 | </tr> |
@@ -2215,38 +2215,38 @@ discard block |
||
2215 | 2215 | } |
2216 | 2216 | } else { |
2217 | 2217 | ?> |
2218 | - <h4 class="no-fields-assigned-notice non-draggable-yikes"><em><?php _e( 'No fields are assigned to this form. Select fields from the right hand column to add to this form.' , 'yikes-inc-easy-mailchimp-extender' ); ?></em></h4> |
|
2218 | + <h4 class="no-fields-assigned-notice non-draggable-yikes"><em><?php _e( 'No fields are assigned to this form. Select fields from the right hand column to add to this form.', 'yikes-inc-easy-mailchimp-extender' ); ?></em></h4> |
|
2219 | 2219 | <?php |
2220 | 2220 | } |
2221 | 2221 | /* Pre Defined Merge Tag Container - Always rendered so the modal appears and links are clickable on initial page load */ |
2222 | 2222 | add_thickbox(); |
2223 | 2223 | // enqueue jquery qtip for our tooltip |
2224 | - wp_enqueue_script( 'jquery-qtip-tooltip' , YIKES_MC_URL . 'admin/js/min/jquery.qtip.min.js' , array( 'jquery' ) ); |
|
2225 | - wp_enqueue_style( 'jquery-qtip-style' , YIKES_MC_URL . 'admin/css/jquery.qtip.min.css' ); |
|
2224 | + wp_enqueue_script( 'jquery-qtip-tooltip', YIKES_MC_URL . 'admin/js/min/jquery.qtip.min.js', array( 'jquery' ) ); |
|
2225 | + wp_enqueue_style( 'jquery-qtip-style', YIKES_MC_URL . 'admin/css/jquery.qtip.min.css' ); |
|
2226 | 2226 | $available_tags = array( |
2227 | 2227 | array( |
2228 | 2228 | 'tag' => '{page_title}', |
2229 | - 'description' => '<h4 class="tooltip-title">' . __( 'Page Title', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{page_title}</small></h4><hr />' . __( 'Pre-populate the field with the current page or post title that the user is on when opting in to your mailing list.' , 'yikes-inc-easy-mailchimp-extender' ), |
|
2229 | + 'description' => '<h4 class="tooltip-title">' . __( 'Page Title', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{page_title}</small></h4><hr />' . __( 'Pre-populate the field with the current page or post title that the user is on when opting in to your mailing list.', 'yikes-inc-easy-mailchimp-extender' ), |
|
2230 | 2230 | 'title' => __( 'Page Title', 'yikes-inc-easy-mailchimp-extender' ) |
2231 | 2231 | ), |
2232 | 2232 | array( |
2233 | 2233 | 'tag' => '{page_id}', |
2234 | - 'description' => '<h4 class="tooltip-title">' . __( 'Page ID', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{page_id}</small></h4><hr />' . __( 'Pre-populate the field with the current page or post ID that the user is on when opting in to your mailing list.' , 'yikes-inc-easy-mailchimp-extender' ), |
|
2234 | + 'description' => '<h4 class="tooltip-title">' . __( 'Page ID', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{page_id}</small></h4><hr />' . __( 'Pre-populate the field with the current page or post ID that the user is on when opting in to your mailing list.', 'yikes-inc-easy-mailchimp-extender' ), |
|
2235 | 2235 | 'title' => __( 'Page ID', 'yikes-inc-easy-mailchimp-extender' ) |
2236 | 2236 | ), |
2237 | 2237 | array( |
2238 | 2238 | 'tag' => '{page_url}', |
2239 | - 'description' => '<h4 class="tooltip-title">' . __( 'Page URL', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{page_url}</small></h4><hr />' . __( 'Pre-populate the field with the current page URL that the user is on when opting in to your mailing list.' , 'yikes-inc-easy-mailchimp-extender' ), |
|
2239 | + 'description' => '<h4 class="tooltip-title">' . __( 'Page URL', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{page_url}</small></h4><hr />' . __( 'Pre-populate the field with the current page URL that the user is on when opting in to your mailing list.', 'yikes-inc-easy-mailchimp-extender' ), |
|
2240 | 2240 | 'title' => __( 'Page URL', 'yikes-inc-easy-mailchimp-extender' ) |
2241 | 2241 | ), |
2242 | 2242 | array( |
2243 | 2243 | 'tag' => '{blog_name}', |
2244 | - 'description' => '<h4 class="tooltip-title">' . __( 'Blog Name', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{blog_name}</small></h4><hr />' . __( 'Pre-populate the field with the current blog name that the user is on when opting in to your mailing list. This is especially helpful for multi-site networks.' , 'yikes-inc-easy-mailchimp-extender' ), |
|
2244 | + 'description' => '<h4 class="tooltip-title">' . __( 'Blog Name', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{blog_name}</small></h4><hr />' . __( 'Pre-populate the field with the current blog name that the user is on when opting in to your mailing list. This is especially helpful for multi-site networks.', 'yikes-inc-easy-mailchimp-extender' ), |
|
2245 | 2245 | 'title' => __( 'Blog Name', 'yikes-inc-easy-mailchimp-extender' ) |
2246 | 2246 | ), |
2247 | 2247 | array( |
2248 | 2248 | 'tag' => '{user_logged_in}', |
2249 | - 'description' => '<h4 class="tooltip-title">' . __( 'User Logged In', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{user_logged_in}</small></h4><hr />' . __( 'Detects if a user is logged in and pre-populates the field with an appropriate value.' , 'yikes-inc-easy-mailchimp-extender' ), |
|
2249 | + 'description' => '<h4 class="tooltip-title">' . __( 'User Logged In', 'yikes-inc-easy-mailchimp-extender' ) . ' | <small>{user_logged_in}</small></h4><hr />' . __( 'Detects if a user is logged in and pre-populates the field with an appropriate value.', 'yikes-inc-easy-mailchimp-extender' ), |
|
2250 | 2250 | 'title' => __( 'User Logged In', 'yikes-inc-easy-mailchimp-extender' ) |
2251 | 2251 | ), |
2252 | 2252 | ); |
@@ -2274,17 +2274,17 @@ discard block |
||
2274 | 2274 | <div id="pre-defined-tag-container"> |
2275 | 2275 | <input type="hidden" value="" class="clicked-input"> |
2276 | 2276 | <div id="pre-defined-tag-interior-container"> |
2277 | - <h3><?php _e( 'Pre Defined Tags' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
2278 | - <p class="description"><?php _e( 'You can use any of the following tags to populate a MailChimp text field with dynamic content. This can be used to determine which page the user signed up on, if the user was logged in and more.' , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
2277 | + <h3><?php _e( 'Pre Defined Tags', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
2278 | + <p class="description"><?php _e( 'You can use any of the following tags to populate a MailChimp text field with dynamic content. This can be used to determine which page the user signed up on, if the user was logged in and more.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
2279 | 2279 | <ul> |
2280 | - <?php foreach( apply_filters( 'yikes-mailchimp-custom-default-value-tags' , $available_tags ) as $tag ) { ?> |
|
2280 | + <?php foreach ( apply_filters( 'yikes-mailchimp-custom-default-value-tags', $available_tags ) as $tag ) { ?> |
|
2281 | 2281 | <li class="tooltop-tag"> |
2282 | 2282 | <!-- link/tag --> |
2283 | - <a href="#" onclick="populateDefaultValue( '<?php echo $tag['tag']; ?>' );return false;" data-attr-tag="<?php echo $tag['tag']; ?>" title="<?php echo $tag['title']; ?>"><?php echo $tag['title']; ?></a> |
|
2283 | + <a href="#" onclick="populateDefaultValue( '<?php echo $tag[ 'tag' ]; ?>' );return false;" data-attr-tag="<?php echo $tag[ 'tag' ]; ?>" title="<?php echo $tag[ 'title' ]; ?>"><?php echo $tag[ 'title' ]; ?></a> |
|
2284 | 2284 | <!-- help icon --> |
2285 | 2285 | <span class="dashicons dashicons-editor-help"></span> |
2286 | 2286 | <!-- tooltip --> |
2287 | - <div class="tooltiptext qtip-bootstrap yikes-easy-mc-hidden"><?php echo $tag['description']; ?></div> |
|
2287 | + <div class="tooltiptext qtip-bootstrap yikes-easy-mc-hidden"><?php echo $tag[ 'description' ]; ?></div> |
|
2288 | 2288 | </li> |
2289 | 2289 | <?php } ?> |
2290 | 2290 | </ul> |
@@ -2300,32 +2300,32 @@ discard block |
||
2300 | 2300 | * - |
2301 | 2301 | * @parameters - $list_id - pass in the list ID to retreive merge variables from |
2302 | 2302 | */ |
2303 | - public function build_available_merge_vars( $form_fields , $available_merge_variables ) { |
|
2303 | + public function build_available_merge_vars( $form_fields, $available_merge_variables ) { |
|
2304 | 2304 | $fields_assigned_to_form = array(); |
2305 | - if( !empty( $form_fields ) ) { |
|
2306 | - foreach( $form_fields as $assigned_field ) { |
|
2305 | + if ( ! empty( $form_fields ) ) { |
|
2306 | + foreach ( $form_fields as $assigned_field ) { |
|
2307 | 2307 | // print_r( $assigned_field) ; |
2308 | 2308 | // switch between merge variables and interest groups |
2309 | - if( isset( $assigned_field['merge'] ) ) { |
|
2310 | - $fields_assigned_to_form[] = $assigned_field['merge']; |
|
2309 | + if ( isset( $assigned_field[ 'merge' ] ) ) { |
|
2310 | + $fields_assigned_to_form[ ] = $assigned_field[ 'merge' ]; |
|
2311 | 2311 | } |
2312 | 2312 | } |
2313 | 2313 | } |
2314 | - if( !empty( $available_merge_variables['data'][0] ) ) { |
|
2314 | + if ( ! empty( $available_merge_variables[ 'data' ][ 0 ] ) ) { |
|
2315 | 2315 | ?><ul id="available-fields"><?php |
2316 | - foreach( $available_merge_variables['data'][0]['merge_vars'] as $merge_var ) { |
|
2317 | - if( in_array( $merge_var['tag'] , $fields_assigned_to_form ) ) { |
|
2316 | + foreach ( $available_merge_variables[ 'data' ][ 0 ][ 'merge_vars' ] as $merge_var ) { |
|
2317 | + if ( in_array( $merge_var[ 'tag' ], $fields_assigned_to_form ) ) { |
|
2318 | 2318 | ?> |
2319 | - <li class="available-form-field not-available" alt="<?php echo $merge_var['tag']; ?>" data-attr-field-type="<?php echo $merge_var['field_type']; ?>" data-attr-field-name="<?php echo $merge_var['name']; ?>" data-attr-form-id="<?php echo $available_merge_variables['data'][0]['id']; ?>" title="<?php _e( 'Already assigned to your form' , 'yikes-inc-easy-mailchimp-extender' ); ?>" disabled="disabled"><?php echo stripslashes( $merge_var['name'] ); if( $merge_var['req'] == '1' ) { echo ' <span class="field-required" title="' . __( 'required field' , 'yikes-inc-easy-mailchimp-extender' ) . '">*</span>'; } ?> <small class="field-type-text"><?php echo $merge_var['field_type']; ?></small></li> |
|
2319 | + <li class="available-form-field not-available" alt="<?php echo $merge_var[ 'tag' ]; ?>" data-attr-field-type="<?php echo $merge_var[ 'field_type' ]; ?>" data-attr-field-name="<?php echo $merge_var[ 'name' ]; ?>" data-attr-form-id="<?php echo $available_merge_variables[ 'data' ][ 0 ][ 'id' ]; ?>" title="<?php _e( 'Already assigned to your form', 'yikes-inc-easy-mailchimp-extender' ); ?>" disabled="disabled"><?php echo stripslashes( $merge_var[ 'name' ] ); if ( $merge_var[ 'req' ] == '1' ) { echo ' <span class="field-required" title="' . __( 'required field', 'yikes-inc-easy-mailchimp-extender' ) . '">*</span>'; } ?> <small class="field-type-text"><?php echo $merge_var[ 'field_type' ]; ?></small></li> |
|
2320 | 2320 | <?php |
2321 | 2321 | } else { |
2322 | 2322 | ?> |
2323 | - <li class="available-form-field" alt="<?php echo $merge_var['tag']; ?>" data-attr-field-type="<?php echo $merge_var['field_type']; ?>" data-attr-field-name="<?php echo $merge_var['name']; ?>" data-attr-form-id="<?php echo $available_merge_variables['data'][0]['id']; ?>"><?php echo stripslashes( $merge_var['name'] ); if( $merge_var['req'] == '1' ) { echo ' <span class="field-required" title="' . __( 'required field' , 'yikes-inc-easy-mailchimp-extender' ) . '">*</span>'; } ?> <small class="field-type-text"><?php echo $merge_var['field_type']; ?></small></li> |
|
2323 | + <li class="available-form-field" alt="<?php echo $merge_var[ 'tag' ]; ?>" data-attr-field-type="<?php echo $merge_var[ 'field_type' ]; ?>" data-attr-field-name="<?php echo $merge_var[ 'name' ]; ?>" data-attr-form-id="<?php echo $available_merge_variables[ 'data' ][ 0 ][ 'id' ]; ?>"><?php echo stripslashes( $merge_var[ 'name' ] ); if ( $merge_var[ 'req' ] == '1' ) { echo ' <span class="field-required" title="' . __( 'required field', 'yikes-inc-easy-mailchimp-extender' ) . '">*</span>'; } ?> <small class="field-type-text"><?php echo $merge_var[ 'field_type' ]; ?></small></li> |
|
2324 | 2324 | <?php |
2325 | 2325 | } |
2326 | 2326 | } |
2327 | 2327 | ?></ul> |
2328 | - <a href="#" class="add-field-to-editor button-secondary yikes-easy-mc-hidden" style="display:none;"><small><span class="dashicons dashicons-arrow-left-alt add-to-form-builder-arrow"></span> <?php _e( 'Add to Form Builder' , 'yikes-inc-easy-mailchimp-extender' ); ?></small></a> |
|
2328 | + <a href="#" class="add-field-to-editor button-secondary yikes-easy-mc-hidden" style="display:none;"><small><span class="dashicons dashicons-arrow-left-alt add-to-form-builder-arrow"></span> <?php _e( 'Add to Form Builder', 'yikes-inc-easy-mailchimp-extender' ); ?></small></a> |
|
2329 | 2329 | <?php |
2330 | 2330 | } |
2331 | 2331 | } |
@@ -2337,30 +2337,30 @@ discard block |
||
2337 | 2337 | * - |
2338 | 2338 | * @parameters - $list_id - pass in the list ID to retreive merge variables from |
2339 | 2339 | */ |
2340 | - public function build_available_interest_groups( $form_fields , $available_interest_groups , $list_id ) { |
|
2340 | + public function build_available_interest_groups( $form_fields, $available_interest_groups, $list_id ) { |
|
2341 | 2341 | $fields_assigned_to_form = array(); |
2342 | - if( !empty( $form_fields ) ) { |
|
2343 | - foreach( $form_fields as $assigned_interest_group ) { |
|
2344 | - if( isset( $assigned_interest_group['group_id'] ) ) { |
|
2345 | - $fields_assigned_to_form[] = $assigned_interest_group['group_id']; |
|
2342 | + if ( ! empty( $form_fields ) ) { |
|
2343 | + foreach ( $form_fields as $assigned_interest_group ) { |
|
2344 | + if ( isset( $assigned_interest_group[ 'group_id' ] ) ) { |
|
2345 | + $fields_assigned_to_form[ ] = $assigned_interest_group[ 'group_id' ]; |
|
2346 | 2346 | } |
2347 | 2347 | } |
2348 | 2348 | } |
2349 | - if( !empty( $available_interest_groups) ) { |
|
2349 | + if ( ! empty( $available_interest_groups ) ) { |
|
2350 | 2350 | ?><ul id="available-interest-groups"><?php |
2351 | - foreach( $available_interest_groups as $interest_group ) { |
|
2352 | - if( in_array( $interest_group['id'] , $fields_assigned_to_form ) ) { |
|
2351 | + foreach ( $available_interest_groups as $interest_group ) { |
|
2352 | + if ( in_array( $interest_group[ 'id' ], $fields_assigned_to_form ) ) { |
|
2353 | 2353 | ?> |
2354 | - <li class="available-interest-group not-available" alt="<?php echo $interest_group['id']; ?>" data-attr-field-name="<?php echo stripslashes( $interest_group['name'] ); ?>" data-attr-field-type="<?php echo $interest_group['form_field']; ?>" data-attr-form-id="<?php echo $list_id; ?>" title="<?php _e( 'Already assigned to your form' , 'yikes-inc-easy-mailchimp-extender' ); ?>" disabled="disabled"><?php echo stripslashes( $interest_group['name'] ); ?> <small class="field-type-text"><?php echo $interest_group['form_field']; ?></small></li> |
|
2354 | + <li class="available-interest-group not-available" alt="<?php echo $interest_group[ 'id' ]; ?>" data-attr-field-name="<?php echo stripslashes( $interest_group[ 'name' ] ); ?>" data-attr-field-type="<?php echo $interest_group[ 'form_field' ]; ?>" data-attr-form-id="<?php echo $list_id; ?>" title="<?php _e( 'Already assigned to your form', 'yikes-inc-easy-mailchimp-extender' ); ?>" disabled="disabled"><?php echo stripslashes( $interest_group[ 'name' ] ); ?> <small class="field-type-text"><?php echo $interest_group[ 'form_field' ]; ?></small></li> |
|
2355 | 2355 | <?php |
2356 | 2356 | } else { |
2357 | 2357 | ?> |
2358 | - <li class="available-interest-group" alt="<?php echo $interest_group['id']; ?>" data-attr-field-name="<?php echo stripslashes( $interest_group['name'] ); ?>" data-attr-field-type="<?php echo $interest_group['form_field']; ?>" data-attr-form-id="<?php echo $list_id; ?>"><?php echo stripslashes( $interest_group['name'] ); ?> <small class="field-type-text"><?php echo $interest_group['form_field']; ?></small></li> |
|
2358 | + <li class="available-interest-group" alt="<?php echo $interest_group[ 'id' ]; ?>" data-attr-field-name="<?php echo stripslashes( $interest_group[ 'name' ] ); ?>" data-attr-field-type="<?php echo $interest_group[ 'form_field' ]; ?>" data-attr-form-id="<?php echo $list_id; ?>"><?php echo stripslashes( $interest_group[ 'name' ] ); ?> <small class="field-type-text"><?php echo $interest_group[ 'form_field' ]; ?></small></li> |
|
2359 | 2359 | <?php |
2360 | 2360 | } |
2361 | 2361 | } |
2362 | 2362 | ?></ul> |
2363 | - <a href="#" class="add-interest-group-to-editor button-secondary yikes-easy-mc-hidden" style="display:none;"><small><span class="dashicons dashicons-arrow-left-alt add-to-form-builder-arrow"></span> <?php _e( 'Add to Form Builder' , 'yikes-inc-easy-mailchimp-extender' ); ?></small></a> |
|
2363 | + <a href="#" class="add-interest-group-to-editor button-secondary yikes-easy-mc-hidden" style="display:none;"><small><span class="dashicons dashicons-arrow-left-alt add-to-form-builder-arrow"></span> <?php _e( 'Add to Form Builder', 'yikes-inc-easy-mailchimp-extender' ); ?></small></a> |
|
2364 | 2364 | <?php |
2365 | 2365 | } |
2366 | 2366 | } |
@@ -2372,9 +2372,9 @@ discard block |
||
2372 | 2372 | * - must clean up db tables , ensure what data is going in and what is needed... |
2373 | 2373 | */ |
2374 | 2374 | public function yikes_easy_mailchimp_create_form() { |
2375 | - $nonce = $_REQUEST['nonce']; |
|
2376 | - if( ! wp_verify_nonce( $nonce, 'create_mailchimp_form' ) ) { |
|
2377 | - die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2375 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2376 | + if ( ! wp_verify_nonce( $nonce, 'create_mailchimp_form' ) ) { |
|
2377 | + die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2378 | 2378 | } |
2379 | 2379 | global $wpdb; |
2380 | 2380 | /* Default values */ |
@@ -2397,7 +2397,7 @@ discard block |
||
2397 | 2397 | ) |
2398 | 2398 | ); |
2399 | 2399 | // setup our default error message array |
2400 | - $error_settings= json_encode( |
|
2400 | + $error_settings = json_encode( |
|
2401 | 2401 | array( |
2402 | 2402 | 'success' => '', |
2403 | 2403 | 'general-error' => '', |
@@ -2411,9 +2411,9 @@ discard block |
||
2411 | 2411 | $wpdb->insert( |
2412 | 2412 | $wpdb->prefix . 'yikes_easy_mc_forms', |
2413 | 2413 | array( |
2414 | - 'list_id' => $_POST['associated-list'], |
|
2415 | - 'form_name' => stripslashes( $_POST['form-name'] ), |
|
2416 | - 'form_description' => stripslashes( $_POST['form-description'] ), |
|
2414 | + 'list_id' => $_POST[ 'associated-list' ], |
|
2415 | + 'form_name' => stripslashes( $_POST[ 'form-name' ] ), |
|
2416 | + 'form_description' => stripslashes( $_POST[ 'form-description' ] ), |
|
2417 | 2417 | 'fields' => '', |
2418 | 2418 | 'custom_styles' => 0, |
2419 | 2419 | 'custom_template' => 0, |
@@ -2434,33 +2434,33 @@ discard block |
||
2434 | 2434 | '%s', // form description |
2435 | 2435 | '%s', // fields |
2436 | 2436 | '%s', // custom styles |
2437 | - '%d', // custom template |
|
2438 | - '%d', // send welcome email |
|
2439 | - '%s', // redirect user |
|
2440 | - '%s', // redirect page |
|
2441 | - '%s', // submission |
|
2442 | - '%s', // optin |
|
2437 | + '%d', // custom template |
|
2438 | + '%d', // send welcome email |
|
2439 | + '%s', // redirect user |
|
2440 | + '%s', // redirect page |
|
2441 | + '%s', // submission |
|
2442 | + '%s', // optin |
|
2443 | 2443 | '%s', // error |
2444 | 2444 | '%s', // custom notifications |
2445 | - '%d', // impressions # |
|
2446 | - '%d', // submissions # |
|
2445 | + '%d', // impressions # |
|
2446 | + '%d', // submissions # |
|
2447 | 2447 | '%s', // custom fields |
2448 | 2448 | ) |
2449 | 2449 | ); |
2450 | 2450 | |
2451 | 2451 | // if an error occurs during the form creation process |
2452 | - if( $wpdb->insert_id == '0' ) { |
|
2452 | + if ( $wpdb->insert_id == '0' ) { |
|
2453 | 2453 | // write it to the error log |
2454 | 2454 | // if the form was not created successfully |
2455 | - if( get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
2455 | + if ( get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
2456 | 2456 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
2457 | 2457 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
2458 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $wpdb->last_error , __( "Creating a new form" , 'yikes-inc-easy-mailchimp-extender' ) , __( "Forms" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2458 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $wpdb->last_error, __( "Creating a new form", 'yikes-inc-easy-mailchimp-extender' ), __( "Forms", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2459 | 2459 | } |
2460 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&sql_error='.urlencode( $wpdb->last_error ) ) ) ); |
|
2460 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&sql_error=' . urlencode( $wpdb->last_error ) ) ) ); |
|
2461 | 2461 | } else { |
2462 | 2462 | // redirect the user to the new form edit page |
2463 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id='.$wpdb->insert_id ) ) ); |
|
2463 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $wpdb->insert_id ) ) ); |
|
2464 | 2464 | } |
2465 | 2465 | exit(); |
2466 | 2466 | die(); |
@@ -2474,11 +2474,11 @@ discard block |
||
2474 | 2474 | */ |
2475 | 2475 | public function yikes_easy_mailchimp_delete_form() { |
2476 | 2476 | // grab & store our variables ( associated list & form name ) |
2477 | - $nonce = $_REQUEST['nonce']; |
|
2478 | - $post_id_to_delete = $_REQUEST['mailchimp-form']; |
|
2477 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2478 | + $post_id_to_delete = $_REQUEST[ 'mailchimp-form' ]; |
|
2479 | 2479 | // verify our nonce |
2480 | - if( ! wp_verify_nonce( $nonce, 'delete-mailchimp-form-'.$post_id_to_delete ) ) { |
|
2481 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
2480 | + if ( ! wp_verify_nonce( $nonce, 'delete-mailchimp-form-' . $post_id_to_delete ) ) { |
|
2481 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
2482 | 2482 | } |
2483 | 2483 | global $wpdb; |
2484 | 2484 | /* Working Insert Function */ |
@@ -2503,39 +2503,39 @@ discard block |
||
2503 | 2503 | */ |
2504 | 2504 | public function yikes_easy_mailchimp_duplicate_form() { |
2505 | 2505 | // grab & store our variables ( associated list & form name ) |
2506 | - $nonce = $_REQUEST['nonce']; |
|
2507 | - $post_id_to_clone = $_REQUEST['mailchimp-form']; |
|
2506 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2507 | + $post_id_to_clone = $_REQUEST[ 'mailchimp-form' ]; |
|
2508 | 2508 | // verify our nonce |
2509 | - if( ! wp_verify_nonce( $nonce, 'duplicate-mailchimp-form-'.$post_id_to_clone ) ) { |
|
2510 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
2509 | + if ( ! wp_verify_nonce( $nonce, 'duplicate-mailchimp-form-' . $post_id_to_clone ) ) { |
|
2510 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
2511 | 2511 | } |
2512 | 2512 | global $wpdb; |
2513 | 2513 | /* Working Insert Function */ |
2514 | - $form_data = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "yikes_easy_mc_forms WHERE id = ".$post_id_to_clone.""); |
|
2514 | + $form_data = $wpdb->get_row( "SELECT * FROM " . $wpdb->prefix . "yikes_easy_mc_forms WHERE id = " . $post_id_to_clone . "" ); |
|
2515 | 2515 | // create empty array to populate with row data |
2516 | 2516 | $data = array(); |
2517 | 2517 | // build a data array to duplicate |
2518 | - foreach( $form_data as $id => $value ) { |
|
2518 | + foreach ( $form_data as $id => $value ) { |
|
2519 | 2519 | // skip the ID field this is unique |
2520 | - if( $id != 'id' ) { |
|
2520 | + if ( $id != 'id' ) { |
|
2521 | 2521 | // append -Copy- to our new form |
2522 | - if( $id == 'form_name' ) { |
|
2522 | + if ( $id == 'form_name' ) { |
|
2523 | 2523 | $value = $value . ' - Copy -'; |
2524 | 2524 | } |
2525 | 2525 | // reset the impressions and submissions back to 0 |
2526 | - if( $id == 'impressions' || $id == 'submissions' ) { |
|
2526 | + if ( $id == 'impressions' || $id == 'submissions' ) { |
|
2527 | 2527 | $value = '0'; |
2528 | 2528 | } |
2529 | 2529 | |
2530 | 2530 | // add data to our array |
2531 | - $data[$id] = $value; |
|
2531 | + $data[ $id ] = $value; |
|
2532 | 2532 | } |
2533 | 2533 | } |
2534 | 2534 | // insert our new data |
2535 | - if( $wpdb->insert( |
|
2535 | + if ( $wpdb->insert( |
|
2536 | 2536 | $wpdb->prefix . 'yikes_easy_mc_forms', |
2537 | 2537 | apply_filters( 'yikes-mailchimp-duplicate-form-data', $data ) |
2538 | - ) === FALSE ) { |
|
2538 | + ) === FALSE ) { |
|
2539 | 2539 | // redirect the user to the manage forms page, display error |
2540 | 2540 | wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp&duplicated-form=false' ) ) ); |
2541 | 2541 | } else { |
@@ -2551,15 +2551,15 @@ discard block |
||
2551 | 2551 | */ |
2552 | 2552 | public function yikes_easy_mailchimp_reset_impression_stats() { |
2553 | 2553 | // grab & store our variables ( associated list & form name ) |
2554 | - $nonce = $_REQUEST['nonce']; |
|
2555 | - $form_id_to_reset = $_REQUEST['mailchimp-form']; |
|
2554 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2555 | + $form_id_to_reset = $_REQUEST[ 'mailchimp-form' ]; |
|
2556 | 2556 | // verify our nonce |
2557 | - if( ! wp_verify_nonce( $nonce, 'reset-stats-mailchimp-form-'.$form_id_to_reset ) ) { |
|
2558 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
2557 | + if ( ! wp_verify_nonce( $nonce, 'reset-stats-mailchimp-form-' . $form_id_to_reset ) ) { |
|
2558 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
2559 | 2559 | } |
2560 | 2560 | global $wpdb; |
2561 | 2561 | /* Update 'Impressions/Submissions' */ |
2562 | - if( $wpdb->update( |
|
2562 | + if ( $wpdb->update( |
|
2563 | 2563 | $wpdb->prefix . 'yikes_easy_mc_forms', |
2564 | 2564 | array( |
2565 | 2565 | 'impressions' => 0, |
@@ -2583,35 +2583,35 @@ discard block |
||
2583 | 2583 | */ |
2584 | 2584 | public function yikes_easy_mailchimp_update_form() { |
2585 | 2585 | // grab & store our variables ( associated list & form name ) |
2586 | - $nonce = $_REQUEST['nonce']; |
|
2587 | - $form_id = $_REQUEST['id']; |
|
2586 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2587 | + $form_id = $_REQUEST[ 'id' ]; |
|
2588 | 2588 | |
2589 | 2589 | // store our values! |
2590 | - $list_id = $_POST['associated-list']; |
|
2591 | - $form_name = stripslashes( $_POST['form-name'] ); |
|
2592 | - $form_description = sanitize_text_field( stripslashes( $_POST['form-description'] ) ); |
|
2593 | - $send_welcome_email = $_POST['send-welcome-email']; |
|
2594 | - $redirect_user_on_submit = $_POST['redirect-user-on-submission']; |
|
2595 | - $redirect_page = $_POST['redirect-user-to-selection']; |
|
2596 | - if( isset( $_POST['custom-styles'] ) ) { |
|
2597 | - $custom_styles = $_POST['custom-styles']; |
|
2590 | + $list_id = $_POST[ 'associated-list' ]; |
|
2591 | + $form_name = stripslashes( $_POST[ 'form-name' ] ); |
|
2592 | + $form_description = sanitize_text_field( stripslashes( $_POST[ 'form-description' ] ) ); |
|
2593 | + $send_welcome_email = $_POST[ 'send-welcome-email' ]; |
|
2594 | + $redirect_user_on_submit = $_POST[ 'redirect-user-on-submission' ]; |
|
2595 | + $redirect_page = $_POST[ 'redirect-user-to-selection' ]; |
|
2596 | + if ( isset( $_POST[ 'custom-styles' ] ) ) { |
|
2597 | + $custom_styles = $_POST[ 'custom-styles' ]; |
|
2598 | 2598 | } |
2599 | 2599 | |
2600 | 2600 | // stripslashes_deep on save, to prevent foreign languages from added excessive backslashes |
2601 | - $assigned_fields = isset( $_POST['field'] ) ? json_encode( stripslashes_deep( $_POST['field'] ) ) : ''; |
|
2601 | + $assigned_fields = isset( $_POST[ 'field' ] ) ? json_encode( stripslashes_deep( $_POST[ 'field' ] ) ) : ''; |
|
2602 | 2602 | |
2603 | 2603 | // setup our custom styles serialized array |
2604 | - if( isset( $custom_styles ) ) { |
|
2604 | + if ( isset( $custom_styles ) ) { |
|
2605 | 2605 | $custom_styles = json_encode( array( |
2606 | - 'active' => $_POST['custom-styles'], |
|
2607 | - 'background_color' => $_POST['form-background-color'], |
|
2608 | - 'font_color' => $_POST['form-font-color'], |
|
2609 | - 'submit_button_color' => $_POST['form-submit-button-color'], |
|
2610 | - 'submit_button_text_color' => $_POST['form-submit-button-text-color'], |
|
2611 | - 'form_padding' => $_POST['form-padding'], |
|
2612 | - 'form_width' => $_POST['form-width'], |
|
2613 | - 'form_alignment' => $_POST['form-alignment'], |
|
2614 | - 'label_visible' => $_POST['label-visible'] |
|
2606 | + 'active' => $_POST[ 'custom-styles' ], |
|
2607 | + 'background_color' => $_POST[ 'form-background-color' ], |
|
2608 | + 'font_color' => $_POST[ 'form-font-color' ], |
|
2609 | + 'submit_button_color' => $_POST[ 'form-submit-button-color' ], |
|
2610 | + 'submit_button_text_color' => $_POST[ 'form-submit-button-text-color' ], |
|
2611 | + 'form_padding' => $_POST[ 'form-padding' ], |
|
2612 | + 'form_width' => $_POST[ 'form-width' ], |
|
2613 | + 'form_alignment' => $_POST[ 'form-alignment' ], |
|
2614 | + 'label_visible' => $_POST[ 'label-visible' ] |
|
2615 | 2615 | ) ); |
2616 | 2616 | } else { |
2617 | 2617 | $custom_styles = 0; |
@@ -2620,33 +2620,33 @@ discard block |
||
2620 | 2620 | // setup our submission settings serialized array |
2621 | 2621 | $submission_settings = json_encode( |
2622 | 2622 | array( |
2623 | - 'ajax' => $_POST['form-ajax-submission'], |
|
2624 | - 'redirect_on_submission' => $_POST['redirect-user-on-submission'], |
|
2625 | - 'redirect_page' => $_POST['redirect-user-to-selection'], |
|
2626 | - 'custom_redirect_url' => esc_url( $_POST['custom-redirect-url'] ), |
|
2627 | - 'hide_form_post_signup' => $_POST['hide-form-post-signup'], |
|
2628 | - 'replace_interests' => $_POST['replace-interest-groups'], |
|
2623 | + 'ajax' => $_POST[ 'form-ajax-submission' ], |
|
2624 | + 'redirect_on_submission' => $_POST[ 'redirect-user-on-submission' ], |
|
2625 | + 'redirect_page' => $_POST[ 'redirect-user-to-selection' ], |
|
2626 | + 'custom_redirect_url' => esc_url( $_POST[ 'custom-redirect-url' ] ), |
|
2627 | + 'hide_form_post_signup' => $_POST[ 'hide-form-post-signup' ], |
|
2628 | + 'replace_interests' => $_POST[ 'replace-interest-groups' ], |
|
2629 | 2629 | ) |
2630 | 2630 | ); |
2631 | 2631 | |
2632 | 2632 | // setup our opt-in settings serialized array |
2633 | 2633 | $optin_settings = json_encode( |
2634 | 2634 | array( |
2635 | - 'optin' => $_POST['single-double-optin'], |
|
2636 | - 'update_existing_user' => $_POST['update-existing-user'], |
|
2637 | - 'send_update_email' => $_POST['update-existing-email'], |
|
2638 | - 'send_welcome_email' => $_POST['send-welcome-email'], |
|
2635 | + 'optin' => $_POST[ 'single-double-optin' ], |
|
2636 | + 'update_existing_user' => $_POST[ 'update-existing-user' ], |
|
2637 | + 'send_update_email' => $_POST[ 'update-existing-email' ], |
|
2638 | + 'send_welcome_email' => $_POST[ 'send-welcome-email' ], |
|
2639 | 2639 | ) |
2640 | 2640 | ); |
2641 | 2641 | |
2642 | 2642 | // setup our error settings serialized array |
2643 | 2643 | $error_settings = json_encode( |
2644 | 2644 | array( |
2645 | - 'success' => trim( $_POST['yikes-easy-mc-success-message'] ) ? trim( stripslashes( $_POST['yikes-easy-mc-success-message'] ) ) : '', |
|
2646 | - 'general-error' => trim( $_POST['yikes-easy-mc-general-error-message'] ) ? trim( stripslashes( $_POST['yikes-easy-mc-general-error-message'] ) ) : '', |
|
2647 | - 'invalid-email' => trim( $_POST['yikes-easy-mc-invalid-email-message'] ) ? trim( stripslashes( $_POST['yikes-easy-mc-invalid-email-message'] ) ) : '', |
|
2648 | - 'already-subscribed' => trim( $_POST['yikes-easy-mc-user-subscribed-message'] ) ? trim( stripslashes( $_POST['yikes-easy-mc-user-subscribed-message'] ) ) : '', |
|
2649 | - 'update-link' => trim( $_POST['yikes-easy-mc-user-update-link'] ) ? trim( stripslashes( $_POST['yikes-easy-mc-user-update-link'] ) ) : '', |
|
2645 | + 'success' => trim( $_POST[ 'yikes-easy-mc-success-message' ] ) ? trim( stripslashes( $_POST[ 'yikes-easy-mc-success-message' ] ) ) : '', |
|
2646 | + 'general-error' => trim( $_POST[ 'yikes-easy-mc-general-error-message' ] ) ? trim( stripslashes( $_POST[ 'yikes-easy-mc-general-error-message' ] ) ) : '', |
|
2647 | + 'invalid-email' => trim( $_POST[ 'yikes-easy-mc-invalid-email-message' ] ) ? trim( stripslashes( $_POST[ 'yikes-easy-mc-invalid-email-message' ] ) ) : '', |
|
2648 | + 'already-subscribed' => trim( $_POST[ 'yikes-easy-mc-user-subscribed-message' ] ) ? trim( stripslashes( $_POST[ 'yikes-easy-mc-user-subscribed-message' ] ) ) : '', |
|
2649 | + 'update-link' => trim( $_POST[ 'yikes-easy-mc-user-update-link' ] ) ? trim( stripslashes( $_POST[ 'yikes-easy-mc-user-update-link' ] ) ) : '', |
|
2650 | 2650 | ) |
2651 | 2651 | ); |
2652 | 2652 | |
@@ -2655,33 +2655,33 @@ discard block |
||
2655 | 2655 | // To Do: Combine date & time so it's a single unix timestamp |
2656 | 2656 | $form_settings = json_encode( |
2657 | 2657 | array( |
2658 | - 'yikes-easy-mc-form-class-names' => trim( $_POST['yikes-easy-mc-form-class-names'] ), |
|
2659 | - 'yikes-easy-mc-inline-form' => $_POST['yikes-easy-mc-inline-form'][0], |
|
2660 | - 'yikes-easy-mc-submit-button-type' => $_POST['yikes-easy-mc-submit-button-type'][0], |
|
2661 | - 'yikes-easy-mc-submit-button-text' => trim( $_POST['yikes-easy-mc-submit-button-text'] ), |
|
2662 | - 'yikes-easy-mc-submit-button-image' => esc_url( trim( $_POST['yikes-easy-mc-submit-button-image'] ) ), |
|
2663 | - 'yikes-easy-mc-submit-button-classes' => trim( $_POST['yikes-easy-mc-submit-button-classes'] ), |
|
2664 | - 'yikes-easy-mc-form-schedule' => ( isset( $_POST['yikes-easy-mc-form-schedule'] ) ) ? '1' : '0', |
|
2665 | - 'yikes-easy-mc-form-restriction-start' => strtotime( $_POST['yikes-easy-mc-form-restriction-start-date'] . ' ' . $_POST['yikes-easy-mc-form-restriction-start-time'] ), |
|
2666 | - 'yikes-easy-mc-form-restriction-end' => strtotime( $_POST['yikes-easy-mc-form-restriction-end-date'] . ' ' . $_POST['yikes-easy-mc-form-restriction-end-time'] ), |
|
2667 | - 'yikes-easy-mc-form-restriction-pending-message' => trim( $_POST['yikes-easy-mc-form-restriction-pending-message'] ), |
|
2668 | - 'yikes-easy-mc-form-restriction-expired-message' => trim( $_POST['yikes-easy-mc-form-restriction-expired-message'] ), |
|
2669 | - 'yikes-easy-mc-form-login-required' => ( isset( $_POST['yikes-easy-mc-form-login-required'] ) ) ? '1' : '0', |
|
2670 | - 'yikes-easy-mc-form-restriction-login-message' => trim( $_POST['yikes-easy-mc-form-restriction-login-message'] ), |
|
2658 | + 'yikes-easy-mc-form-class-names' => trim( $_POST[ 'yikes-easy-mc-form-class-names' ] ), |
|
2659 | + 'yikes-easy-mc-inline-form' => $_POST[ 'yikes-easy-mc-inline-form' ][ 0 ], |
|
2660 | + 'yikes-easy-mc-submit-button-type' => $_POST[ 'yikes-easy-mc-submit-button-type' ][ 0 ], |
|
2661 | + 'yikes-easy-mc-submit-button-text' => trim( $_POST[ 'yikes-easy-mc-submit-button-text' ] ), |
|
2662 | + 'yikes-easy-mc-submit-button-image' => esc_url( trim( $_POST[ 'yikes-easy-mc-submit-button-image' ] ) ), |
|
2663 | + 'yikes-easy-mc-submit-button-classes' => trim( $_POST[ 'yikes-easy-mc-submit-button-classes' ] ), |
|
2664 | + 'yikes-easy-mc-form-schedule' => ( isset( $_POST[ 'yikes-easy-mc-form-schedule' ] ) ) ? '1' : '0', |
|
2665 | + 'yikes-easy-mc-form-restriction-start' => strtotime( $_POST[ 'yikes-easy-mc-form-restriction-start-date' ] . ' ' . $_POST[ 'yikes-easy-mc-form-restriction-start-time' ] ), |
|
2666 | + 'yikes-easy-mc-form-restriction-end' => strtotime( $_POST[ 'yikes-easy-mc-form-restriction-end-date' ] . ' ' . $_POST[ 'yikes-easy-mc-form-restriction-end-time' ] ), |
|
2667 | + 'yikes-easy-mc-form-restriction-pending-message' => trim( $_POST[ 'yikes-easy-mc-form-restriction-pending-message' ] ), |
|
2668 | + 'yikes-easy-mc-form-restriction-expired-message' => trim( $_POST[ 'yikes-easy-mc-form-restriction-expired-message' ] ), |
|
2669 | + 'yikes-easy-mc-form-login-required' => ( isset( $_POST[ 'yikes-easy-mc-form-login-required' ] ) ) ? '1' : '0', |
|
2670 | + 'yikes-easy-mc-form-restriction-login-message' => trim( $_POST[ 'yikes-easy-mc-form-restriction-login-message' ] ), |
|
2671 | 2671 | ) |
2672 | 2672 | ); |
2673 | 2673 | |
2674 | 2674 | // setup and store our notification array |
2675 | - $custom_notifications = isset( $_POST['custom-notification'] ) ? stripslashes( json_encode( $_POST['custom-notification'] ) ) : ''; |
|
2675 | + $custom_notifications = isset( $_POST[ 'custom-notification' ] ) ? stripslashes( json_encode( $_POST[ 'custom-notification' ] ) ) : ''; |
|
2676 | 2676 | |
2677 | 2677 | // additional custom fields (extensions / user defined fields) |
2678 | - if( isset( $_POST['custom-field'] ) ) { |
|
2678 | + if ( isset( $_POST[ 'custom-field' ] ) ) { |
|
2679 | 2679 | $custom_field_array = array(); |
2680 | - foreach( $_POST['custom-field'] as $custom_field => $custom_value ) { |
|
2681 | - if( is_array( $custom_value ) ) { |
|
2682 | - $custom_field_array[$custom_field] = array_filter( stripslashes_deep( $custom_value ) ); // array_filters to remove empty items (don't save them!) |
|
2680 | + foreach ( $_POST[ 'custom-field' ] as $custom_field => $custom_value ) { |
|
2681 | + if ( is_array( $custom_value ) ) { |
|
2682 | + $custom_field_array[ $custom_field ] = array_filter( stripslashes_deep( $custom_value ) ); // array_filters to remove empty items (don't save them!) |
|
2683 | 2683 | } else { |
2684 | - $custom_field_array[$custom_field] = stripslashes( $custom_value ); |
|
2684 | + $custom_field_array[ $custom_field ] = stripslashes( $custom_value ); |
|
2685 | 2685 | } |
2686 | 2686 | } |
2687 | 2687 | $custom_fields = json_encode( $custom_field_array ); |
@@ -2690,8 +2690,8 @@ discard block |
||
2690 | 2690 | } |
2691 | 2691 | |
2692 | 2692 | // verify our nonce |
2693 | - if( ! wp_verify_nonce( $nonce, 'update-mailchimp-form-'.$form_id ) ) { |
|
2694 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
2693 | + if ( ! wp_verify_nonce( $nonce, 'update-mailchimp-form-' . $form_id ) ) { |
|
2694 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
2695 | 2695 | } |
2696 | 2696 | |
2697 | 2697 | global $wpdb; |
@@ -2723,12 +2723,12 @@ discard block |
||
2723 | 2723 | '%s', // form description |
2724 | 2724 | '%s', // fields |
2725 | 2725 | '%s', // custom styles |
2726 | - '%d', //custom template |
|
2727 | - '%d', // send welcome email |
|
2728 | - '%s', // redirect user |
|
2729 | - '%s', // redirect page |
|
2730 | - '%s', // submission |
|
2731 | - '%s', // opt-in |
|
2726 | + '%d', //custom template |
|
2727 | + '%d', // send welcome email |
|
2728 | + '%s', // redirect user |
|
2729 | + '%s', // redirect page |
|
2730 | + '%s', // submission |
|
2731 | + '%s', // opt-in |
|
2732 | 2732 | '%s', // error |
2733 | 2733 | '%s', // custom notifications |
2734 | 2734 | '%s', // custom fields |
@@ -2737,7 +2737,7 @@ discard block |
||
2737 | 2737 | ); |
2738 | 2738 | |
2739 | 2739 | /* Custom action hook which allows users to update specific options when a form is updated - used in add ons */ |
2740 | - do_action( 'yikes-mailchimp-save-form', $form_id, json_decode( $custom_fields, true ) ); |
|
2740 | + do_action( 'yikes-mailchimp-save-form', $form_id, json_decode( $custom_fields, true ) ); |
|
2741 | 2741 | |
2742 | 2742 | // redirect the user to the manage forms page, display confirmation |
2743 | 2743 | wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $form_id . '&updated-form=true' ) ) ); |
@@ -2747,18 +2747,18 @@ discard block |
||
2747 | 2747 | |
2748 | 2748 | /* Unsubscribe a given user from our list */ |
2749 | 2749 | public function yikes_easy_mailchimp_unsubscribe_user() { |
2750 | - $nonce = $_REQUEST['nonce']; |
|
2751 | - $list_id = $_REQUEST['mailchimp-list']; |
|
2752 | - $email_id = $_REQUEST['email_id']; |
|
2750 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2751 | + $list_id = $_REQUEST[ 'mailchimp-list' ]; |
|
2752 | + $email_id = $_REQUEST[ 'email_id' ]; |
|
2753 | 2753 | // verify our nonce |
2754 | - if( ! wp_verify_nonce( $nonce, 'unsubscribe-user-' . $email_id ) ) { |
|
2755 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
2754 | + if ( ! wp_verify_nonce( $nonce, 'unsubscribe-user-' . $email_id ) ) { |
|
2755 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
2756 | 2756 | } |
2757 | 2757 | // only re-run the API request if our API key has changed |
2758 | 2758 | // initialize MailChimp Class |
2759 | 2759 | $api_key = yikes_get_mc_api_key(); |
2760 | 2760 | $dash_position = strpos( $api_key, '-' ); |
2761 | - if( $dash_position !== false ) { |
|
2761 | + if ( $dash_position !== false ) { |
|
2762 | 2762 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/unsubscribe.json'; |
2763 | 2763 | } |
2764 | 2764 | $response = wp_remote_post( $api_endpoint, array( |
@@ -2772,13 +2772,13 @@ discard block |
||
2772 | 2772 | 'timeout' => 10, |
2773 | 2773 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
2774 | 2774 | ) ); |
2775 | - if( ! is_wp_error( $response ) ) { |
|
2775 | + if ( ! is_wp_error( $response ) ) { |
|
2776 | 2776 | $response_body = json_decode( wp_remote_retrieve_body( $response ), true ); |
2777 | - if( isset( $response_body['error'] ) ) { |
|
2778 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
2777 | + if ( isset( $response_body[ 'error' ] ) ) { |
|
2778 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
2779 | 2779 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
2780 | 2780 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
2781 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $response_body['error'], __( "Unsubscribe User" , 'yikes-inc-easy-mailchimp-extender' ) , __( "Manage List Page" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2781 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $response_body[ 'error' ], __( "Unsubscribe User", 'yikes-inc-easy-mailchimp-extender' ), __( "Manage List Page", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2782 | 2782 | } |
2783 | 2783 | } |
2784 | 2784 | wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-mailchimp-view-list&list-id=' . $list_id . '&user-unsubscribed=true' ) ) ); |
@@ -2789,21 +2789,21 @@ discard block |
||
2789 | 2789 | |
2790 | 2790 | public function yikes_easy_mailchimp_create_missing_error_log() { |
2791 | 2791 | // grab our nonnce |
2792 | - $nonce = $_REQUEST['nonce']; |
|
2792 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2793 | 2793 | // validate nonce |
2794 | - if( !wp_verify_nonce( $nonce, 'create_error_log' ) ) { |
|
2795 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
2794 | + if ( ! wp_verify_nonce( $nonce, 'create_error_log' ) ) { |
|
2795 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
2796 | 2796 | } |
2797 | 2797 | // setup the path to the error log |
2798 | - $error_log = fopen( plugin_dir_path( __FILE__ ) . '../includes/error_log/yikes-easy-mailchimp-error-log.php' , 'w' ); |
|
2798 | + $error_log = fopen( plugin_dir_path( __FILE__ ) . '../includes/error_log/yikes-easy-mailchimp-error-log.php', 'w' ); |
|
2799 | 2799 | try { |
2800 | 2800 | // create the file |
2801 | - fwrite( $error_log , '' ); |
|
2801 | + fwrite( $error_log, '' ); |
|
2802 | 2802 | // close out |
2803 | 2803 | fclose( $error_log ); |
2804 | 2804 | wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=debug-settings&error_log_created=true' ) ) ); |
2805 | 2805 | } catch ( Exception $e ) { |
2806 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=debug-settings&error_log_created=false&error_message='.urlencode( $e->getMessage() ) ) ) ); |
|
2806 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings§ion=debug-settings&error_log_created=false&error_message=' . urlencode( $e->getMessage() ) ) ) ); |
|
2807 | 2807 | } |
2808 | 2808 | } |
2809 | 2809 | |
@@ -2814,16 +2814,16 @@ discard block |
||
2814 | 2814 | public function yikes_easy_mailchimp_clear_transient_data() { |
2815 | 2815 | $referer = wp_get_referer(); |
2816 | 2816 | // grab & store our variables ( associated list & form name ) |
2817 | - $nonce = $_REQUEST['nonce']; |
|
2817 | + $nonce = $_REQUEST[ 'nonce' ]; |
|
2818 | 2818 | // verify our nonce |
2819 | - if( ! wp_verify_nonce( $nonce, 'clear-mc-transient-data' ) ) { |
|
2820 | - wp_die( __( "We've run into an error. The security check didn't pass. Please try again." , 'yikes-inc-easy-mailchimp-extender' ) , __( "Failed nonce validation" , 'yikes-inc-easy-mailchimp-extender' ) , array( 'response' => 500 , 'back_link' => true ) ); |
|
2819 | + if ( ! wp_verify_nonce( $nonce, 'clear-mc-transient-data' ) ) { |
|
2820 | + wp_die( __( "We've run into an error. The security check didn't pass. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), __( "Failed nonce validation", 'yikes-inc-easy-mailchimp-extender' ), array( 'response' => 500, 'back_link' => true ) ); |
|
2821 | 2821 | } |
2822 | 2822 | // delete all of the integration settings list data in the cache |
2823 | 2823 | $list_ids = $this->get_mailchimp_list_ids_on_account(); |
2824 | 2824 | // confirm the list IDs was returned and is not empty |
2825 | - if( isset( $list_ids ) && ! empty( $list_ids ) ) { |
|
2826 | - foreach( $list_ids as $id ) { |
|
2825 | + if ( isset( $list_ids ) && ! empty( $list_ids ) ) { |
|
2826 | + foreach ( $list_ids as $id ) { |
|
2827 | 2827 | // loop over each interest group and delete the transient associated with it |
2828 | 2828 | // this is created & stored on the integration list page |
2829 | 2829 | // id = groupID_interest_group |
@@ -2856,12 +2856,12 @@ discard block |
||
2856 | 2856 | */ |
2857 | 2857 | public function get_mailchimp_list_ids_on_account() { |
2858 | 2858 | $api_key = yikes_get_mc_api_key(); |
2859 | - if( ! $api_key ) { |
|
2859 | + if ( ! $api_key ) { |
|
2860 | 2860 | // if no api key is set/site is not connected, return an empty array |
2861 | 2861 | return array(); |
2862 | 2862 | } |
2863 | 2863 | $dash_position = strpos( $api_key, '-' ); |
2864 | - if( $dash_position !== false ) { |
|
2864 | + if ( $dash_position !== false ) { |
|
2865 | 2865 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/list.json'; |
2866 | 2866 | } |
2867 | 2867 | $mailchimp_lists = wp_remote_post( $api_endpoint, array( |
@@ -2872,19 +2872,19 @@ discard block |
||
2872 | 2872 | 'timeout' => 10, |
2873 | 2873 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
2874 | 2874 | ) ); |
2875 | - if( ! is_wp_error( $mailchimp_lists ) ) { |
|
2875 | + if ( ! is_wp_error( $mailchimp_lists ) ) { |
|
2876 | 2876 | $list_data = json_decode( wp_remote_retrieve_body( $mailchimp_lists ), true ); |
2877 | - if( isset( $list_data['error'] ) ) { |
|
2878 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
2877 | + if ( isset( $list_data[ 'error' ] ) ) { |
|
2878 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
2879 | 2879 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
2880 | 2880 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
2881 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_data['error'], __( "Get List IDs" , 'yikes-inc-easy-mailchimp-extender' ) , __( "Clear API Cache" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2881 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_data[ 'error' ], __( "Get List IDs", 'yikes-inc-easy-mailchimp-extender' ), __( "Clear API Cache", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
2882 | 2882 | } |
2883 | 2883 | } |
2884 | 2884 | $mail_chimp_list_ids = array(); |
2885 | - if( $mailchimp_lists ) { |
|
2886 | - foreach( $list_data as $list ) { |
|
2887 | - $mail_chimp_list_ids[] = $list['id']; |
|
2885 | + if ( $mailchimp_lists ) { |
|
2886 | + foreach ( $list_data as $list ) { |
|
2887 | + $mail_chimp_list_ids[ ] = $list[ 'id' ]; |
|
2888 | 2888 | } |
2889 | 2889 | return $mail_chimp_list_ids; |
2890 | 2890 | } else { |
@@ -2900,7 +2900,7 @@ discard block |
||
2900 | 2900 | */ |
2901 | 2901 | public function yikes_mailchimp_load_helper_class() { |
2902 | 2902 | // check to see if it's already loaded up |
2903 | - if( !class_exists( 'Yikes_Inc_Easy_Mailchimp_Forms_Helper' ) ) { |
|
2903 | + if ( ! class_exists( 'Yikes_Inc_Easy_Mailchimp_Forms_Helper' ) ) { |
|
2904 | 2904 | // Include our main helper class file |
2905 | 2905 | include_once( YIKES_MC_PATH . 'admin/partials/helpers/init.php' ); |
2906 | 2906 | } |
@@ -2977,7 +2977,7 @@ discard block |
||
2977 | 2977 | * @since 6.0.4 |
2978 | 2978 | */ |
2979 | 2979 | public function check_yikes_mc_table_version() { |
2980 | - if( get_option( 'yikes_mc_database_version', '0.00' ) < '1.0' ) { |
|
2980 | + if ( get_option( 'yikes_mc_database_version', '0.00' ) < '1.0' ) { |
|
2981 | 2981 | require_once YIKES_MC_PATH . 'includes/class-yikes-inc-easy-mailchimp-extender-activator.php'; |
2982 | 2982 | global $wpdb; |
2983 | 2983 | Yikes_Inc_Easy_Mailchimp_Extender_Activator::_activate_yikes_easy_mailchimp( $wpdb ); |
@@ -10,35 +10,35 @@ discard block |
||
10 | 10 | */ |
11 | 11 | $api_key = yikes_get_mc_api_key(); |
12 | 12 | $dash_position = strpos( $api_key, '-' ); |
13 | - if( $dash_position !== false ) { |
|
13 | + if ( $dash_position !== false ) { |
|
14 | 14 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/merge-vars.json'; |
15 | 15 | } |
16 | 16 | $available_merge_variables = wp_remote_post( $api_endpoint, array( |
17 | 17 | 'body' => array( |
18 | 18 | 'apikey' => $api_key, |
19 | - 'id' => array( $form_data_array['list_id'] ), |
|
19 | + 'id' => array( $form_data_array[ 'list_id' ] ), |
|
20 | 20 | ), |
21 | 21 | 'timeout' => 10, |
22 | 22 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
23 | 23 | ) ); |
24 | 24 | $body = json_decode( wp_remote_retrieve_body( $available_merge_variables ), true ); |
25 | - if( isset( $body['error'] ) ) { |
|
26 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
25 | + if ( isset( $body[ 'error' ] ) ) { |
|
26 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
27 | 27 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
28 | 28 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
29 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $body['error'], __( "Get Merge Variables" , 'yikes-inc-easy-mailchimp-extender' ), "process_ajax.php" ); |
|
29 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $body[ 'error' ], __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), "process_ajax.php" ); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | // find and return the location of this merge field in the array |
33 | - $index = $this->findMCListIndex( $form_data_array['merge_tag'] , $body['data'][0]['merge_vars'], 'tag' ); |
|
33 | + $index = $this->findMCListIndex( $form_data_array[ 'merge_tag' ], $body[ 'data' ][ 0 ][ 'merge_vars' ], 'tag' ); |
|
34 | 34 | // store it and use it to pre-populate field data (only on initial add to form) |
35 | - $merge_field_data = $body['data'][0]['merge_vars'][$index]; |
|
35 | + $merge_field_data = $body[ 'data' ][ 0 ][ 'merge_vars' ][ $index ]; |
|
36 | 36 | ?> |
37 | -<section class="draggable" id="<?php echo $form_data_array['field_name']; ?>"> |
|
37 | +<section class="draggable" id="<?php echo $form_data_array[ 'field_name' ]; ?>"> |
|
38 | 38 | <!-- top --> |
39 | 39 | <a href="#" class="expansion-section-title settings-sidebar"> |
40 | - <span class="dashicons dashicons-plus"></span><?php echo $form_data_array['field_name']; ?> |
|
41 | - <span class="field-type-text"><small><?php echo __( 'type' , 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $form_data_array['field_type']; ?></small></span> |
|
40 | + <span class="dashicons dashicons-plus"></span><?php echo $form_data_array[ 'field_name' ]; ?> |
|
41 | + <span class="field-type-text"><small><?php echo __( 'type', 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $form_data_array[ 'field_type' ]; ?></small></span> |
|
42 | 42 | </a> |
43 | 43 | <!-- expansion section --> |
44 | 44 | <div class="yikes-mc-settings-expansion-section"> |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | <!-- Single or Double Opt-in --> |
47 | 47 | <p class="type-container form-field-container"><!-- necessary to prevent skipping on slideToggle(); --> |
48 | 48 | <!-- store the label --> |
49 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][label]" value="<?php echo $form_data_array['field_name']; ?>" /> |
|
50 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][type]" value="<?php echo $form_data_array['field_type']; ?>" /> |
|
51 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][merge]" value="<?php echo $merge_field_data['tag']; ?>" /> |
|
52 | - <input type="hidden" class="field-<?php echo $merge_field_data['tag']; ?>-position position-input" name="field[<?php echo $merge_field_data['tag']; ?>][position]" value="" /> |
|
49 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][label]" value="<?php echo $form_data_array[ 'field_name' ]; ?>" /> |
|
50 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][type]" value="<?php echo $form_data_array[ 'field_type' ]; ?>" /> |
|
51 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][merge]" value="<?php echo $merge_field_data[ 'tag' ]; ?>" /> |
|
52 | + <input type="hidden" class="field-<?php echo $merge_field_data[ 'tag' ]; ?>-position position-input" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][position]" value="" /> |
|
53 | 53 | |
54 | - <?php if ( $form_data_array['field_type'] == 'radio' || $form_data_array['field_type'] == 'dropdown' ) { ?> |
|
55 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][choices]" value='<?php echo stripslashes( json_encode( $merge_field_data['choices'] ) ); ?>' /> |
|
54 | + <?php if ( $form_data_array[ 'field_type' ] == 'radio' || $form_data_array[ 'field_type' ] == 'dropdown' ) { ?> |
|
55 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][choices]" value='<?php echo stripslashes( json_encode( $merge_field_data[ 'choices' ] ) ); ?>' /> |
|
56 | 56 | <?php } ?> |
57 | 57 | |
58 | 58 | <table class="form-table form-field-container"> |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | <tr valign="top"> |
61 | 61 | <td scope="row"> |
62 | 62 | <label for="placeholder"> |
63 | - <?php _e( 'Placeholder' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
63 | + <?php _e( 'Placeholder', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
64 | 64 | </label> |
65 | 65 | </td> |
66 | 66 | <td> |
67 | - <input type="text" class="widefat" name="field[<?php echo $merge_field_data['tag']; ?>][placeholder]" value="<?php echo isset( $merge_field_data['placeholder'] ) ? stripslashes( wp_strip_all_tags( $merge_field_data['placeholder'] ) ) : '' ; ?>" /> |
|
68 | - <p class="description"><small><?php _e( "Assign a placeholder value to this field.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
67 | + <input type="text" class="widefat" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][placeholder]" value="<?php echo isset( $merge_field_data[ 'placeholder' ] ) ? stripslashes( wp_strip_all_tags( $merge_field_data[ 'placeholder' ] ) ) : ''; ?>" /> |
|
68 | + <p class="description"><small><?php _e( "Assign a placeholder value to this field.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
69 | 69 | </td> |
70 | 70 | </tr> |
71 | 71 | <!-- Default Value --> |
72 | - <?php switch( $form_data_array['field_type'] ) { |
|
72 | + <?php switch ( $form_data_array[ 'field_type' ] ) { |
|
73 | 73 | |
74 | 74 | default: |
75 | 75 | case 'text': |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | <tr valign="top"> |
78 | 78 | <td scope="row"> |
79 | 79 | <label for="placeholder"> |
80 | - <?php _e( 'Default Value' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
80 | + <?php _e( 'Default Value', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
81 | 81 | </label> |
82 | 82 | </td> |
83 | 83 | <td> |
84 | - <input type="text" class="widefat" name="field[<?php echo $merge_field_data['tag']; ?>][default]" <?php if( $form_data_array['field_type'] != 'url' ) { ?> value="<?php echo isset( $merge_field_data['default'] ) ? stripslashes( wp_strip_all_tags( $merge_field_data['default'] ) ) : ''; ?>" <?php } else { ?> value="<?php echo isset( $merge_field_data['default'] ) ? stripslashes( wp_strip_all_tags( esc_url_raw( $merge_field_data['default'] ) ) ) : ''; } ?>" /> |
|
85 | - <p class="description"><small><?php _e( "Assign a default value to populate this field with on initial page load.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
84 | + <input type="text" class="widefat" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][default]" <?php if ( $form_data_array[ 'field_type' ] != 'url' ) { ?> value="<?php echo isset( $merge_field_data[ 'default' ] ) ? stripslashes( wp_strip_all_tags( $merge_field_data[ 'default' ] ) ) : ''; ?>" <?php } else { ?> value="<?php echo isset( $merge_field_data[ 'default' ] ) ? stripslashes( wp_strip_all_tags( esc_url_raw( $merge_field_data[ 'default' ] ) ) ) : ''; } ?>" /> |
|
85 | + <p class="description"><small><?php _e( "Assign a default value to populate this field with on initial page load.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
86 | 86 | </td> |
87 | 87 | </tr> |
88 | 88 | <?php |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | <tr valign="top"> |
94 | 94 | <td scope="row"> |
95 | 95 | <label for="placeholder"> |
96 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
96 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
97 | 97 | </label> |
98 | 98 | </td> |
99 | 99 | <td> |
100 | - <?php foreach( $merge_field_data['choices'] as $choice => $value ) { |
|
101 | - $pre_selected = !empty( $merge_field_data['default_choice'] ) ? $merge_field_data['default_choice'] : '0'; |
|
100 | + <?php foreach ( $merge_field_data[ 'choices' ] as $choice => $value ) { |
|
101 | + $pre_selected = ! empty( $merge_field_data[ 'default_choice' ] ) ? $merge_field_data[ 'default_choice' ] : '0'; |
|
102 | 102 | ?> |
103 | - <input type="radio" name="field[<?php echo $merge_field_data['tag']; ?>][default_choice]" value="<?php echo $choice; ?>" <?php checked( $pre_selected , $choice ); ?>><?php echo stripslashes( $value ); ?> |
|
103 | + <input type="radio" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][default_choice]" value="<?php echo $choice; ?>" <?php checked( $pre_selected, $choice ); ?>><?php echo stripslashes( $value ); ?> |
|
104 | 104 | <?php } ?> |
105 | - <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
105 | + <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
106 | 106 | </td> |
107 | 107 | </tr> |
108 | 108 | |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | <tr valign="top"> |
115 | 115 | <td scope="row"> |
116 | 116 | <label for="placeholder"> |
117 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
117 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
118 | 118 | </label> |
119 | 119 | </td> |
120 | 120 | <td> |
121 | - <select type="default" name="field[<?php echo $merge_field_data['tag']; ?>][default_choice]"> |
|
122 | - <?php foreach( $merge_field_data['choices'] as $choice => $value ) { |
|
123 | - $pre_selected = !empty( $merge_field_data['default_choice'] ) ? $merge_field_data['default_choice'] : '0'; |
|
121 | + <select type="default" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][default_choice]"> |
|
122 | + <?php foreach ( $merge_field_data[ 'choices' ] as $choice => $value ) { |
|
123 | + $pre_selected = ! empty( $merge_field_data[ 'default_choice' ] ) ? $merge_field_data[ 'default_choice' ] : '0'; |
|
124 | 124 | ?> |
125 | - <option value="<?php echo $choice; ?>" <?php selected( $pre_selected , $choice ); ?>><?php echo stripslashes( $value ); ?></option> |
|
125 | + <option value="<?php echo $choice; ?>" <?php selected( $pre_selected, $choice ); ?>><?php echo stripslashes( $value ); ?></option> |
|
126 | 126 | <?php } ?> |
127 | 127 | </select> |
128 | - <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
128 | + <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
129 | 129 | </td> |
130 | 130 | </tr> |
131 | 131 | |
@@ -139,36 +139,36 @@ discard block |
||
139 | 139 | <tr valign="top"> |
140 | 140 | <td scope="row"> |
141 | 141 | <label for="placeholder"> |
142 | - <?php _e( 'Additional Classes' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
142 | + <?php _e( 'Additional Classes', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
143 | 143 | </label> |
144 | 144 | </td> |
145 | 145 | <td> |
146 | - <input type="text" class="widefat" name="field[<?php echo $merge_field_data['tag']; ?>][additional-classes]" value="<?php echo isset( $form_data_array['classes'] ) ? stripslashes( esc_html( $form_data_array['classes'] ) ) : '' ; ?>" /> |
|
147 | - <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' );?></small></p> |
|
146 | + <input type="text" class="widefat" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][additional-classes]" value="<?php echo isset( $form_data_array[ 'classes' ] ) ? stripslashes( esc_html( $form_data_array[ 'classes' ] ) ) : ''; ?>" /> |
|
147 | + <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); ?></small></p> |
|
148 | 148 | </td> |
149 | 149 | </tr> |
150 | 150 | <!-- Required Toggle --> |
151 | 151 | <tr valign="top"> |
152 | 152 | <td scope="row"> |
153 | 153 | <label for="field-required"> |
154 | - <?php _e( 'Field Required?' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
154 | + <?php _e( 'Field Required?', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
155 | 155 | </label> |
156 | 156 | </td> |
157 | 157 | <td> |
158 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data['tag']; ?>][require]" <?php checked( $merge_field_data['req'] , 1 ); ?> <?php if( $merge_field_data['tag'] == 'EMAIL' ) { ?> disabled="disabled" checked="checked" title="<?php echo __( 'Email is a required field.' , 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
159 | - <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
158 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][require]" <?php checked( $merge_field_data[ 'req' ], 1 ); ?> <?php if ( $merge_field_data[ 'tag' ] == 'EMAIL' ) { ?> disabled="disabled" checked="checked" title="<?php echo __( 'Email is a required field.', 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
159 | + <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
160 | 160 | </td> |
161 | 161 | </tr> |
162 | 162 | <!-- Visible Toggle --> |
163 | 163 | <tr valign="top"> |
164 | 164 | <td scope="row"> |
165 | 165 | <label for="hide-field"> |
166 | - <?php _e( 'Hide Field' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
166 | + <?php _e( 'Hide Field', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
167 | 167 | </label> |
168 | 168 | </td> |
169 | 169 | <td> |
170 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data['tag']; ?>][hide]" <?php if( empty( $merge_field_data['show'] ) ) { echo 'checked="checked"'; } ?> <?php if( $merge_field_data['tag'] == 'EMAIL' ) { ?> disabled="disabled" title="<?php echo __( 'Cannot toggle email field visibility.' , 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
171 | - <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
170 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][hide]" <?php if ( empty( $merge_field_data[ 'show' ] ) ) { echo 'checked="checked"'; } ?> <?php if ( $merge_field_data[ 'tag' ] == 'EMAIL' ) { ?> disabled="disabled" title="<?php echo __( 'Cannot toggle email field visibility.', 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
171 | + <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
172 | 172 | </td> |
173 | 173 | </tr> |
174 | 174 | <!-- Toggle Buttons --> |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | </td> |
179 | 179 | <td> |
180 | 180 | <span class="toggle-container"> |
181 | - <a href="#" class="hide-field"><?php _e( "Close" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
182 | - <a href="#" class="remove-field" alt="<?php echo $merge_field_data['tag']; ?>"><?php _e( "Remove Field" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
181 | + <a href="#" class="hide-field"><?php _e( "Close", 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
182 | + <a href="#" class="remove-field" alt="<?php echo $merge_field_data[ 'tag' ]; ?>"><?php _e( "Remove Field", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
183 | 183 | </span> |
184 | 184 | </td> |
185 | 185 | </tr> |
@@ -3,41 +3,41 @@ discard block |
||
3 | 3 | // or build our default selection arrays etc. |
4 | 4 | $api_key = yikes_get_mc_api_key(); |
5 | 5 | $dash_position = strpos( $api_key, '-' ); |
6 | - if( $dash_position !== false ) { |
|
6 | + if ( $dash_position !== false ) { |
|
7 | 7 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/merge-vars.json'; |
8 | 8 | } |
9 | 9 | $available_merge_variables = wp_remote_post( $api_endpoint, array( |
10 | 10 | 'body' => array( |
11 | 11 | 'apikey' => $api_key, |
12 | - 'id' => array( $form_data_array['list_id'] ), |
|
12 | + 'id' => array( $form_data_array[ 'list_id' ] ), |
|
13 | 13 | ), |
14 | 14 | 'timeout' => 10, |
15 | 15 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
16 | 16 | ) ); |
17 | 17 | $body = json_decode( wp_remote_retrieve_body( $available_merge_variables ), true ); |
18 | - if( isset( $body['error'] ) ) { |
|
19 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
18 | + if ( isset( $body[ 'error' ] ) ) { |
|
19 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
20 | 20 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
21 | 21 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
22 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $body['error'], __( "Get Merge Variables" , 'yikes-inc-easy-mailchimp-extender' ) , __( "Add Field to Form" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
22 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $body[ 'error' ], __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), __( "Add Field to Form", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
23 | 23 | } |
24 | 24 | ?> |
25 | 25 | <section class="draggable" id="error-container"> |
26 | - <p><span class="dashicons dashicons-no-alt"></span> <?php printf( __( 'Error: %s', 'yikes-inc-easy-mailchimp-extender' ), $body['error'] ); ?></p> |
|
26 | + <p><span class="dashicons dashicons-no-alt"></span> <?php printf( __( 'Error: %s', 'yikes-inc-easy-mailchimp-extender' ), $body[ 'error' ] ); ?></p> |
|
27 | 27 | </section> |
28 | 28 | <?php |
29 | 29 | return; |
30 | 30 | } |
31 | 31 | // find and return the location of this merge field in the array |
32 | - $index = $this->findMCListIndex( $form_data_array['merge_tag'] , $body['data'][0]['merge_vars'], 'tag' ); |
|
32 | + $index = $this->findMCListIndex( $form_data_array[ 'merge_tag' ], $body[ 'data' ][ 0 ][ 'merge_vars' ], 'tag' ); |
|
33 | 33 | // store it and use it to pre-populate field data (only on initial add to form) |
34 | - $merge_field_data = $body['data'][0]['merge_vars'][$index]; |
|
34 | + $merge_field_data = $body[ 'data' ][ 0 ][ 'merge_vars' ][ $index ]; |
|
35 | 35 | ?> |
36 | -<section class="draggable" id="<?php echo $form_data_array['field_name']; ?>"> |
|
36 | +<section class="draggable" id="<?php echo $form_data_array[ 'field_name' ]; ?>"> |
|
37 | 37 | <!-- top --> |
38 | 38 | <a href="#" class="expansion-section-title settings-sidebar"> |
39 | - <span class="dashicons dashicons-plus" title="<?php _e( 'Expand Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>"></span><?php echo stripslashes( $form_data_array['field_name'] ); ?> |
|
40 | - <span class="field-type-text"><small><?php echo __( 'type' , 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $form_data_array['field_type']; ?></small></span> |
|
39 | + <span class="dashicons dashicons-plus" title="<?php _e( 'Expand Field', 'yikes-inc-easy-mailchimp-extender' ); ?>"></span><?php echo stripslashes( $form_data_array[ 'field_name' ] ); ?> |
|
40 | + <span class="field-type-text"><small><?php echo __( 'type', 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $form_data_array[ 'field_type' ]; ?></small></span> |
|
41 | 41 | </a> |
42 | 42 | <!-- expansion section --> |
43 | 43 | <div class="yikes-mc-settings-expansion-section"> |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | <!-- Single or Double Opt-in --> |
46 | 46 | <p class="type-container form-field-container"><!-- necessary to prevent skipping on slideToggle(); --> |
47 | 47 | <!-- store the label --> |
48 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][label]" value="<?php echo $form_data_array['field_name']; ?>" /> |
|
49 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][type]" value="<?php echo $form_data_array['field_type']; ?>" /> |
|
50 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][merge]" value="<?php echo $merge_field_data['tag']; ?>" /> |
|
51 | - <input type="hidden" class="field-<?php echo $merge_field_data['tag']; ?>-position position-input" name="field[<?php echo $merge_field_data['tag']; ?>][position]" value="" /> |
|
48 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][label]" value="<?php echo $form_data_array[ 'field_name' ]; ?>" /> |
|
49 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][type]" value="<?php echo $form_data_array[ 'field_type' ]; ?>" /> |
|
50 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][merge]" value="<?php echo $merge_field_data[ 'tag' ]; ?>" /> |
|
51 | + <input type="hidden" class="field-<?php echo $merge_field_data[ 'tag' ]; ?>-position position-input" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][position]" value="" /> |
|
52 | 52 | |
53 | - <?php if ( $form_data_array['field_type'] == 'radio' || $form_data_array['field_type'] == 'dropdown' ) { ?> |
|
54 | - <?php $choices = ( isset( $merge_field_data['choices'] ) ) ? esc_attr( json_encode( $merge_field_data['choices'] ) ) : ''; ?> |
|
55 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][choices]" value='<?php echo $choices; ?>' /> |
|
53 | + <?php if ( $form_data_array[ 'field_type' ] == 'radio' || $form_data_array[ 'field_type' ] == 'dropdown' ) { ?> |
|
54 | + <?php $choices = ( isset( $merge_field_data[ 'choices' ] ) ) ? esc_attr( json_encode( $merge_field_data[ 'choices' ] ) ) : ''; ?> |
|
55 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][choices]" value='<?php echo $choices; ?>' /> |
|
56 | 56 | <?php } ?> |
57 | 57 | |
58 | 58 | <table class="form-table form-field-container"> |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | <tr valign="top"> |
62 | 62 | <td scope="row"> |
63 | 63 | <label for="merge-tag"> |
64 | - <?php _e( 'Merge Tag' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
64 | + <?php _e( 'Merge Tag', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
65 | 65 | </label> |
66 | 66 | </td> |
67 | 67 | <td> |
68 | - <input class="widefat merge-tag-text" type="text" readonly value="<?php echo $merge_field_data['tag']; ?>"> |
|
68 | + <input class="widefat merge-tag-text" type="text" readonly value="<?php echo $merge_field_data[ 'tag' ]; ?>"> |
|
69 | 69 | </td> |
70 | 70 | </tr> |
71 | 71 | |
72 | - <?php switch( $form_data_array['field_type'] ) { |
|
72 | + <?php switch ( $form_data_array[ 'field_type' ] ) { |
|
73 | 73 | |
74 | 74 | default: |
75 | 75 | break; |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | <tr valign="top"> |
88 | 88 | <td scope="row"> |
89 | 89 | <label for="placeholder"> |
90 | - <?php _e( 'Placeholder' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
90 | + <?php _e( 'Placeholder', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
91 | 91 | </label> |
92 | 92 | </td> |
93 | 93 | <td> |
94 | - <input type="text" class="widefat" name="field[<?php echo $merge_field_data['tag']; ?>][placeholder]" value="<?php echo isset( $merge_field_data['placeholder'] ) ? stripslashes( wp_strip_all_tags( $merge_field_data['placeholder'] ) ): '' ; ?>" /> |
|
95 | - <p class="description"><small><?php _e( "Assign a placeholder value to this field.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
94 | + <input type="text" class="widefat" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][placeholder]" value="<?php echo isset( $merge_field_data[ 'placeholder' ] ) ? stripslashes( wp_strip_all_tags( $merge_field_data[ 'placeholder' ] ) ) : ''; ?>" /> |
|
95 | + <p class="description"><small><?php _e( "Assign a placeholder value to this field.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | |
@@ -101,27 +101,27 @@ discard block |
||
101 | 101 | * Loop over field types and store necessary formats |
102 | 102 | * ( date, birthday - dateformat ; phone - phoneformat ) |
103 | 103 | */ |
104 | - switch( $form_data_array['field_type'] ) { |
|
104 | + switch ( $form_data_array[ 'field_type' ] ) { |
|
105 | 105 | |
106 | 106 | /* Store the date format, for properly rendering dates on the front end */ |
107 | 107 | case 'date': |
108 | - $date_format = ( isset( $merge_field_data['dateformat'] ) ) ? $merge_field_data['dateformat'] : 'MM/DD/YYYY'; |
|
108 | + $date_format = ( isset( $merge_field_data[ 'dateformat' ] ) ) ? $merge_field_data[ 'dateformat' ] : 'MM/DD/YYYY'; |
|
109 | 109 | ?> |
110 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][date_format]" value="<?php echo strtolower( $merge_field_data['dateformat'] ); ?>" /> |
|
110 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][date_format]" value="<?php echo strtolower( $merge_field_data[ 'dateformat' ] ); ?>" /> |
|
111 | 111 | <?php |
112 | 112 | break; |
113 | 113 | |
114 | 114 | case 'birthday': |
115 | - $date_format = ( isset( $merge_field_data['dateformat'] ) ) ? $merge_field_data['dateformat'] : 'MM/DD'; |
|
115 | + $date_format = ( isset( $merge_field_data[ 'dateformat' ] ) ) ? $merge_field_data[ 'dateformat' ] : 'MM/DD'; |
|
116 | 116 | ?> |
117 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][date_format]" value="<?php echo strtolower( $date_format ); ?>" /> |
|
117 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][date_format]" value="<?php echo strtolower( $date_format ); ?>" /> |
|
118 | 118 | <?php |
119 | 119 | break; |
120 | 120 | |
121 | 121 | /* Store the phone format, for properly regex pattern */ |
122 | 122 | case 'phone': |
123 | 123 | ?> |
124 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][phone_format]" value="<?php echo $merge_field_data['phoneformat']; ?>" /> |
|
124 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][phone_format]" value="<?php echo $merge_field_data[ 'phoneformat' ]; ?>" /> |
|
125 | 125 | <?php |
126 | 126 | break; |
127 | 127 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ?> |
133 | 133 | |
134 | 134 | <!-- Default Value --> |
135 | - <?php switch( $form_data_array['field_type'] ) { |
|
135 | + <?php switch ( $form_data_array[ 'field_type' ] ) { |
|
136 | 136 | |
137 | 137 | default: |
138 | 138 | case 'text': |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | <tr valign="top"> |
141 | 141 | <td scope="row"> |
142 | 142 | <label for="placeholder"> |
143 | - <?php _e( 'Default Value' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
143 | + <?php _e( 'Default Value', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
144 | 144 | </label> |
145 | 145 | </td> |
146 | 146 | <td> |
147 | - <input type="text" class="widefat" name="field[<?php echo $merge_field_data['tag']; ?>][default]" <?php if( $form_data_array['field_type'] != 'url' ) { ?> value="<?php echo isset( $merge_field_data['default'] ) ? stripslashes( wp_strip_all_tags( $merge_field_data['default'] ) ) : ''; ?>" <?php } else { ?> value="<?php echo isset( $merge_field_data['default'] ) ? stripslashes( wp_strip_all_tags( esc_url_raw( $merge_field_data['default'] ) ) ) : ''; } ?>" /> |
|
148 | - <p class="description"><small><?php _e( "Assign a default value to populate this field with on initial page load.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
147 | + <input type="text" class="widefat" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][default]" <?php if ( $form_data_array[ 'field_type' ] != 'url' ) { ?> value="<?php echo isset( $merge_field_data[ 'default' ] ) ? stripslashes( wp_strip_all_tags( $merge_field_data[ 'default' ] ) ) : ''; ?>" <?php } else { ?> value="<?php echo isset( $merge_field_data[ 'default' ] ) ? stripslashes( wp_strip_all_tags( esc_url_raw( $merge_field_data[ 'default' ] ) ) ) : ''; } ?>" /> |
|
148 | + <p class="description"><small><?php _e( "Assign a default value to populate this field with on initial page load.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
149 | 149 | <?php |
150 | - switch( $form_data_array['field_type'] ) { |
|
150 | + switch ( $form_data_array[ 'field_type' ] ) { |
|
151 | 151 | case 'text': |
152 | 152 | ?> |
153 | - <p><small class="pre-defined-tag-link"><a href="#TB_inline?width=600&height=550&inlineId=pre-defined-tag-container" class="thickbox" onclick="storeGlobalClicked( jQuery( this ) );"><?php _e( 'View Pre-Defined Tags' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></small></p> |
|
153 | + <p><small class="pre-defined-tag-link"><a href="#TB_inline?width=600&height=550&inlineId=pre-defined-tag-container" class="thickbox" onclick="storeGlobalClicked( jQuery( this ) );"><?php _e( 'View Pre-Defined Tags', 'yikes-inc-easy-mailchimp-extender' ); ?></a></small></p> |
|
154 | 154 | <?php |
155 | 155 | break; |
156 | 156 | } ?> |
@@ -164,20 +164,20 @@ discard block |
||
164 | 164 | <tr valign="top"> |
165 | 165 | <td scope="row"> |
166 | 166 | <label for="placeholder"> |
167 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
167 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
168 | 168 | </label> |
169 | 169 | </td> |
170 | 170 | <td> |
171 | 171 | <?php |
172 | 172 | $x = 0; |
173 | - foreach( $merge_field_data['choices'] as $choice => $value ) { |
|
174 | - $pre_selected = !empty( $merge_field_data['default_choice'] ) ? $merge_field_data['default_choice'] : '0'; |
|
173 | + foreach ( $merge_field_data[ 'choices' ] as $choice => $value ) { |
|
174 | + $pre_selected = ! empty( $merge_field_data[ 'default_choice' ] ) ? $merge_field_data[ 'default_choice' ] : '0'; |
|
175 | 175 | ?> |
176 | 176 | <label> |
177 | - <input type="radio" name="field[<?php echo $merge_field_data['tag']; ?>][default_choice]" value="<?php echo $x; ?>" <?php checked( $pre_selected , $choice ); ?>><?php echo $value; ?> |
|
177 | + <input type="radio" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][default_choice]" value="<?php echo $x; ?>" <?php checked( $pre_selected, $choice ); ?>><?php echo $value; ?> |
|
178 | 178 | </label> |
179 | 179 | <?php $x++; } ?> |
180 | - <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
180 | + <p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
181 | 181 | </td> |
182 | 182 | </tr> |
183 | 183 | |
@@ -189,18 +189,18 @@ discard block |
||
189 | 189 | <tr valign="top"> |
190 | 190 | <td scope="row"> |
191 | 191 | <label for="placeholder"> |
192 | - <?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
192 | + <?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
193 | 193 | </label> |
194 | 194 | </td> |
195 | 195 | <td> |
196 | - <select type="default" name="field[<?php echo $merge_field_data['tag']; ?>][default_choice]"> |
|
197 | - <?php foreach( $merge_field_data['choices'] as $choice => $value ) { |
|
198 | - $pre_selected = ! empty( $merge_field_data['default_choice'] ) ? $merge_field_data['default_choice'] : '0'; |
|
196 | + <select type="default" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][default_choice]"> |
|
197 | + <?php foreach ( $merge_field_data[ 'choices' ] as $choice => $value ) { |
|
198 | + $pre_selected = ! empty( $merge_field_data[ 'default_choice' ] ) ? $merge_field_data[ 'default_choice' ] : '0'; |
|
199 | 199 | ?> |
200 | - <option value="<?php echo $choice; ?>" <?php selected( $pre_selected , $choice ); ?>><?php echo stripslashes( $value ); ?></option> |
|
200 | + <option value="<?php echo $choice; ?>" <?php selected( $pre_selected, $choice ); ?>><?php echo stripslashes( $value ); ?></option> |
|
201 | 201 | <?php } ?> |
202 | 202 | </select> |
203 | - <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
203 | + <p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
204 | 204 | </td> |
205 | 205 | </tr> |
206 | 206 | |
@@ -214,65 +214,65 @@ discard block |
||
214 | 214 | <tr valign="top"> |
215 | 215 | <td scope="row"> |
216 | 216 | <label for="placeholder"> |
217 | - <?php _e( 'Description' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
217 | + <?php _e( 'Description', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
218 | 218 | </label> |
219 | 219 | </td> |
220 | 220 | <td> |
221 | - <textarea class="widefat field-description-input" name="field[<?php echo $merge_field_data['tag']; ?>][description]"></textarea> |
|
222 | - <p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
221 | + <textarea class="widefat field-description-input" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][description]"></textarea> |
|
222 | + <p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
223 | 223 | </td> |
224 | 224 | </tr> |
225 | 225 | <!-- Additional Classes --> |
226 | 226 | <tr valign="top"> |
227 | 227 | <td scope="row"> |
228 | 228 | <label for="placeholder"> |
229 | - <?php _e( 'Additional Classes' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
229 | + <?php _e( 'Additional Classes', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
230 | 230 | </label> |
231 | 231 | </td> |
232 | 232 | <td> |
233 | - <input type="text" class="widefat" name="field[<?php echo $merge_field_data['tag']; ?>][additional-classes]" value="<?php echo isset( $form_data_array['classes'] ) ? stripslashes( wp_strip_all_tags( $form_data_array['classes'] ) ) : '' ; ?>" /> |
|
234 | - <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' );?></small></p> |
|
233 | + <input type="text" class="widefat" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][additional-classes]" value="<?php echo isset( $form_data_array[ 'classes' ] ) ? stripslashes( wp_strip_all_tags( $form_data_array[ 'classes' ] ) ) : ''; ?>" /> |
|
234 | + <p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); ?></small></p> |
|
235 | 235 | </td> |
236 | 236 | </tr> |
237 | 237 | <!-- Required Toggle --> |
238 | 238 | <tr valign="top"> |
239 | 239 | <td scope="row"> |
240 | 240 | <label for="field-required"> |
241 | - <?php _e( 'Field Required?' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
241 | + <?php _e( 'Field Required?', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
242 | 242 | </label> |
243 | 243 | </td> |
244 | 244 | <td> |
245 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data['tag']; ?>][require]" <?php checked( $merge_field_data['req'], 1 ); ?> <?php if( $merge_field_data['tag'] == 'EMAIL' ) { ?> disabled="disabled" checked="checked" title="<?php echo __( 'Email is a required field.' , 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
246 | - <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
245 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][require]" <?php checked( $merge_field_data[ 'req' ], 1 ); ?> <?php if ( $merge_field_data[ 'tag' ] == 'EMAIL' ) { ?> disabled="disabled" checked="checked" title="<?php echo __( 'Email is a required field.', 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
246 | + <p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
247 | 247 | </td> |
248 | 248 | </tr> |
249 | 249 | <!-- Visible Toggle --> |
250 | 250 | <tr valign="top"> |
251 | 251 | <td scope="row"> |
252 | 252 | <label for="hide-field"> |
253 | - <?php _e( 'Hide Field' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
253 | + <?php _e( 'Hide Field', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
254 | 254 | </label> |
255 | 255 | </td> |
256 | 256 | <td> |
257 | - <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data['tag']; ?>][hide]" <?php checked( $merge_field_data['public'], '' ); ?> <?php if( $merge_field_data['tag'] == 'EMAIL' ) { ?> disabled="disabled" title="<?php echo __( 'Cannot toggle email field visibility.' , 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
258 | - <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
257 | + <input type="checkbox" class="widefat" value="1" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][hide]" <?php checked( $merge_field_data[ 'public' ], '' ); ?> <?php if ( $merge_field_data[ 'tag' ] == 'EMAIL' ) { ?> disabled="disabled" title="<?php echo __( 'Cannot toggle email field visibility.', 'yikes-inc-easy-mailchimp-extender' ); } ?>"> |
|
258 | + <p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
259 | 259 | </td> |
260 | 260 | </tr> |
261 | 261 | <!-- Toggle Field Label Visibility --> |
262 | 262 | <tr valign="top"> |
263 | 263 | <td scope="row"> |
264 | 264 | <label for="placeholder"> |
265 | - <?php _e( 'Hide Label' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
265 | + <?php _e( 'Hide Label', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
266 | 266 | </label> |
267 | 267 | </td> |
268 | 268 | <td> |
269 | - <input type="checkbox" name="field[<?php echo $merge_field_data['tag']; ?>][hide-label]" value="1" /> |
|
270 | - <p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' );?></small></p> |
|
269 | + <input type="checkbox" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][hide-label]" value="1" /> |
|
270 | + <p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p> |
|
271 | 271 | </td> |
272 | 272 | </tr> |
273 | 273 | <!-- Display Phone/Date Formats back to the user --> |
274 | 274 | <?php |
275 | - switch( $form_data_array['field_type'] ) { |
|
275 | + switch ( $form_data_array[ 'field_type' ] ) { |
|
276 | 276 | |
277 | 277 | /* Store the phone format, for properly regex pattern */ |
278 | 278 | case 'phone': |
@@ -283,23 +283,23 @@ discard block |
||
283 | 283 | <td scope="row"> |
284 | 284 | <label for="placeholder"> |
285 | 285 | <?php |
286 | - switch( $form_data_array['field_type'] ) { |
|
286 | + switch ( $form_data_array[ 'field_type' ] ) { |
|
287 | 287 | default: |
288 | 288 | case 'birthday': |
289 | - $type = __( 'Date Format' , 'yikes-inc-easy-mailchimp-extender' ); |
|
290 | - $format = $merge_field_data['dateformat']; |
|
289 | + $type = __( 'Date Format', 'yikes-inc-easy-mailchimp-extender' ); |
|
290 | + $format = $merge_field_data[ 'dateformat' ]; |
|
291 | 291 | $format_name = 'date_format'; |
292 | 292 | break; |
293 | 293 | |
294 | 294 | case 'date': |
295 | - $type = __( 'Date Format' , 'yikes-inc-easy-mailchimp-extender' ); |
|
296 | - $format = $merge_field_data['dateformat']; |
|
295 | + $type = __( 'Date Format', 'yikes-inc-easy-mailchimp-extender' ); |
|
296 | + $format = $merge_field_data[ 'dateformat' ]; |
|
297 | 297 | $format_name = 'date_format'; |
298 | 298 | break; |
299 | 299 | |
300 | 300 | case 'phone': |
301 | - $type = __( 'Phone Format' , 'yikes-inc-easy-mailchimp-extender' ); |
|
302 | - $format = ( ( $merge_field_data['phoneformat'] == 'none' ) ? __( 'International', 'yikes-inc-easy-mailchimp-extender' ) : $merge_field_data['phoneformat'] ); |
|
301 | + $type = __( 'Phone Format', 'yikes-inc-easy-mailchimp-extender' ); |
|
302 | + $format = ( ( $merge_field_data[ 'phoneformat' ] == 'none' ) ? __( 'International', 'yikes-inc-easy-mailchimp-extender' ) : $merge_field_data[ 'phoneformat' ] ); |
|
303 | 303 | $format_name = 'phone_format'; |
304 | 304 | break; |
305 | 305 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | </td> |
310 | 310 | <td> |
311 | 311 | <strong><?php echo $format; ?></strong> |
312 | - <input type="hidden" name="field[<?php echo $merge_field_data['tag']; ?>][<?php echo $format_name; ?>]" value="<?php echo $format; ?>" /> |
|
312 | + <input type="hidden" name="field[<?php echo $merge_field_data[ 'tag' ]; ?>][<?php echo $format_name; ?>]" value="<?php echo $format; ?>" /> |
|
313 | 313 | <p class="description"><small> |
314 | 314 | <?php printf( __( 'To change the %s please head over to <a href="%s" title="MailChimp" target="_blank">MailChimp</a>. If you alter the format, you should re-import this field.', 'yikes-inc-easy-mailchimp-extender' ), strtolower( $type ), esc_url( 'http://www.mailchimp.com' ) ); ?> |
315 | 315 | </small></p> |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | </td> |
331 | 331 | <td> |
332 | 332 | <span class="toggle-container"> |
333 | - <a href="#" class="hide-field"><?php _e( "Close" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
334 | - <a href="#" class="remove-field" alt="<?php echo $merge_field_data['tag']; ?>"><?php _e( "Remove Field" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
333 | + <a href="#" class="hide-field"><?php _e( "Close", 'yikes-inc-easy-mailchimp-extender' ); ?></a> | |
|
334 | + <a href="#" class="remove-field" alt="<?php echo $merge_field_data[ 'tag' ]; ?>"><?php _e( "Remove Field", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
335 | 335 | </span> |
336 | 336 | </td> |
337 | 337 | </tr> |