@@ -17,7 +17,7 @@ |
||
| 17 | 17 | // required..* |
| 18 | 18 | include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 19 | 19 | /* Visual Composer */ |
| 20 | - if( is_plugin_active( 'js_composer/js_composer.php' ) ) { |
|
| 20 | + if ( is_plugin_active( 'js_composer/js_composer.php' ) ) { |
|
| 21 | 21 | new YIKES_MailChimp_Visual_Composer_Extension(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 9 | 9 | // users can only unisntall a plugin from the network dashboard page |
| 10 | 10 | // Get all blog ids |
| 11 | - $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
| 11 | + $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
| 12 | 12 | foreach ( $blogids as $blog_id ) { |
| 13 | 13 | switch_to_blog( $blog_id ); |
| 14 | 14 | self::_uninstall_yikes_easy_mailchimp( $wpdb ); |
@@ -28,15 +28,15 @@ discard block |
||
| 28 | 28 | * @since 6.0.0 |
| 29 | 29 | */ |
| 30 | 30 | static function _uninstall_yikes_easy_mailchimp( $wpdb ) { |
| 31 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 31 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 32 | 32 | |
| 33 | 33 | /* Clean up and delete our custom table from the databse */ |
| 34 | - $table = $wpdb->prefix."yikes_easy_mc_forms"; |
|
| 34 | + $table = $wpdb->prefix . "yikes_easy_mc_forms"; |
|
| 35 | 35 | $sql = 'DROP TABLE IF EXISTS ' . $table; |
| 36 | 36 | |
| 37 | 37 | //Delete any options thats stored also? |
| 38 | 38 | $wpdb->query( $sql ); |
| 39 | - dbDelta($sql); |
|
| 39 | + dbDelta( $sql ); |
|
| 40 | 40 | |
| 41 | 41 | /* Clear All Transient Data */ |
| 42 | 42 | delete_transient( 'yikes-easy-mailchimp-list-data' ); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | <div class="addon-footer-wrap give-clearfix"> |
| 34 | 34 | <a href="<?php echo esc_attr( $permalink ); ?>" title="<?php echo esc_attr( $add_on_title ); ?>" class="button-secondary" target="_blank"> |
| 35 | - <?php esc_attr_e( 'View Add-on' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 35 | + <?php esc_attr_e( 'View Add-on', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 36 | 36 | <span class="dashicons dashicons-external"></span></a> |
| 37 | 37 | </div> |
| 38 | 38 | |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | <div class="addon-footer-wrap give-clearfix"> |
| 34 | 34 | <a href="<?php echo esc_attr( $permalink ); ?>" title="<?php echo esc_attr( $add_on_title ); ?>" class="button-secondary" target="_blank"> |
| 35 | - <?php esc_attr_e( 'View Add-on' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 35 | + <?php esc_attr_e( 'View Add-on', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 36 | 36 | <span class="dashicons dashicons-external"></span></a> |
| 37 | 37 | </div> |
| 38 | 38 | |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | <div class="addon-footer-wrap give-clearfix"> |
| 34 | 34 | <a href="<?php echo esc_attr( $permalink ); ?>" title="<?php echo esc_attr( $add_on_title ); ?>" class="button-secondary" target="_blank"> |
| 35 | - <?php esc_attr_e( 'View Add-on' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 35 | + <?php esc_attr_e( 'View Add-on', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 36 | 36 | <span class="dashicons dashicons-external"></span></a> |
| 37 | 37 | </div> |
| 38 | 38 | |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | <div class="addon-footer-wrap give-clearfix"> |
| 34 | 34 | <a href="<?php echo esc_attr( $permalink ); ?>" title="<?php echo esc_attr( $add_on_title ); ?>" class="button-secondary" target="_blank"> |
| 35 | - <?php esc_attr_e( 'View Add-on' , 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 35 | + <?php esc_attr_e( 'View Add-on', 'yikes-inc-easy-mailchimp-extender' ); ?> |
|
| 36 | 36 | <span class="dashicons dashicons-external"></span></a> |
| 37 | 37 | </div> |
| 38 | 38 | |
@@ -3,18 +3,18 @@ |
||
| 3 | 3 | - Clear MailChimp transient data such as forms, form fields, list data, subscribers etc. |
| 4 | 4 | * transient cache is stored for 60 minutes. |
| 5 | 5 | --> |
| 6 | -<h3><span><?php _e( 'API Cache Settings' , 'yikes-inc-easy-mailchimp-extender' ); ?></span></h3> |
|
| 6 | +<h3><span><?php _e( 'API Cache Settings', 'yikes-inc-easy-mailchimp-extender' ); ?></span></h3> |
|
| 7 | 7 | <div class="inside"> |
| 8 | 8 | |
| 9 | 9 | <!-- Settings Form --> |
| 10 | - <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"> |
|
| 10 | + <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"> |
|
| 11 | 11 | |
| 12 | - <p><?php _e( "Delete all MailChimp data stored in your sites cache. Most data is stored in the cache for 1 hour." , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 12 | + <p><?php _e( "Delete all MailChimp data stored in your sites cache. Most data is stored in the cache for 1 hour.", 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 13 | 13 | <!-- check if any of our transients contain data --> |
| 14 | 14 | <?php if ( false === get_transient( 'yikes-easy-mailchimp-list-data' ) && false === get_transient( 'yikes-easy-mailchimp-profile-data' ) && false === get_transient( 'yikes-easy-mailchimp-account-data' ) && false === get_transient( 'yikesinc_eme_list_ids' ) && false === get_transient( 'yikes_eme_lists' ) ) { ?> |
| 15 | - <p><a href="#" class="button-secondary" disabled="disabled" title="<?php _e( 'No MailChimp data found in temporary cache storage.' , 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( 'Clear MailChimp API Cache' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></p> |
|
| 15 | + <p><a href="#" class="button-secondary" disabled="disabled" title="<?php _e( 'No MailChimp data found in temporary cache storage.', 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( 'Clear MailChimp API Cache', 'yikes-inc-easy-mailchimp-extender' ); ?></a></p> |
|
| 16 | 16 | <?php } else { ?> |
| 17 | - <p><input type="submit" class="button-primary" value="<?php _e( 'Clear MailChimp API Cache' , 'yikes-inc-easy-mailchimp-extender' ); ?>" /></p> |
|
| 17 | + <p><input type="submit" class="button-primary" value="<?php _e( 'Clear MailChimp API Cache', 'yikes-inc-easy-mailchimp-extender' ); ?>" /></p> |
|
| 18 | 18 | <?php } ?> |
| 19 | 19 | |
| 20 | 20 | </form> |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Allows us to apply_filters for the filters we're adding |
|
| 28 | - */ |
|
| 27 | + * Allows us to apply_filters for the filters we're adding |
|
| 28 | + */ |
|
| 29 | 29 | public function init_filters() { |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * yikes-mailchimp-wp-comment-integration-placement |
|
| 33 | - * |
|
| 34 | - * Decide the placement of the subscription checkbox. Default is after the "Comment" box. |
|
| 35 | - * |
|
| 36 | - * @return string | The name of a WP comment field's filter |
|
| 37 | - */ |
|
| 32 | + * yikes-mailchimp-wp-comment-integration-placement |
|
| 33 | + * |
|
| 34 | + * Decide the placement of the subscription checkbox. Default is after the "Comment" box. |
|
| 35 | + * |
|
| 36 | + * @return string | The name of a WP comment field's filter |
|
| 37 | + */ |
|
| 38 | 38 | $checkbox_placement = apply_filters( 'yikes-mailchimp-wp-comment-integration-placement', 'comment_form_field_comment' ); |
| 39 | 39 | |
| 40 | 40 | add_action( $checkbox_placement, array( $this, 'output_checkbox' ), 10 ); |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * Outputs a checkbox, if user is not already subscribed |
|
| 46 | - */ |
|
| 45 | + * Outputs a checkbox, if user is not already subscribed |
|
| 46 | + */ |
|
| 47 | 47 | public function output_checkbox( $comment_field ) { |
| 48 | 48 | if ( $this->is_user_already_subscribed( $this->type ) ) { |
| 49 | 49 | return $comment_field; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * a new comment is submitted |
| 60 | 60 | * |
| 61 | 61 | * @since 6.0.0 |
| 62 | - **/ |
|
| 62 | + **/ |
|
| 63 | 63 | public function subscribe_from_comment( $comment_id, $comment_approved ) { |
| 64 | 64 | |
| 65 | 65 | // was sign-up checkbox checked? |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | // Prevent direct access to the file |
| 9 | - defined('ABSPATH') or die( __( "Whoops, you shouldn't be accessing this file directly. Abort!" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
| 9 | + defined( 'ABSPATH' ) or die( __( "Whoops, you shouldn't be accessing this file directly. Abort!", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
| 10 | 10 | |
| 11 | 11 | class Yikes_Easy_MC_Comment_Checkbox_Class extends Yikes_Easy_MC_Checkbox_Integration_Class { |
| 12 | 12 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | // Subscribe the user |
| 85 | - $this->subscribe_user_integration( sanitize_email( $comment_data->comment_author_email ) , $this->type , $merge_vars ); |
|
| 85 | + $this->subscribe_user_integration( sanitize_email( $comment_data->comment_author_email ), $this->type, $merge_vars ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | // declare our integration type |
| 14 | 14 | protected $type = 'comment_form'; |
| 15 | 15 | |
| 16 | - public function __construct() { |
|
| 16 | + public function __construct() { |
|
| 17 | 17 | // hooks for outputting the checkbox |
| 18 | 18 | add_action( 'thesis_hook_after_comment_box', array( $this, 'output_checkbox' ), 10 ); |
| 19 | 19 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @since 6.0.0 |
| 62 | 62 | **/ |
| 63 | - public function subscribe_from_comment( $comment_id, $comment_approved ) { |
|
| 63 | + public function subscribe_from_comment( $comment_id, $comment_approved ) { |
|
| 64 | 64 | |
| 65 | 65 | // was sign-up checkbox checked? |
| 66 | 66 | if ( $this->was_checkbox_checked( $this->type ) === false ) { |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | - * If login is required, abort |
|
| 158 | - * @since 6.0.3.8 |
|
| 159 | - */ |
|
| 157 | + * If login is required, abort |
|
| 158 | + * @since 6.0.3.8 |
|
| 159 | + */ |
|
| 160 | 160 | if( $form_login_required ) { |
| 161 | 161 | if( apply_filters( 'yikes-mailchimp-required-login-requirement', ! is_user_logged_in() ) ) { |
| 162 | 162 | ob_start(); |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * Check if schedule is set for this form |
|
| 175 | - * @since 6.0.3.8 |
|
| 176 | - */ |
|
| 174 | + * Check if schedule is set for this form |
|
| 175 | + * @since 6.0.3.8 |
|
| 176 | + */ |
|
| 177 | 177 | if( $form_schedule_state ) { |
| 178 | 178 | // store current date |
| 179 | 179 | $current_date = strtotime( current_time( 'm/d/Y g:iA' ) ); |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | - * Check for form inline parameter |
|
| 230 | - */ |
|
| 229 | + * Check for form inline parameter |
|
| 230 | + */ |
|
| 231 | 231 | $form_inline = ( $atts['inline'] == 1 || $atts['inline'] == 'true' || get_theme_mod( 'form-inline-' . $form_id, '' ) === true ); // form-inline-{$form_id} comes from customizer extension |
| 232 | 232 | // recheck from our form options |
| 233 | 233 | if ( ! $form_inline ) { |
@@ -291,21 +291,21 @@ discard block |
||
| 291 | 291 | /**** Set up any filter'able content (that needs to be filtered before the rest of the logic kicks off) ****/ |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | - * yikes-mailchimp-countries-with-zip |
|
| 295 | - * |
|
| 296 | - * Filter which countries show the zip field |
|
| 297 | - * |
|
| 298 | - * @param array | An array of country codes that the zip field will appear for - default: US, GB, CA |
|
| 299 | - * Note: please return the array with the country code as the KEY! This allows for optimal searching. |
|
| 300 | - * @param int | $form_id |
|
| 301 | - */ |
|
| 294 | + * yikes-mailchimp-countries-with-zip |
|
| 295 | + * |
|
| 296 | + * Filter which countries show the zip field |
|
| 297 | + * |
|
| 298 | + * @param array | An array of country codes that the zip field will appear for - default: US, GB, CA |
|
| 299 | + * Note: please return the array with the country code as the KEY! This allows for optimal searching. |
|
| 300 | + * @param int | $form_id |
|
| 301 | + */ |
|
| 302 | 302 | $countries_with_zip_code_field = apply_filters( 'yikes-mailchimp-countries-with-zip', |
| 303 | 303 | array( 'US' => 'US', 'GB' => 'GB', 'CA' => 'CA', |
| 304 | - 'IE' => 'IE', 'CN' => 'CN', 'IN' => 'IN', |
|
| 305 | - 'AU' => 'AU', 'BR' => 'BR', 'MX' => 'MX', |
|
| 306 | - 'IT' => 'IT', 'NZ' => 'NZ', 'JP' => 'JP', |
|
| 307 | - 'FR' => 'FR', 'GR' => 'GR', 'DE' => 'DE', |
|
| 308 | - 'NL' => 'NL', 'PT' => 'PT', 'ES' => 'ES' |
|
| 304 | + 'IE' => 'IE', 'CN' => 'CN', 'IN' => 'IN', |
|
| 305 | + 'AU' => 'AU', 'BR' => 'BR', 'MX' => 'MX', |
|
| 306 | + 'IT' => 'IT', 'NZ' => 'NZ', 'JP' => 'JP', |
|
| 307 | + 'FR' => 'FR', 'GR' => 'GR', 'DE' => 'DE', |
|
| 308 | + 'NL' => 'NL', 'PT' => 'PT', 'ES' => 'ES' |
|
| 309 | 309 | ), $form_id |
| 310 | 310 | ); |
| 311 | 311 | |
@@ -532,14 +532,14 @@ discard block |
||
| 532 | 532 | $description .= '</p>'; |
| 533 | 533 | |
| 534 | 534 | /** |
| 535 | - * 'yikes-mailchimp-' . $field['merge'] . '-description-html' (e.g. yikes-mailchimp-FNAME-description-html) |
|
| 536 | - * |
|
| 537 | - * Filter the description HTML block |
|
| 538 | - * |
|
| 539 | - * @param string | $description | The full HTML description block |
|
| 540 | - * @param string | $field['description'] | The field's description text |
|
| 541 | - * @param int | $form_id |
|
| 542 | - */ |
|
| 535 | + * 'yikes-mailchimp-' . $field['merge'] . '-description-html' (e.g. yikes-mailchimp-FNAME-description-html) |
|
| 536 | + * |
|
| 537 | + * Filter the description HTML block |
|
| 538 | + * |
|
| 539 | + * @param string | $description | The full HTML description block |
|
| 540 | + * @param string | $field['description'] | The field's description text |
|
| 541 | + * @param int | $form_id |
|
| 542 | + */ |
|
| 543 | 543 | $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description-html', $description, esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
| 544 | 544 | } |
| 545 | 545 | |
@@ -684,13 +684,13 @@ discard block |
||
| 684 | 684 | $required_fields = array( 'addr1' => 'address' , 'addr2' => 'address 2', 'city' => 'city', 'state' =>'state', 'zip' =>'zip' , 'country' => 'country' ); |
| 685 | 685 | |
| 686 | 686 | /** |
| 687 | - * Filter to control the default country (the option pre-selected in the country dropdown). |
|
| 688 | - * |
|
| 689 | - * 'yikes-mailchimp-default-country-value' |
|
| 690 | - * |
|
| 691 | - * @param string | $country_slug | The slug of the desired default country. Default: 'US' |
|
| 692 | - * @param int | $form_id | ID of the form |
|
| 693 | - */ |
|
| 687 | + * Filter to control the default country (the option pre-selected in the country dropdown). |
|
| 688 | + * |
|
| 689 | + * 'yikes-mailchimp-default-country-value' |
|
| 690 | + * |
|
| 691 | + * @param string | $country_slug | The slug of the desired default country. Default: 'US' |
|
| 692 | + * @param int | $form_id | ID of the form |
|
| 693 | + */ |
|
| 694 | 694 | $default_country = apply_filters( 'yikes-mailchimp-default-country-value', 'US', $form_id ); |
| 695 | 695 | |
| 696 | 696 | // <!-- Description Above --> |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | <?php |
| 757 | 757 | $state_and_province_list = file_get_contents( YIKES_MC_PATH . 'public/partials/shortcodes/templates/state-and-province-dropdown.php' ); |
| 758 | 758 | /** |
| 759 | - * 'yikes-mailchimp-state-province-list' |
|
| 760 | - * |
|
| 761 | - * Filter the HTML options for the states dropdown |
|
| 762 | - * |
|
| 763 | - * @param string | $state_and_province_list | HTML string of state/province options |
|
| 764 | - * @param int | $form_id | The form ID |
|
| 765 | - * |
|
| 766 | - * @return string | $state_and_province_list | Filtered HTML string of state/province options |
|
| 767 | - */ |
|
| 759 | + * 'yikes-mailchimp-state-province-list' |
|
| 760 | + * |
|
| 761 | + * Filter the HTML options for the states dropdown |
|
| 762 | + * |
|
| 763 | + * @param string | $state_and_province_list | HTML string of state/province options |
|
| 764 | + * @param int | $form_id | The form ID |
|
| 765 | + * |
|
| 766 | + * @return string | $state_and_province_list | Filtered HTML string of state/province options |
|
| 767 | + */ |
|
| 768 | 768 | echo apply_filters( 'yikes-mailchimp-state-province-list', $state_and_province_list, $form_id ); |
| 769 | 769 | |
| 770 | 770 | ?> |
@@ -797,17 +797,17 @@ discard block |
||
| 797 | 797 | } else { |
| 798 | 798 | |
| 799 | 799 | /** |
| 800 | - * A filter to set the default zip code value. |
|
| 801 | - * |
|
| 802 | - * U.S. users may want to default their subscribers. |
|
| 803 | - * However, this filter is more for non-U.S. users, where the zip field is hidden. |
|
| 804 | - * MailChimp requires a zip code (for all submissions/countries), so this filter allows users users to set a default value. |
|
| 805 | - * |
|
| 806 | - * 'yikes-mailchimp-default-zip-code' |
|
| 807 | - * |
|
| 808 | - * @param string | $zip | A value to pre-populate the zip code with. |
|
| 809 | - * @param int | $form_id | ID of the form |
|
| 810 | - */ |
|
| 800 | + * A filter to set the default zip code value. |
|
| 801 | + * |
|
| 802 | + * U.S. users may want to default their subscribers. |
|
| 803 | + * However, this filter is more for non-U.S. users, where the zip field is hidden. |
|
| 804 | + * MailChimp requires a zip code (for all submissions/countries), so this filter allows users users to set a default value. |
|
| 805 | + * |
|
| 806 | + * 'yikes-mailchimp-default-zip-code' |
|
| 807 | + * |
|
| 808 | + * @param string | $zip | A value to pre-populate the zip code with. |
|
| 809 | + * @param int | $form_id | ID of the form |
|
| 810 | + */ |
|
| 811 | 811 | $zip_value = apply_filters( 'yikes-mailchimp-default-zip-code', '', $form_id ); |
| 812 | 812 | } |
| 813 | 813 | ?> |
@@ -1038,14 +1038,14 @@ discard block |
||
| 1038 | 1038 | $description .= '</p>'; |
| 1039 | 1039 | |
| 1040 | 1040 | /** |
| 1041 | - * 'yikes-mailchimp-' . $field['group_id'] . '-description-html' (e.g. yikes-mailchimp-0ab8f8c84b-description-html) |
|
| 1042 | - * |
|
| 1043 | - * Filter the description HTML block |
|
| 1044 | - * |
|
| 1045 | - * @param string | $description | The full HTML description block |
|
| 1046 | - * @param string | $field['description'] | The field's description text |
|
| 1047 | - * @param int | $form_id |
|
| 1048 | - */ |
|
| 1041 | + * 'yikes-mailchimp-' . $field['group_id'] . '-description-html' (e.g. yikes-mailchimp-0ab8f8c84b-description-html) |
|
| 1042 | + * |
|
| 1043 | + * Filter the description HTML block |
|
| 1044 | + * |
|
| 1045 | + * @param string | $description | The full HTML description block |
|
| 1046 | + * @param string | $field['description'] | The field's description text |
|
| 1047 | + * @param int | $form_id |
|
| 1048 | + */ |
|
| 1049 | 1049 | $description = apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description-html', $description, esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
| 1050 | 1050 | } |
| 1051 | 1051 | |
@@ -474,7 +474,9 @@ discard block |
||
| 474 | 474 | $field_array['required'] = isset( $field['require'] ) ? 'required="required"' : ''; |
| 475 | 475 | $label_array['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
| 476 | 476 | $label_class_array[] = ( $tag === 'merge' ) ? $field['merge'] . '-label' : $field['group_id'] . '-label'; |
| 477 | - if ( isset( $field['require'] ) ) $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 477 | + if ( isset( $field['require'] ) ) { |
|
| 478 | + $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 479 | + } |
|
| 478 | 480 | } |
| 479 | 481 | |
| 480 | 482 | // if both hide label and hide field are checked, we gotta hide the field! |
@@ -761,7 +763,7 @@ discard block |
||
| 761 | 763 | } else { |
| 762 | 764 | $zip_value = $_POST[$field['merge']]; |
| 763 | 765 | } |
| 764 | - } else { |
|
| 766 | + } else { |
|
| 765 | 767 | |
| 766 | 768 | /** |
| 767 | 769 | * A filter to set the default zip code value. |
@@ -1125,7 +1127,7 @@ discard block |
||
| 1125 | 1127 | echo $no_default === true ? '<option value="">' . $no_default_name . '</option>' : ''; |
| 1126 | 1128 | |
| 1127 | 1129 | $i = 0; |
| 1128 | - foreach( $groups as $group_id => $name ) { |
|
| 1130 | + foreach( $groups as $group_id => $name ) { |
|
| 1129 | 1131 | |
| 1130 | 1132 | // If the form was submitted and failed, set the submitted/chosen values as the default |
| 1131 | 1133 | if( isset( $_POST[ 'group-' . $field['group_id'] ] ) && $form_submitted === 0 ) { |
@@ -1174,7 +1176,7 @@ discard block |
||
| 1174 | 1176 | // Turn $default_choice into an array if it isn't already |
| 1175 | 1177 | $default_choice = ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice : array( $default_choice ); |
| 1176 | 1178 | |
| 1177 | - foreach( $groups as $group_id => $name ) { |
|
| 1179 | + foreach( $groups as $group_id => $name ) { |
|
| 1178 | 1180 | ?> |
| 1179 | 1181 | <label for="<?php echo esc_attr( $field['group_id'] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ' , $custom_classes ); if ( $x === $count ) { echo ' last-selection'; } ?>" style="display:none;"> |
| 1180 | 1182 | <input |
@@ -30,39 +30,39 @@ discard block |
||
| 30 | 30 | $form_submitted = isset( $form_submitted ) ? $form_submitted : 0; |
| 31 | 31 | |
| 32 | 32 | /* If the user hasn't authenticated yet, lets kill off */ |
| 33 | - if ( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) != 'valid_api_key' ) { |
|
| 34 | - 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>'; |
|
| 33 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) != 'valid_api_key' ) { |
|
| 34 | + 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>'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // if the user forgot to specify a form ID, lets kill of and warn them. |
| 38 | - if( ! $atts['form'] ) { |
|
| 38 | + if ( ! $atts[ 'form' ] ) { |
|
| 39 | 39 | return __( 'Whoops, it looks like you forgot to specify a form to display.', 'yikes-inc-easy-mailchimp-extender' ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // store our variables |
| 43 | - $form_id = (int) $atts['form']; // form id (the id of the form in the database) |
|
| 43 | + $form_id = (int) $atts[ 'form' ]; // form id (the id of the form in the database) |
|
| 44 | 44 | $interface = yikes_easy_mailchimp_extender_get_form_interface(); |
| 45 | 45 | $form_data = $interface->get_form( $form_id ); |
| 46 | 46 | |
| 47 | 47 | // confirm we have some results, or return an error |
| 48 | 48 | if ( empty( $form_data ) ) { |
| 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' ); |
|
| 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 | |
| 57 | 57 | // Allow users to manually set recaptcha (instead of globally - recaptcha="1"/recaptcha="0" - but still needs to be globally enabled on the settings page). |
| 58 | - if ( $atts['recaptcha'] != '0' ) { |
|
| 58 | + if ( $atts[ 'recaptcha' ] != '0' ) { |
|
| 59 | 59 | |
| 60 | 60 | // If either of the Private the Secret key is left blank, we should display an error back to the user. |
| 61 | - if ( get_option( 'yikes-mc-recaptcha-site-key' , '' ) == '' ) { |
|
| 62 | - 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 | + if ( get_option( 'yikes-mc-recaptcha-site-key', '' ) == '' ) { |
|
| 62 | + 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>'; |
|
| 63 | 63 | } |
| 64 | - if ( get_option( 'yikes-mc-recaptcha-secret-key' , '' ) == '' ) { |
|
| 65 | - 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 | + if ( get_option( 'yikes-mc-recaptcha-secret-key', '' ) == '' ) { |
|
| 65 | + 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>'; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $has_recaptcha = true; |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | $locale_split = explode( '_', $locale ); |
| 73 | 73 | |
| 74 | 74 | // Setup reCAPTCHA parameters. |
| 75 | - $lang = ! empty( $locale_split ) ? $locale_split[0] : $locale; |
|
| 76 | - $lang = ! empty( $atts['recaptcha_lang'] ) ? $atts['recaptcha_lang'] : $lang; |
|
| 77 | - $type = ! empty( $atts['recaptcha_type'] ) ? strtolower( $atts['recaptcha_type'] ) : 'image'; // setup recaptcha type |
|
| 78 | - $theme = ! empty( $atts['recaptcha_theme'] ) ? strtolower( $atts['recaptcha_theme'] ) : 'light'; // setup recaptcha theme |
|
| 79 | - $size = ! empty( $atts['recaptcha_size'] ) ? strtolower( $atts['recaptcha_size'] ) : 'normal'; // setup recaptcha size |
|
| 80 | - $data_cb = ! empty( $atts['recaptcha_data_callback'] ) ? $atts['recaptcha_data_callback'] : false; // setup recaptcha size |
|
| 81 | - $expired_cb = ! empty( $atts['recaptcha_expired_callback'] ) ? $atts['recaptcha_expired_callback'] : false; // setup recaptcha size |
|
| 75 | + $lang = ! empty( $locale_split ) ? $locale_split[ 0 ] : $locale; |
|
| 76 | + $lang = ! empty( $atts[ 'recaptcha_lang' ] ) ? $atts[ 'recaptcha_lang' ] : $lang; |
|
| 77 | + $type = ! empty( $atts[ 'recaptcha_type' ] ) ? strtolower( $atts[ 'recaptcha_type' ] ) : 'image'; // setup recaptcha type |
|
| 78 | + $theme = ! empty( $atts[ 'recaptcha_theme' ] ) ? strtolower( $atts[ 'recaptcha_theme' ] ) : 'light'; // setup recaptcha theme |
|
| 79 | + $size = ! empty( $atts[ 'recaptcha_size' ] ) ? strtolower( $atts[ 'recaptcha_size' ] ) : 'normal'; // setup recaptcha size |
|
| 80 | + $data_cb = ! empty( $atts[ 'recaptcha_data_callback' ] ) ? $atts[ 'recaptcha_data_callback' ] : false; // setup recaptcha size |
|
| 81 | + $expired_cb = ! empty( $atts[ 'recaptcha_expired_callback' ] ) ? $atts[ 'recaptcha_expired_callback' ] : false; // setup recaptcha size |
|
| 82 | 82 | |
| 83 | 83 | // Pass the shortcode parameters through a filter. |
| 84 | 84 | $recaptcha_shortcode_params = apply_filters( 'yikes-mailchimp-recaptcha-parameters', array( |
@@ -88,49 +88,49 @@ discard block |
||
| 88 | 88 | 'size' => $size, |
| 89 | 89 | 'success_callback' => $data_cb, |
| 90 | 90 | 'expired_callback' => $expired_cb, |
| 91 | - ), $atts['form'] ); |
|
| 91 | + ), $atts[ 'form' ] ); |
|
| 92 | 92 | |
| 93 | 93 | // Enqueue Google recaptcha JS. |
| 94 | - wp_register_script( 'google-recaptcha-js' , 'https://www.google.com/recaptcha/api.js?hl=' . $recaptcha_shortcode_params['language'] . '&onload=renderReCaptchaCallback&render=explicit', array( 'jquery', 'form-submission-helpers' ) , 'all' ); |
|
| 94 | + wp_register_script( 'google-recaptcha-js', 'https://www.google.com/recaptcha/api.js?hl=' . $recaptcha_shortcode_params[ 'language' ] . '&onload=renderReCaptchaCallback&render=explicit', array( 'jquery', 'form-submission-helpers' ), 'all' ); |
|
| 95 | 95 | wp_enqueue_script( 'google-recaptcha-js' ); |
| 96 | 96 | |
| 97 | - $recaptcha_site_key = get_option( 'yikes-mc-recaptcha-site-key' , '' ); |
|
| 98 | - $recaptcha_box = '<div class="g-recaptcha" data-sitekey="' . esc_attr( $recaptcha_site_key ) . '" data-theme="' . esc_attr( $recaptcha_shortcode_params['theme'] ) . '" data-type="' . esc_attr( $recaptcha_shortcode_params['type'] ) . '" data-size="' . esc_attr( $recaptcha_shortcode_params['size'] ) . '" data-callback="' . esc_attr( $recaptcha_shortcode_params['success_callback'] ) . '" data-expired-callback="' . esc_attr( $recaptcha_shortcode_params['expired_callback'] ) . '"></div>'; |
|
| 97 | + $recaptcha_site_key = get_option( 'yikes-mc-recaptcha-site-key', '' ); |
|
| 98 | + $recaptcha_box = '<div class="g-recaptcha" data-sitekey="' . esc_attr( $recaptcha_site_key ) . '" data-theme="' . esc_attr( $recaptcha_shortcode_params[ 'theme' ] ) . '" data-type="' . esc_attr( $recaptcha_shortcode_params[ 'type' ] ) . '" data-size="' . esc_attr( $recaptcha_shortcode_params[ 'size' ] ) . '" data-callback="' . esc_attr( $recaptcha_shortcode_params[ 'success_callback' ] ) . '" data-expired-callback="' . esc_attr( $recaptcha_shortcode_params[ 'expired_callback' ] ) . '"></div>'; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // place our results into a separate variable for easy looping |
| 103 | - $additional_form_settings = ( isset( $form_data['form_settings'] ) ) ? $form_data['form_settings'] : false; |
|
| 103 | + $additional_form_settings = ( isset( $form_data[ 'form_settings' ] ) ) ? $form_data[ 'form_settings' ] : false; |
|
| 104 | 104 | |
| 105 | 105 | // store our options from the additional form settings array |
| 106 | - $form_classes = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-class-names'] : ''; |
|
| 107 | - $inline_form = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-inline-form'] : ''; |
|
| 108 | - $submit_button_type = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-submit-button-type'] : 'text'; |
|
| 109 | - $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' ); |
|
| 110 | - $submit_button_image = ( $additional_form_settings ) ? esc_url( $additional_form_settings['yikes-easy-mc-submit-button-image'] ) : ''; |
|
| 111 | - $submit_button_classes = ( $additional_form_settings ) ? ' ' . esc_attr( $additional_form_settings['yikes-easy-mc-submit-button-classes'] ) : ''; |
|
| 106 | + $form_classes = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-class-names' ] : ''; |
|
| 107 | + $inline_form = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-inline-form' ] : ''; |
|
| 108 | + $submit_button_type = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-submit-button-type' ] : 'text'; |
|
| 109 | + $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' ); |
|
| 110 | + $submit_button_image = ( $additional_form_settings ) ? esc_url( $additional_form_settings[ 'yikes-easy-mc-submit-button-image' ] ) : ''; |
|
| 111 | + $submit_button_classes = ( $additional_form_settings ) ? ' ' . esc_attr( $additional_form_settings[ 'yikes-easy-mc-submit-button-classes' ] ) : ''; |
|
| 112 | 112 | |
| 113 | 113 | // scheuldes |
| 114 | - $form_schedule_state = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-schedule'] : false; |
|
| 115 | - $form_schedule_start = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-start'] : '';; |
|
| 116 | - $form_schedule_end = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-end'] : ''; |
|
| 117 | - $form_pending_message = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-pending-message'] : ''; |
|
| 118 | - $form_expired_message = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-expired-message'] : ''; |
|
| 114 | + $form_schedule_state = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-schedule' ] : false; |
|
| 115 | + $form_schedule_start = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-start' ] : ''; ; |
|
| 116 | + $form_schedule_end = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-end' ] : ''; |
|
| 117 | + $form_pending_message = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-pending-message' ] : ''; |
|
| 118 | + $form_expired_message = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-expired-message' ] : ''; |
|
| 119 | 119 | |
| 120 | 120 | // register required |
| 121 | - $form_login_required = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-login-required'] : false; |
|
| 122 | - $form_login_message = ( $additional_form_settings ) ? $additional_form_settings['yikes-easy-mc-form-restriction-login-message'] : ''; |
|
| 121 | + $form_login_required = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-login-required' ] : false; |
|
| 122 | + $form_login_message = ( $additional_form_settings ) ? $additional_form_settings[ 'yikes-easy-mc-form-restriction-login-message' ] : ''; |
|
| 123 | 123 | |
| 124 | 124 | // store number of fields |
| 125 | - $field_count = (int) count( $form_data['fields'] ); |
|
| 125 | + $field_count = (int) count( $form_data[ 'fields' ] ); |
|
| 126 | 126 | |
| 127 | 127 | // confirm we actually have fields, before looping |
| 128 | - if ( isset( $form_data['fields'] ) && ! empty( $form_data['fields'] ) ) { |
|
| 128 | + if ( isset( $form_data[ 'fields' ] ) && ! empty( $form_data[ 'fields' ] ) ) { |
|
| 129 | 129 | // loop over each field, if it's set to hidden -- subtract it from the field count |
| 130 | 130 | // this throws off the layout for inline forms setup below |
| 131 | - foreach ( $form_data['fields'] as $form_field ) { |
|
| 132 | - if ( isset( $form_field['hide'] ) && (string) $form_field['hide'] === '1' ) { |
|
| 133 | - $field_count --; |
|
| 131 | + foreach ( $form_data[ 'fields' ] as $form_field ) { |
|
| 132 | + if ( isset( $form_field[ 'hide' ] ) && (string) $form_field[ 'hide' ] === '1' ) { |
|
| 133 | + $field_count--; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * If login is required, abort |
| 140 | 140 | * @since 6.0.3.8 |
| 141 | 141 | */ |
| 142 | - if( $form_login_required ) { |
|
| 143 | - if( apply_filters( 'yikes-mailchimp-required-login-requirement', ! is_user_logged_in() ) ) { |
|
| 142 | + if ( $form_login_required ) { |
|
| 143 | + if ( apply_filters( 'yikes-mailchimp-required-login-requirement', ! is_user_logged_in() ) ) { |
|
| 144 | 144 | ob_start(); |
| 145 | 145 | ?> |
| 146 | 146 | <div class="yikes-mailchimp-login-required yikes-mailchimp-form-<?php echo $form_id; ?>-login-required"> |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | * Check if schedule is set for this form |
| 157 | 157 | * @since 6.0.3.8 |
| 158 | 158 | */ |
| 159 | - if( $form_schedule_state ) { |
|
| 159 | + if ( $form_schedule_state ) { |
|
| 160 | 160 | // store current date |
| 161 | 161 | $current_date = strtotime( current_time( 'm/d/Y g:iA' ) ); |
| 162 | 162 | |
| 163 | 163 | // the the current date is less than the form scheduled start date |
| 164 | - if( $current_date < $form_schedule_start ) { |
|
| 164 | + if ( $current_date < $form_schedule_start ) { |
|
| 165 | 165 | echo apply_filters( 'yikes-mailchimp-frontend-content', $form_pending_message, $form_id, $form_schedule_start ); |
| 166 | 166 | return; |
| 167 | 167 | // abort |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // The current date is past or equal to the end date, aka form has now expired |
| 171 | - if( $current_date >= $form_schedule_end ) { |
|
| 171 | + if ( $current_date >= $form_schedule_end ) { |
|
| 172 | 172 | echo apply_filters( 'yikes-mailchimp-frontend-content', $form_expired_message, $form_id, $form_schedule_end ); |
| 173 | 173 | return; |
| 174 | 174 | // abort |
@@ -177,14 +177,14 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | // setup the submit button text |
| 179 | 179 | // shortcode parameter takes precedence over option |
| 180 | - $submit = ( ! empty( $atts['submit'] ) ) ? $atts['submit'] : $submit_button_text; |
|
| 180 | + $submit = ( ! empty( $atts[ 'submit' ] ) ) ? $atts[ 'submit' ] : $submit_button_text; |
|
| 181 | 181 | |
| 182 | 182 | /* |
| 183 | 183 | * Check for the constant to prevent styles from loading |
| 184 | 184 | * to exclude styles from loading, add `define( 'YIKES_MAILCHIMP_EXCLUDE_STYLES', true );` to functions.php |
| 185 | 185 | * @since 6.0.3.8 |
| 186 | 186 | */ |
| 187 | - if( ! defined( 'YIKES_MAILCHIMP_EXCLUDE_STYLES' ) ) { |
|
| 187 | + if ( ! defined( 'YIKES_MAILCHIMP_EXCLUDE_STYLES' ) ) { |
|
| 188 | 188 | // enqueue the form styles |
| 189 | 189 | wp_enqueue_style( 'yikes-inc-easy-mailchimp-public-styles', YIKES_MC_URL . 'public/css/yikes-inc-easy-mailchimp-extender-public.min.css' ); |
| 190 | 190 | } |
@@ -192,19 +192,19 @@ discard block |
||
| 192 | 192 | /** |
| 193 | 193 | * Check for form inline parameter |
| 194 | 194 | */ |
| 195 | - $form_inline = ( $atts['inline'] == 1 || $atts['inline'] == 'true' || get_theme_mod( 'form-inline-' . $form_id, '' ) === true ); // form-inline-{$form_id} comes from customizer extension |
|
| 195 | + $form_inline = ( $atts[ 'inline' ] == 1 || $atts[ 'inline' ] == 'true' || get_theme_mod( 'form-inline-' . $form_id, '' ) === true ); // form-inline-{$form_id} comes from customizer extension |
|
| 196 | 196 | // recheck from our form options |
| 197 | 197 | if ( ! $form_inline ) { |
| 198 | - $form_inline = (bool) $additional_form_settings['yikes-easy-mc-inline-form']; |
|
| 198 | + $form_inline = (bool) $additional_form_settings[ 'yikes-easy-mc-inline-form' ]; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /* If the current user is logged in, and an admin...lets display our 'Edit Form' link */ |
| 202 | - if( is_user_logged_in() ) { |
|
| 203 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
| 202 | + if ( is_user_logged_in() ) { |
|
| 203 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
| 204 | 204 | $edit_form_link = '<span class="edit-link">'; |
| 205 | - $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $atts['form'] ) ) . '" title="' . __( 'Edit' , 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $form_data['form_name'] ) . '">' . __( 'Edit Form' , 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
| 205 | + $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $atts[ 'form' ] ) ) . '" title="' . __( 'Edit', 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $form_data[ 'form_name' ] ) . '">' . __( 'Edit Form', 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
| 206 | 206 | $edit_form_link .= '</span>'; |
| 207 | - $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $atts['form'], ucwords( $form_data['form_name'] ) ); |
|
| 207 | + $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $atts[ 'form' ], ucwords( $form_data[ 'form_name' ] ) ); |
|
| 208 | 208 | } else { |
| 209 | 209 | $edit_form_link = ''; |
| 210 | 210 | } |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | // or else MailChimp throws errors at you |
| 215 | 215 | // extract our array keys |
| 216 | 216 | // @todo Remove array_keys() and in_array() usage here. |
| 217 | - if( isset( $form_data['fields'] ) && ! empty( $form_data['fields'] ) ) { |
|
| 218 | - $array_keys = array_keys( $form_data['fields'] ); |
|
| 217 | + if ( isset( $form_data[ 'fields' ] ) && ! empty( $form_data[ 'fields' ] ) ) { |
|
| 218 | + $array_keys = array_keys( $form_data[ 'fields' ] ); |
|
| 219 | 219 | // check for EMAIL in that array |
| 220 | - if( !in_array( 'EMAIL', $array_keys ) && !in_array( 'email', $array_keys ) ) { |
|
| 221 | - 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>'; |
|
| 220 | + if ( ! in_array( 'EMAIL', $array_keys ) && ! in_array( 'email', $array_keys ) ) { |
|
| 221 | + 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>'; |
|
| 222 | 222 | } |
| 223 | 223 | } else { |
| 224 | - $error = '<p>' . __( "Whoops, it looks like you forgot to assign fields to this form." , 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
| 225 | - if( is_user_logged_in() ) { |
|
| 226 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
| 224 | + $error = '<p>' . __( "Whoops, it looks like you forgot to assign fields to this form.", 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
| 225 | + if ( is_user_logged_in() ) { |
|
| 226 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
| 227 | 227 | return $error . $edit_form_link; |
| 228 | 228 | } |
| 229 | 229 | } else { |
@@ -316,17 +316,17 @@ discard block |
||
| 316 | 316 | * Set a custom title using custom_title="lorem ipsum" parameter in the shortcode |
| 317 | 317 | * - This takes precedence over the title set |
| 318 | 318 | */ |
| 319 | - if ( $atts['title'] ) { |
|
| 320 | - if ( ! empty( $atts['custom_title'] ) ) { |
|
| 319 | + if ( $atts[ 'title' ] ) { |
|
| 320 | + if ( ! empty( $atts[ 'custom_title' ] ) ) { |
|
| 321 | 321 | /** |
| 322 | 322 | * Filter the title that is displayed through the shortcode. |
| 323 | 323 | * |
| 324 | 324 | * @param string $title The title to display. |
| 325 | 325 | * @param int $form_id The form ID. |
| 326 | 326 | */ |
| 327 | - $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $atts['custom_title'] ), $form_id ); |
|
| 327 | + $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $atts[ 'custom_title' ] ), $form_id ); |
|
| 328 | 328 | } else { |
| 329 | - $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_data['form_name'] ), $form_id ); |
|
| 329 | + $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_data[ 'form_name' ] ), $form_id ); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | echo sprintf( '<h3 class="yikes-mailchimp-form-title yikes-mailchimp-form-title-%1$s">%2$s</h3>', $form_id, $title ); |
@@ -336,17 +336,17 @@ discard block |
||
| 336 | 336 | * Allow users to specify a custom description for this form, no html support |
| 337 | 337 | * @since 6.0.3.8 |
| 338 | 338 | */ |
| 339 | - if ( $atts['description'] ) { |
|
| 340 | - if ( ! empty( $atts['custom_description'] ) ) { |
|
| 339 | + if ( $atts[ 'description' ] ) { |
|
| 340 | + if ( ! empty( $atts[ 'custom_description' ] ) ) { |
|
| 341 | 341 | /** |
| 342 | 342 | * Filter the description that is displayed through the shortcode. |
| 343 | 343 | * |
| 344 | 344 | * @param string $title The title to display. |
| 345 | 345 | * @param int $form_id The form ID. |
| 346 | 346 | */ |
| 347 | - $description = apply_filters( 'yikes-mailchimp-form-description', $atts['custom_description'], $form_id ); |
|
| 347 | + $description = apply_filters( 'yikes-mailchimp-form-description', $atts[ 'custom_description' ], $form_id ); |
|
| 348 | 348 | } else { |
| 349 | - $description = apply_filters( 'yikes-mailchimp-form-description', $form_data['form_description'], $form_id ); |
|
| 349 | + $description = apply_filters( 'yikes-mailchimp-form-description', $form_data[ 'form_description' ], $form_id ); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | echo sprintf( '<section class="yikes-mailchimp-form-description yikes-mailchimp-form-description-%1$s">%2$s</section>', $form_id, $description ); |
@@ -361,10 +361,10 @@ discard block |
||
| 361 | 361 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 362 | 362 | |
| 363 | 363 | // Check for AJAX |
| 364 | - if( ( ! empty( $atts['ajax'] ) && $atts['ajax'] == 1 ) || $form_data['submission_settings']['ajax'] == 1 ) { |
|
| 364 | + if ( ( ! empty( $atts[ 'ajax' ] ) && $atts[ 'ajax' ] == 1 ) || $form_data[ 'submission_settings' ][ 'ajax' ] == 1 ) { |
|
| 365 | 365 | |
| 366 | 366 | // Enqueue our ajax script |
| 367 | - wp_enqueue_script( 'yikes-easy-mc-ajax' , YIKES_MC_URL . "public/js/yikes-mc-ajax-forms{$min}.js" , array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 367 | + wp_enqueue_script( 'yikes-easy-mc-ajax', YIKES_MC_URL . "public/js/yikes-mc-ajax-forms{$min}.js", array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 368 | 368 | wp_localize_script( 'yikes-easy-mc-ajax', 'yikes_mailchimp_ajax', array( |
| 369 | 369 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 370 | 370 | 'page_data' => $page_data, |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // Generic JavaScript functions for interacting with the form |
| 379 | - wp_enqueue_script( 'form-submission-helpers', YIKES_MC_URL . "public/js/form-submission-helpers{$min}.js" , array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 379 | + wp_enqueue_script( 'form-submission-helpers', YIKES_MC_URL . "public/js/form-submission-helpers{$min}.js", array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 380 | 380 | wp_localize_script( 'form-submission-helpers', 'form_submission_helpers', array( |
| 381 | 381 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 382 | 382 | 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) ), |
@@ -395,67 +395,67 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | // render the form! |
| 397 | 397 | ?> |
| 398 | - <form id="<?php echo sanitize_title( $form_data['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_data['submission_settings']['hide_form_post_signup'] == 1 ) { echo ' yikes-easy-mc-display-none'; } ?>" method="POST" data-attr-form-id="<?php echo esc_attr( $form_id ); ?>"> |
|
| 398 | + <form id="<?php echo sanitize_title( $form_data[ '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_data[ 'submission_settings' ][ 'hide_form_post_signup' ] == 1 ) { echo ' yikes-easy-mc-display-none'; } ?>" method="POST" data-attr-form-id="<?php echo esc_attr( $form_id ); ?>"> |
|
| 399 | 399 | |
| 400 | 400 | <?php |
| 401 | 401 | // Set a default constant for hidden fields |
| 402 | 402 | $hidden_label_count = 0; |
| 403 | 403 | |
| 404 | 404 | // Loop over our form fields |
| 405 | - foreach( $form_data['fields'] as $field ) { |
|
| 405 | + foreach ( $form_data[ 'fields' ] as $field ) { |
|
| 406 | 406 | // input array |
| 407 | 407 | $field_array = array(); |
| 408 | 408 | // label array |
| 409 | 409 | $label_array = array(); |
| 410 | 410 | // label classes array |
| 411 | 411 | $label_class_array = array(); |
| 412 | - if( $field['additional-classes'] != '' ) { |
|
| 412 | + if ( $field[ 'additional-classes' ] != '' ) { |
|
| 413 | 413 | // split custom classes at spaces |
| 414 | - $custom_classes = explode( ' ' , $field['additional-classes'] ); |
|
| 414 | + $custom_classes = explode( ' ', $field[ 'additional-classes' ] ); |
|
| 415 | 415 | // check our custom class array for field-left/field-right |
| 416 | 416 | // if it's set we need to assign it to our label and remove it from the field classes |
| 417 | 417 | // input half left |
| 418 | - if( in_array( 'field-left-half' , $custom_classes ) ) { |
|
| 418 | + if ( in_array( 'field-left-half', $custom_classes ) ) { |
|
| 419 | 419 | // $label_array['class'] = 'class="field-left-half"'; |
| 420 | - $label_class_array[] = 'field-left-half'; |
|
| 421 | - $key = array_search( 'field-left-half' , $custom_classes ); |
|
| 422 | - unset( $custom_classes[$key] ); |
|
| 420 | + $label_class_array[ ] = 'field-left-half'; |
|
| 421 | + $key = array_search( 'field-left-half', $custom_classes ); |
|
| 422 | + unset( $custom_classes[ $key ] ); |
|
| 423 | 423 | } // input half right |
| 424 | - if( in_array( 'field-right-half' , $custom_classes ) ) { |
|
| 424 | + if ( in_array( 'field-right-half', $custom_classes ) ) { |
|
| 425 | 425 | // $label_array['class'] = 'class="field-right-half"'; |
| 426 | - $label_class_array[] = 'field-right-half'; |
|
| 427 | - $key = array_search( 'field-right-half' , $custom_classes ); |
|
| 428 | - unset( $custom_classes[$key] ); |
|
| 426 | + $label_class_array[ ] = 'field-right-half'; |
|
| 427 | + $key = array_search( 'field-right-half', $custom_classes ); |
|
| 428 | + unset( $custom_classes[ $key ] ); |
|
| 429 | 429 | } // input thirds (1/3 width, floated left) |
| 430 | - if( in_array( 'field-third' , $custom_classes ) ) { |
|
| 430 | + if ( in_array( 'field-third', $custom_classes ) ) { |
|
| 431 | 431 | // $label_array['class'] = 'class="field-third"'; |
| 432 | - $label_class_array[] = 'field-third'; |
|
| 433 | - $key = array_search( 'field-third' , $custom_classes ); |
|
| 434 | - unset( $custom_classes[$key] ); |
|
| 432 | + $label_class_array[ ] = 'field-third'; |
|
| 433 | + $key = array_search( 'field-third', $custom_classes ); |
|
| 434 | + unset( $custom_classes[ $key ] ); |
|
| 435 | 435 | } // 2 column radio |
| 436 | - if( in_array( 'option-2-col' , $custom_classes ) ) { |
|
| 436 | + if ( in_array( 'option-2-col', $custom_classes ) ) { |
|
| 437 | 437 | // $label_array['class'] = 'class="option-2-col"'; |
| 438 | - $label_class_array[] = 'option-2-col'; |
|
| 439 | - $key = array_search( 'option-2-col' , $custom_classes ); |
|
| 440 | - unset( $custom_classes[$key] ); |
|
| 438 | + $label_class_array[ ] = 'option-2-col'; |
|
| 439 | + $key = array_search( 'option-2-col', $custom_classes ); |
|
| 440 | + unset( $custom_classes[ $key ] ); |
|
| 441 | 441 | } // 3 column radio |
| 442 | - if( in_array( 'option-3-col' , $custom_classes ) ) { |
|
| 442 | + if ( in_array( 'option-3-col', $custom_classes ) ) { |
|
| 443 | 443 | // $label_array['class'] = 'class="option-3-col"'; |
| 444 | - $label_class_array[] = 'option-3-col'; |
|
| 445 | - $key = array_search( 'option-3-col' , $custom_classes ); |
|
| 446 | - unset( $custom_classes[$key] ); |
|
| 444 | + $label_class_array[ ] = 'option-3-col'; |
|
| 445 | + $key = array_search( 'option-3-col', $custom_classes ); |
|
| 446 | + unset( $custom_classes[ $key ] ); |
|
| 447 | 447 | } // 4 column radio |
| 448 | - if( in_array( 'option-4-col' , $custom_classes ) ) { |
|
| 448 | + if ( in_array( 'option-4-col', $custom_classes ) ) { |
|
| 449 | 449 | // $label_array['class'] = 'class="option-4-col"'; |
| 450 | - $label_class_array[] = 'option-4-col'; |
|
| 451 | - $key = array_search( 'option-4-col' , $custom_classes ); |
|
| 452 | - unset( $custom_classes[$key] ); |
|
| 450 | + $label_class_array[ ] = 'option-4-col'; |
|
| 451 | + $key = array_search( 'option-4-col', $custom_classes ); |
|
| 452 | + unset( $custom_classes[ $key ] ); |
|
| 453 | 453 | } // inline radio & checkboxes etc |
| 454 | - if( in_array( 'option-inline' , $custom_classes ) ) { |
|
| 454 | + if ( in_array( 'option-inline', $custom_classes ) ) { |
|
| 455 | 455 | // $label_array['class'] = 'class="option-inline"'; |
| 456 | - $label_class_array[] = 'option-inline'; |
|
| 457 | - $key = array_search( 'option-inline' , $custom_classes ); |
|
| 458 | - unset( $custom_classes[$key] ); |
|
| 456 | + $label_class_array[ ] = 'option-inline'; |
|
| 457 | + $key = array_search( 'option-inline', $custom_classes ); |
|
| 458 | + unset( $custom_classes[ $key ] ); |
|
| 459 | 459 | } |
| 460 | 460 | } else { |
| 461 | 461 | $custom_classes = array(); |
@@ -463,19 +463,19 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | // if the form is set to inline, add the inline class to our labels |
| 465 | 465 | // since @6.0.3.8 |
| 466 | - if( $form_inline ) { |
|
| 467 | - $label_class_array[] = 'label-inline'; |
|
| 466 | + if ( $form_inline ) { |
|
| 467 | + $label_class_array[ ] = 'label-inline'; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - if( isset( $field['hide-label'] ) ) { |
|
| 471 | - if( absint( $field['hide-label'] ) === 1 ) { |
|
| 470 | + if ( isset( $field[ 'hide-label' ] ) ) { |
|
| 471 | + if ( absint( $field[ 'hide-label' ] ) === 1 ) { |
|
| 472 | 472 | $hidden_label_count++; |
| 473 | - $custom_classes[] = 'field-no-label'; |
|
| 473 | + $custom_classes[ ] = 'field-no-label'; |
|
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /* Store tag variable based on field type */ |
| 478 | - if( isset( $field['merge'] ) ) { |
|
| 478 | + if ( isset( $field[ 'merge' ] ) ) { |
|
| 479 | 479 | $group = ''; |
| 480 | 480 | $tag = 'merge'; |
| 481 | 481 | } else { |
@@ -485,28 +485,28 @@ discard block |
||
| 485 | 485 | |
| 486 | 486 | // build up our array |
| 487 | 487 | $field_id_string = 'yikes-easy-mc-form-' . $form_id . '-' . $field[ $tag ]; |
| 488 | - $field_array['id'] = 'id="' . esc_attr( $field_id_string ) . '" '; |
|
| 489 | - $field_array['name'] = 'name="' . $group . esc_attr( $field[ $tag ] ) . '" '; |
|
| 490 | - $field_array['placeholder'] = isset( $field['placeholder'] ) ? 'placeholder="' . esc_attr( stripslashes( $field['placeholder'] ) ) . '" ' : ''; |
|
| 491 | - $field_array['classes'] = 'class="yikes-easy-mc-'.$field['type'] . ' ' . esc_attr( trim( implode( ' ' , $custom_classes ) ) ) . '" '; |
|
| 488 | + $field_array[ 'id' ] = 'id="' . esc_attr( $field_id_string ) . '" '; |
|
| 489 | + $field_array[ 'name' ] = 'name="' . $group . esc_attr( $field[ $tag ] ) . '" '; |
|
| 490 | + $field_array[ 'placeholder' ] = isset( $field[ 'placeholder' ] ) ? 'placeholder="' . esc_attr( stripslashes( $field[ 'placeholder' ] ) ) . '" ' : ''; |
|
| 491 | + $field_array[ 'classes' ] = 'class="yikes-easy-mc-' . $field[ 'type' ] . ' ' . esc_attr( trim( implode( ' ', $custom_classes ) ) ) . '" '; |
|
| 492 | 492 | |
| 493 | 493 | // email must always be required and visible |
| 494 | - if( $field['type'] == 'email' ) { |
|
| 495 | - $field_array['required'] = 'required="required"'; |
|
| 496 | - $label_array['visible'] = ''; |
|
| 497 | - $label_class_array[] = $field['merge'] . '-label'; |
|
| 498 | - $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 494 | + if ( $field[ 'type' ] == 'email' ) { |
|
| 495 | + $field_array[ 'required' ] = 'required="required"'; |
|
| 496 | + $label_array[ 'visible' ] = ''; |
|
| 497 | + $label_class_array[ ] = $field[ 'merge' ] . '-label'; |
|
| 498 | + $label_class_array[ ] = 'yikes-mailchimp-field-required'; |
|
| 499 | 499 | } else { |
| 500 | - $field_array['required'] = isset( $field['require'] ) ? 'required="required"' : ''; |
|
| 501 | - $label_array['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
| 502 | - $label_class_array[] = ( $tag === 'merge' ) ? $field['merge'] . '-label' : $field['group_id'] . '-label'; |
|
| 503 | - if ( isset( $field['require'] ) ) $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 500 | + $field_array[ 'required' ] = isset( $field[ 'require' ] ) ? 'required="required"' : ''; |
|
| 501 | + $label_array[ 'visible' ] = isset( $field[ 'hide' ] ) ? 'style="display:none;"' : ''; |
|
| 502 | + $label_class_array[ ] = ( $tag === 'merge' ) ? $field[ 'merge' ] . '-label' : $field[ 'group_id' ] . '-label'; |
|
| 503 | + if ( isset( $field[ 'require' ] ) ) $label_class_array[ ] = 'yikes-mailchimp-field-required'; |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | // if both hide label and hide field are checked, we gotta hide the field! |
| 507 | - if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
| 508 | - if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
| 509 | - $field_array['visible'] = 'style="display:none;"'; |
|
| 507 | + if ( isset( $field[ 'hide' ] ) && $field[ 'hide' ] == 1 ) { |
|
| 508 | + if ( isset( $field[ 'hide-label' ] ) && $field[ 'hide-label' ] == 1 ) { |
|
| 509 | + $field_array[ 'visible' ] = 'style="display:none;"'; |
|
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | |
@@ -514,20 +514,20 @@ discard block |
||
| 514 | 514 | $label_class_array = function_exists( 'sanitize_html_class' ) ? array_map( 'sanitize_html_class', $label_class_array ) : $label_class_array; |
| 515 | 515 | |
| 516 | 516 | // Turn the clases into a string |
| 517 | - $label_array['classes'] = 'class="' . implode( ' ', $label_class_array ) . ' "'; |
|
| 517 | + $label_array[ 'classes' ] = 'class="' . implode( ' ', $label_class_array ) . ' "'; |
|
| 518 | 518 | |
| 519 | 519 | // Filter the field array data |
| 520 | 520 | $field_array = apply_filters( 'yikes-mailchimp-field-data', $field_array, $field, $form_id ); |
| 521 | 521 | |
| 522 | 522 | /* Loop Over Standard Fields (aka merge variables) */ |
| 523 | - if( isset( $field['merge'] ) ) { |
|
| 523 | + if ( isset( $field[ 'merge' ] ) ) { |
|
| 524 | 524 | |
| 525 | 525 | // Handle the Description logic in one spot, here: |
| 526 | - $show_description = isset( $field['description'] ) && trim( $field['description'] ) !== '' ? true : false; |
|
| 527 | - $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 526 | + $show_description = isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) !== '' ? true : false; |
|
| 527 | + $description_above = isset( $field[ 'description_above' ] ) && $field[ 'description_above' ] === '1' ? true : false; |
|
| 528 | 528 | if ( $show_description === true ) { |
| 529 | - $description = '<p class="form-field-description" id="form-field-description-' . $field['merge'] . '">'; |
|
| 530 | - $description .= apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 529 | + $description = '<p class="form-field-description" id="form-field-description-' . $field[ 'merge' ] . '">'; |
|
| 530 | + $description .= apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 531 | 531 | $description .= '</p>'; |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -539,11 +539,11 @@ discard block |
||
| 539 | 539 | * @param string | $field['description'] | The field's description text |
| 540 | 540 | * @param int | $form_id |
| 541 | 541 | */ |
| 542 | - $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description-html', $description, esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 542 | + $description = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description-html', $description, esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | // loop over our fields by Type |
| 546 | - switch ( $field['type'] ) { |
|
| 546 | + switch ( $field[ 'type' ] ) { |
|
| 547 | 547 | |
| 548 | 548 | default: |
| 549 | 549 | case 'email': |
@@ -551,24 +551,24 @@ discard block |
||
| 551 | 551 | case 'number': |
| 552 | 552 | |
| 553 | 553 | // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
| 554 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 554 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 555 | 555 | $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
| 556 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 556 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 557 | 557 | |
| 558 | 558 | ?> |
| 559 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 559 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 560 | 560 | |
| 561 | 561 | <!-- dictate label visibility --> |
| 562 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 563 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 564 | - <?php if( ! isset( $field['hide-label'] ) ) { echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ), $form_id ); } ?> |
|
| 562 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 563 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 564 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ), $form_id ); } ?> |
|
| 565 | 565 | </span> |
| 566 | 566 | <?php } ?> |
| 567 | 567 | |
| 568 | 568 | <!-- Description Above --> |
| 569 | 569 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 570 | 570 | |
| 571 | - <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 esc_attr( $_POST[$field['merge']] ); } else { echo esc_attr( $default_value ); } ?>"> |
|
| 571 | + <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 esc_attr( $_POST[ $field[ 'merge' ] ] ); } else { echo esc_attr( $default_value ); } ?>"> |
|
| 572 | 572 | |
| 573 | 573 | <!-- Description Below --> |
| 574 | 574 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -580,23 +580,23 @@ discard block |
||
| 580 | 580 | |
| 581 | 581 | case 'url': |
| 582 | 582 | case 'imageurl': |
| 583 | - $default_value = ( isset( $field['default'] ) ) ? $field['default'] : ''; |
|
| 584 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 583 | + $default_value = ( isset( $field[ 'default' ] ) ) ? $field[ 'default' ] : ''; |
|
| 584 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 585 | 585 | ?> |
| 586 | 586 | |
| 587 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 587 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 588 | 588 | |
| 589 | 589 | <!-- dictate label visibility --> |
| 590 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 591 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 592 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 590 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 591 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 592 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 593 | 593 | </span> |
| 594 | 594 | <?php } ?> |
| 595 | 595 | |
| 596 | 596 | <!-- Description Above --> |
| 597 | 597 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 598 | 598 | |
| 599 | - <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 esc_attr( $_POST[$field['merge']] ); } else { echo esc_attr( $default_value ); } ?>" > |
|
| 599 | + <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 esc_attr( $_POST[ $field[ 'merge' ] ] ); } else { echo esc_attr( $default_value ); } ?>" > |
|
| 600 | 600 | |
| 601 | 601 | <!-- Description Below --> |
| 602 | 602 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -607,24 +607,24 @@ discard block |
||
| 607 | 607 | break; |
| 608 | 608 | |
| 609 | 609 | case 'phone': |
| 610 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 611 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 612 | - $phone_format = $field['phone_format']; |
|
| 610 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 611 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 612 | + $phone_format = $field[ 'phone_format' ]; |
|
| 613 | 613 | ?> |
| 614 | 614 | |
| 615 | - <label for="<?php echo esc_attr( $field_id_string ) ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 615 | + <label for="<?php echo esc_attr( $field_id_string ) ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 616 | 616 | |
| 617 | 617 | <!-- dictate label visibility --> |
| 618 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 619 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 620 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 618 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 619 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 620 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 621 | 621 | </span> |
| 622 | 622 | <?php } ?> |
| 623 | 623 | |
| 624 | 624 | <!-- Description Above --> |
| 625 | 625 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 626 | 626 | |
| 627 | - <input <?php echo implode( ' ' , $field_array ); ?> type="text" <?php if( $phone_format != 'US' ) { ?> data-phone-type="international" 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' ); ?>" data-phone-type="us" pattern="<?php echo apply_filters( 'yikes-mailchimp-us-phone-pattern' , '^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$' ); ?>" <?php } ?> value="<?php if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { echo esc_attr( $_POST[$field['merge']] ); } else { echo esc_attr( $default_value ); } ?>"> |
|
| 627 | + <input <?php echo implode( ' ', $field_array ); ?> type="text" <?php if ( $phone_format != 'US' ) { ?> data-phone-type="international" 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' ); ?>" data-phone-type="us" pattern="<?php echo apply_filters( 'yikes-mailchimp-us-phone-pattern', '^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$' ); ?>" <?php } ?> value="<?php if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { echo esc_attr( $_POST[ $field[ 'merge' ] ] ); } else { echo esc_attr( $default_value ); } ?>"> |
|
| 628 | 628 | |
| 629 | 629 | <!-- Description Below --> |
| 630 | 630 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -634,23 +634,23 @@ discard block |
||
| 634 | 634 | break; |
| 635 | 635 | |
| 636 | 636 | case 'zip': |
| 637 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 638 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 637 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 638 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 639 | 639 | |
| 640 | 640 | ?> |
| 641 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 641 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 642 | 642 | |
| 643 | 643 | <!-- dictate label visibility --> |
| 644 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 645 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 646 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 644 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 645 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 646 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 647 | 647 | </span> |
| 648 | 648 | <?php } ?> |
| 649 | 649 | |
| 650 | 650 | <!-- Description Above --> |
| 651 | 651 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 652 | 652 | |
| 653 | - <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 esc_attr( $_POST[$field['merge']] ); } else { echo esc_attr( $default_value ); } ?>"> |
|
| 653 | + <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 esc_attr( $_POST[ $field[ 'merge' ] ] ); } else { echo esc_attr( $default_value ); } ?>"> |
|
| 654 | 654 | |
| 655 | 655 | <!-- Description Below --> |
| 656 | 656 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | case 'address': |
| 664 | 664 | |
| 665 | 665 | // required fields |
| 666 | - $required_fields = array( 'addr1' => 'address' , 'addr2' => 'address 2', 'city' => 'city', 'state' =>'state', 'zip' =>'zip' , 'country' => 'country' ); |
|
| 666 | + $required_fields = array( 'addr1' => 'address', 'addr2' => 'address 2', 'city' => 'city', 'state' =>'state', 'zip' =>'zip', 'country' => 'country' ); |
|
| 667 | 667 | |
| 668 | 668 | /** |
| 669 | 669 | * Filter to control the default country (the option pre-selected in the country dropdown). |
@@ -679,55 +679,55 @@ discard block |
||
| 679 | 679 | if ( $show_description === true && $description_above === true ) { echo $description; } |
| 680 | 680 | |
| 681 | 681 | // Placeholder logic |
| 682 | - if ( ! empty( $field_array['placeholder'] ) ) { |
|
| 682 | + if ( ! empty( $field_array[ 'placeholder' ] ) ) { |
|
| 683 | 683 | |
| 684 | 684 | $use_address_placeholder = true; |
| 685 | 685 | |
| 686 | 686 | // Don't use the address field's array placeholder - use the custom placeholder |
| 687 | - unset( $field_array['placeholder'] ); |
|
| 687 | + unset( $field_array[ 'placeholder' ] ); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | // store number for looping |
| 691 | 691 | $x = 1; |
| 692 | - foreach( $required_fields as $type => $label ) { |
|
| 692 | + foreach ( $required_fields as $type => $label ) { |
|
| 693 | 693 | |
| 694 | 694 | // set the field names for the address fields |
| 695 | - $field_array['name'] = 'name="' . $field[$tag] . '[' . $type . ']' . '"'; |
|
| 695 | + $field_array[ 'name' ] = 'name="' . $field[ $tag ] . '[' . $type . ']' . '"'; |
|
| 696 | 696 | |
| 697 | 697 | // Set the placeholder value if we need to |
| 698 | 698 | $placeholder = isset( $use_address_placeholder ) ? apply_filters( 'yikes-mailchimp-address-' . $type . '-placeholder', ucwords( $label ) ) : ''; |
| 699 | 699 | |
| 700 | 700 | // reset the label classes for left-half/right-half for addresses |
| 701 | - if( isset( $label_array['class'] ) ) { |
|
| 701 | + if ( isset( $label_array[ 'class' ] ) ) { |
|
| 702 | 702 | if ( $x % 2 == 0 ) { |
| 703 | - $label_array['class'] = str_replace( 'field-left-half', 'field-right-half', $label_array['class'] ); |
|
| 703 | + $label_array[ 'class' ] = str_replace( 'field-left-half', 'field-right-half', $label_array[ 'class' ] ); |
|
| 704 | 704 | } else { |
| 705 | - $label_array['class'] = str_replace( 'field-right-half', 'field-left-half', $label_array['class'] ); |
|
| 705 | + $label_array[ 'class' ] = str_replace( 'field-right-half', 'field-left-half', $label_array[ 'class' ] ); |
|
| 706 | 706 | } |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | // Never force addr2 to be required |
| 710 | 710 | if ( $type === 'addr2' ) { |
| 711 | - $field_array['required'] = apply_filters( 'yikes-mailchimp-address-2-required', '', $form_id ); |
|
| 711 | + $field_array[ 'required' ] = apply_filters( 'yikes-mailchimp-address-2-required', '', $form_id ); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - switch( $type ) { |
|
| 714 | + switch ( $type ) { |
|
| 715 | 715 | |
| 716 | 716 | default: |
| 717 | 717 | case 'addr1': |
| 718 | 718 | case 'addr2': |
| 719 | 719 | case 'city': |
| 720 | 720 | ?> |
| 721 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 721 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ', $label_array ); ?>> |
|
| 722 | 722 | |
| 723 | 723 | <!-- dictate label visibility --> |
| 724 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 725 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 726 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 724 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 725 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 726 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 727 | 727 | </span> |
| 728 | 728 | <?php } ?> |
| 729 | 729 | |
| 730 | - <input <?php echo implode( ' ' , $field_array ); ?> placeholder="<?php echo $placeholder; ?>" type="text" value="<?php if( isset( $_POST[$field['merge']][$type] ) && $form_submitted != 1 ) { echo esc_attr( $_POST[$field['merge']][$type] ); } ?>"> |
|
| 730 | + <input <?php echo implode( ' ', $field_array ); ?> placeholder="<?php echo $placeholder; ?>" type="text" value="<?php if ( isset( $_POST[ $field[ 'merge' ] ][ $type ] ) && $form_submitted != 1 ) { echo esc_attr( $_POST[ $field[ 'merge' ] ][ $type ] ); } ?>"> |
|
| 731 | 731 | |
| 732 | 732 | </label> |
| 733 | 733 | <?php |
@@ -736,16 +736,16 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | case 'state': |
| 738 | 738 | ?> |
| 739 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" <?php echo implode( ' ' , $label_array ); ?> data-attr-name="state-dropdown"> |
|
| 739 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" <?php echo implode( ' ', $label_array ); ?> data-attr-name="state-dropdown"> |
|
| 740 | 740 | |
| 741 | 741 | <!-- dictate label visibility --> |
| 742 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 743 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 744 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 742 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 743 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 744 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 745 | 745 | </span> |
| 746 | 746 | <?php } ?> |
| 747 | 747 | |
| 748 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
| 748 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
| 749 | 749 | <?php |
| 750 | 750 | $state_and_province_list = file_get_contents( YIKES_MC_PATH . 'public/partials/shortcodes/templates/state-and-province-dropdown.php' ); |
| 751 | 751 | /** |
@@ -771,21 +771,21 @@ discard block |
||
| 771 | 771 | case 'zip': |
| 772 | 772 | |
| 773 | 773 | ?> |
| 774 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" placeholder="<?php echo $placeholder; ?>" <?php echo implode( ' ' , $label_array ); ?> data-attr-name="zip-input"<?php if ( ! isset( $countries_with_zip_code_field[ $default_country ] ) ) { ?> style="display: none;"<?php } ?>> |
|
| 774 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" placeholder="<?php echo $placeholder; ?>" <?php echo implode( ' ', $label_array ); ?> data-attr-name="zip-input"<?php if ( ! isset( $countries_with_zip_code_field[ $default_country ] ) ) { ?> style="display: none;"<?php } ?>> |
|
| 775 | 775 | |
| 776 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 777 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 778 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 776 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 777 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 778 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 779 | 779 | </span> |
| 780 | 780 | <?php } ?> |
| 781 | 781 | |
| 782 | 782 | <?php |
| 783 | 783 | // If zip lookup plugin is installed, the ZIP field comes back as an array and we need to handle it differently... |
| 784 | - if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { |
|
| 785 | - if ( is_array( $_POST[$field['merge']] ) && isset( $_POST[$field['merge']]['zip'] ) ) { |
|
| 786 | - $zip_value = $_POST[$field['merge']]['zip']; |
|
| 784 | + if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { |
|
| 785 | + if ( is_array( $_POST[ $field[ 'merge' ] ] ) && isset( $_POST[ $field[ 'merge' ] ][ 'zip' ] ) ) { |
|
| 786 | + $zip_value = $_POST[ $field[ 'merge' ] ][ 'zip' ]; |
|
| 787 | 787 | } else { |
| 788 | - $zip_value = $_POST[$field['merge']]; |
|
| 788 | + $zip_value = $_POST[ $field[ 'merge' ] ]; |
|
| 789 | 789 | } |
| 790 | 790 | } else { |
| 791 | 791 | |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | } |
| 806 | 806 | ?> |
| 807 | 807 | |
| 808 | - <input <?php echo implode( ' ' , $field_array ); ?> placeholder="<?php echo $placeholder; ?>" type="text" pattern="<?php echo apply_filters( 'yikes-mailchimp-zip-pattern', '\d{5,5}(-\d{4,4})?', $form_id ); ?>" title="<?php _e( '5 digit zip code, numbers only' , 'yikes-inc-easy-mailchimp-extender' ); ?>" value="<?php echo esc_attr( $zip_value ); ?>"> |
|
| 808 | + <input <?php echo implode( ' ', $field_array ); ?> placeholder="<?php echo $placeholder; ?>" type="text" pattern="<?php echo apply_filters( 'yikes-mailchimp-zip-pattern', '\d{5,5}(-\d{4,4})?', $form_id ); ?>" title="<?php _e( '5 digit zip code, numbers only', 'yikes-inc-easy-mailchimp-extender' ); ?>" value="<?php echo esc_attr( $zip_value ); ?>"> |
|
| 809 | 809 | |
| 810 | 810 | </label> |
| 811 | 811 | <?php |
@@ -815,16 +815,16 @@ discard block |
||
| 815 | 815 | case 'country': |
| 816 | 816 | ?> |
| 817 | 817 | |
| 818 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 818 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ', $label_array ); ?>> |
|
| 819 | 819 | |
| 820 | 820 | <!-- dictate label visibility --> |
| 821 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 822 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 823 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 821 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 822 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 823 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 824 | 824 | </span> |
| 825 | 825 | <?php } ?> |
| 826 | 826 | |
| 827 | - <select <?php echo implode( ' ' , $field_array ); ?> data-country="true"> |
|
| 827 | + <select <?php echo implode( ' ', $field_array ); ?> data-country="true"> |
|
| 828 | 828 | <?php include( YIKES_MC_PATH . 'public/partials/shortcodes/templates/country-dropdown.php' ); ?> |
| 829 | 829 | </select> |
| 830 | 830 | </label> |
@@ -870,40 +870,40 @@ discard block |
||
| 870 | 870 | wp_register_script( 'yikes-datepicker-scripts', YIKES_MC_URL . 'public/js/yikes-datepicker-scripts.min.js', array( 'jquery-ui-datepicker' ), YIKES_MC_VERSION, false ); |
| 871 | 871 | wp_localize_script( 'yikes-datepicker-scripts', 'datepicker_settings', $datepicker_options ); |
| 872 | 872 | wp_enqueue_script( 'yikes-datepicker-scripts' ); |
| 873 | - wp_enqueue_style( 'jquery-datepicker-styles' , YIKES_MC_URL . 'public/css/jquery-ui.min.css' ); |
|
| 874 | - wp_enqueue_style( 'yikes-datepicker-styles' , YIKES_MC_URL . 'public/css/yikes-datepicker-styles.min.css' ); |
|
| 873 | + wp_enqueue_style( 'jquery-datepicker-styles', YIKES_MC_URL . 'public/css/jquery-ui.min.css' ); |
|
| 874 | + wp_enqueue_style( 'yikes-datepicker-styles', YIKES_MC_URL . 'public/css/yikes-datepicker-styles.min.css' ); |
|
| 875 | 875 | |
| 876 | - switch ( $field['type'] ) { |
|
| 876 | + switch ( $field[ 'type' ] ) { |
|
| 877 | 877 | default: |
| 878 | 878 | case 'date': |
| 879 | - $date_format = ( isset( $field['date_format'] ) ) ? $field['date_format'] : 'mm/dd/yyyy'; |
|
| 879 | + $date_format = ( isset( $field[ 'date_format' ] ) ) ? $field[ 'date_format' ] : 'mm/dd/yyyy'; |
|
| 880 | 880 | break; |
| 881 | 881 | |
| 882 | 882 | case 'birthday': |
| 883 | - $date_format = ( isset( $field['date_format'] ) ) ? strtolower( $field['date_format'] ) : 'mm/dd'; |
|
| 883 | + $date_format = ( isset( $field[ 'date_format' ] ) ) ? strtolower( $field[ 'date_format' ] ) : 'mm/dd'; |
|
| 884 | 884 | break; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 888 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 887 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 888 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 889 | 889 | |
| 890 | 890 | // store empty number for looping |
| 891 | 891 | $x = 0; |
| 892 | 892 | |
| 893 | 893 | ?> |
| 894 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 894 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 895 | 895 | |
| 896 | 896 | <!-- dictate label visibility --> |
| 897 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 898 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 899 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 897 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 898 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 899 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 900 | 900 | </span> |
| 901 | 901 | <?php } ?> |
| 902 | 902 | |
| 903 | 903 | <!-- Description Above --> |
| 904 | 904 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 905 | 905 | |
| 906 | - <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 esc_attr( $_POST[$field['merge']] ); } else { echo esc_attr( $default_value ); } ?>" data-date-format="<?php echo esc_attr( strtolower( $date_format ) ); ?>"> |
|
| 906 | + <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 esc_attr( $_POST[ $field[ 'merge' ] ] ); } else { echo esc_attr( $default_value ); } ?>" data-date-format="<?php echo esc_attr( strtolower( $date_format ) ); ?>"> |
|
| 907 | 907 | |
| 908 | 908 | <!-- Description Below --> |
| 909 | 909 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -914,26 +914,26 @@ discard block |
||
| 914 | 914 | break; |
| 915 | 915 | |
| 916 | 916 | case 'dropdown': |
| 917 | - $no_default = $field['default_choice'] === 'no-default' || isset( $field['default_choice'][0] ) && $field['default_choice'][0] === 'no-default'; |
|
| 918 | - $default_choice = is_array( $field['default_choice'] ) ? $field['default_choice'] : array( $field['default_choice'] ); |
|
| 917 | + $no_default = $field[ 'default_choice' ] === 'no-default' || isset( $field[ 'default_choice' ][ 0 ] ) && $field[ 'default_choice' ][ 0 ] === 'no-default'; |
|
| 918 | + $default_choice = is_array( $field[ 'default_choice' ] ) ? $field[ 'default_choice' ] : array( $field[ 'default_choice' ] ); |
|
| 919 | 919 | |
| 920 | 920 | // store empty number for looping |
| 921 | 921 | $x = 0; |
| 922 | 922 | ?> |
| 923 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 923 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 924 | 924 | <!-- dictate label visibility --> |
| 925 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 926 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 927 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 925 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 926 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 927 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 928 | 928 | </span> |
| 929 | 929 | <?php } |
| 930 | 930 | |
| 931 | 931 | // decode for looping |
| 932 | - $choices = json_decode( $field['choices'], true ); |
|
| 932 | + $choices = json_decode( $field[ 'choices' ], true ); |
|
| 933 | 933 | |
| 934 | 934 | // If the form was submitted, but failed, let's default to the chosen option |
| 935 | - if( isset( $_POST[ $field['merge'] ] ) && $form_submitted === 0 ) { |
|
| 936 | - $default_choice = is_array( $_POST[ $field['merge'] ] ) ? $_POST[ $field['merge'] ] : array( $_POST[ $field['merge'] ] ); |
|
| 935 | + if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted === 0 ) { |
|
| 936 | + $default_choice = is_array( $_POST[ $field[ 'merge' ] ] ) ? $_POST[ $field[ 'merge' ] ] : array( $_POST[ $field[ 'merge' ] ] ); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | ?> |
@@ -941,11 +941,11 @@ discard block |
||
| 941 | 941 | <!-- Description Above --> |
| 942 | 942 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 943 | 943 | |
| 944 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
| 944 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
| 945 | 945 | <?php |
| 946 | 946 | $no_default_name = apply_filters( 'yikes-mailchimp-dropdown-field-no-default-option-name', __( 'Select...', 'yikes-inc-easy-mailchimp-extender' ), $form_id ); |
| 947 | 947 | echo $no_default === true ? '<option value="">' . $no_default_name . '</option>' : ''; |
| 948 | - foreach( $choices as $choice ) { ?> |
|
| 948 | + foreach ( $choices as $choice ) { ?> |
|
| 949 | 949 | <option |
| 950 | 950 | value="<?php echo esc_attr( $choice ); ?>" |
| 951 | 951 | <?php if ( $no_default !== true && in_array( $x, $default_choice ) || in_array( $choice, $default_choice, true ) ) { echo 'selected="selected"'; } ?>> |
@@ -968,17 +968,17 @@ discard block |
||
| 968 | 968 | case 'radio': |
| 969 | 969 | case 'checkbox': |
| 970 | 970 | // remove the ID (as to not assign the same ID to every radio button) |
| 971 | - unset( $field_array['id'] ); |
|
| 972 | - $choices = json_decode( $field['choices'], true ); |
|
| 971 | + unset( $field_array[ 'id' ] ); |
|
| 972 | + $choices = json_decode( $field[ 'choices' ], true ); |
|
| 973 | 973 | |
| 974 | 974 | // assign a default choice |
| 975 | - $no_default = $field['default_choice'] === 'no-default' || isset( $field['default_choice'][0] ) && $field['default_choice'][0] === 'no-default'; |
|
| 976 | - $default_choice = ( isset( $field['default_choice'] ) && ! empty( $field['default_choice'] ) ) ? $field['default_choice'] : $choices[0]; |
|
| 975 | + $no_default = $field[ 'default_choice' ] === 'no-default' || isset( $field[ 'default_choice' ][ 0 ] ) && $field[ 'default_choice' ][ 0 ] === 'no-default'; |
|
| 976 | + $default_choice = ( isset( $field[ 'default_choice' ] ) && ! empty( $field[ 'default_choice' ] ) ) ? $field[ 'default_choice' ] : $choices[ 0 ]; |
|
| 977 | 977 | $default_choice = ( is_array( $default_choice ) ) ? $default_choice : array( $default_choice ); |
| 978 | 978 | |
| 979 | 979 | // If the form was submitted, but failed, let's default to the chosen option |
| 980 | - if( isset( $_POST[ $field['merge'] ] ) && $form_submitted === 0 ) { |
|
| 981 | - $default_choice = is_array( $_POST[ $field['merge'] ] ) ? $_POST[ $field['merge'] ] : array( $_POST[ $field['merge'] ] ); |
|
| 980 | + if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted === 0 ) { |
|
| 981 | + $default_choice = is_array( $_POST[ $field[ 'merge' ] ] ) ? $_POST[ $field[ 'merge' ] ] : array( $_POST[ $field[ 'merge' ] ] ); |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | $count = count( $choices ); |
@@ -986,29 +986,29 @@ discard block |
||
| 986 | 986 | $x = 0; |
| 987 | 987 | |
| 988 | 988 | ?> |
| 989 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 989 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 990 | 990 | |
| 991 | 991 | <!-- dictate label visibility --> |
| 992 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 993 | - <span class="<?php echo esc_attr( $field['merge'] ). '-label'; ?> checkbox-parent-label"> |
|
| 994 | - <?php echo esc_attr( apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label', stripslashes( $field['label'] ) ) ); ?> |
|
| 992 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 993 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?> checkbox-parent-label"> |
|
| 994 | + <?php echo esc_attr( apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 995 | 995 | </span> |
| 996 | 996 | <?php } |
| 997 | 997 | |
| 998 | 998 | // <!-- Description Above --> |
| 999 | 999 | if ( $show_description === true && $description_above === true ) { echo $description; } |
| 1000 | 1000 | |
| 1001 | - foreach( $choices as $choice ) { |
|
| 1001 | + foreach ( $choices as $choice ) { |
|
| 1002 | 1002 | ?> |
| 1003 | - <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 } ?>"> |
|
| 1003 | + <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 } ?>"> |
|
| 1004 | 1004 | <input |
| 1005 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
| 1006 | - name="<?php echo esc_attr( $field['merge'] ); ?>" |
|
| 1007 | - id="<?php echo esc_attr( $field['merge'] . '-' . $i ); ?>" |
|
| 1005 | + type="<?php echo esc_attr( $field[ 'type' ] ); ?>" |
|
| 1006 | + name="<?php echo esc_attr( $field[ 'merge' ] ); ?>" |
|
| 1007 | + id="<?php echo esc_attr( $field[ 'merge' ] . '-' . $i ); ?>" |
|
| 1008 | 1008 | <?php if ( $no_default !== true && in_array( $x, $default_choice ) || in_array( $choice, $default_choice, true ) ) { echo 'checked="checked"'; } ?> |
| 1009 | - <?php echo $field_array['required']; ?> |
|
| 1009 | + <?php echo $field_array[ 'required' ]; ?> |
|
| 1010 | 1010 | value="<?php echo esc_attr( $choice ); ?>"> |
| 1011 | - <span class="<?php echo esc_attr( $field['merge'] ). '-label'; ?>"><?php echo stripslashes( $choice ); ?></span> |
|
| 1011 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"><?php echo stripslashes( $choice ); ?></span> |
|
| 1012 | 1012 | </label> |
| 1013 | 1013 | <?php |
| 1014 | 1014 | $i++; |
@@ -1029,11 +1029,11 @@ discard block |
||
| 1029 | 1029 | /**** Interest Groups ****/ |
| 1030 | 1030 | |
| 1031 | 1031 | // Handle the Description logic in one spot, here: |
| 1032 | - $show_description = isset( $field['description'] ) && trim( $field['description'] ) !== '' ? true : false; |
|
| 1033 | - $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 1032 | + $show_description = isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) !== '' ? true : false; |
|
| 1033 | + $description_above = isset( $field[ 'description_above' ] ) && $field[ 'description_above' ] === '1' ? true : false; |
|
| 1034 | 1034 | if ( $show_description === true ) { |
| 1035 | - $description = '<p class="form-field-description" id="form-field-description-' . $field['group_id'] . '">'; |
|
| 1036 | - $description .= apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 1035 | + $description = '<p class="form-field-description" id="form-field-description-' . $field[ 'group_id' ] . '">'; |
|
| 1036 | + $description .= apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 1037 | 1037 | $description .= '</p>'; |
| 1038 | 1038 | |
| 1039 | 1039 | /** |
@@ -1045,28 +1045,28 @@ discard block |
||
| 1045 | 1045 | * @param string | $field['description'] | The field's description text |
| 1046 | 1046 | * @param int | $form_id |
| 1047 | 1047 | */ |
| 1048 | - $description = apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description-html', $description, esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 1048 | + $description = apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-description-html', $description, esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | // Get our groups |
| 1052 | - $groups = isset( $field['groups'] ) && ! empty( $field['groups'] ) ? json_decode( $field['groups'], true ) : array(); |
|
| 1052 | + $groups = isset( $field[ 'groups' ] ) && ! empty( $field[ 'groups' ] ) ? json_decode( $field[ 'groups' ], true ) : array(); |
|
| 1053 | 1053 | |
| 1054 | 1054 | // Get the default choice(s) from the field settings and turn them into an array if not already |
| 1055 | - $default_choice = isset( $field['default_choice'] ) ? $field['default_choice'] : ''; |
|
| 1055 | + $default_choice = isset( $field[ 'default_choice' ] ) ? $field[ 'default_choice' ] : ''; |
|
| 1056 | 1056 | $default_choice = is_array( $default_choice ) ? $default_choice : array( $default_choice ); |
| 1057 | - $default_choice = apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-default', $default_choice, $groups, $field, $form_id ); |
|
| 1057 | + $default_choice = apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-default', $default_choice, $groups, $field, $form_id ); |
|
| 1058 | 1058 | |
| 1059 | 1059 | |
| 1060 | 1060 | $count = count( $groups ); |
| 1061 | 1061 | |
| 1062 | - if( $field['type'] === 'checkboxes' ) { |
|
| 1062 | + if ( $field[ 'type' ] === 'checkboxes' ) { |
|
| 1063 | 1063 | $type = 'checkbox'; |
| 1064 | - } else if( $field['type'] === 'radio' ) { |
|
| 1064 | + } else if ( $field[ 'type' ] === 'radio' ) { |
|
| 1065 | 1065 | $type = 'radio'; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | // loop over the interest group field types |
| 1069 | - switch ( $field['type'] ) { |
|
| 1069 | + switch ( $field[ 'type' ] ) { |
|
| 1070 | 1070 | |
| 1071 | 1071 | case 'checkboxes': |
| 1072 | 1072 | case 'radio': |
@@ -1074,11 +1074,11 @@ discard block |
||
| 1074 | 1074 | $x = 1; // used to find the last item of our array |
| 1075 | 1075 | |
| 1076 | 1076 | ?> |
| 1077 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 1078 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 1077 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 1078 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 1079 | 1079 | <!-- dictate label visibility --> |
| 1080 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?> checkbox-parent-label"> |
|
| 1081 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 1080 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?> checkbox-parent-label"> |
|
| 1081 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 1082 | 1082 | </span> |
| 1083 | 1083 | <?php |
| 1084 | 1084 | } |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | |
| 1089 | 1089 | // Display Submission Errors |
| 1090 | 1090 | if ( ! empty( $missing_required_checkbox_interest_groups ) ) { |
| 1091 | - if( in_array( $field['group_id'], $missing_required_checkbox_interest_groups ) ) { |
|
| 1091 | + if ( in_array( $field[ 'group_id' ], $missing_required_checkbox_interest_groups ) ) { |
|
| 1092 | 1092 | ?> |
| 1093 | 1093 | <p class="yikes-mailchimp-required-interest-group-error"> |
| 1094 | 1094 | <?php echo apply_filters( 'yikes-mailchimp-interest-group-checkbox-error', __( 'This field is required.', 'yikes-inc-easy-mailchimp-extender' ), $form_id ); ?> |
@@ -1100,20 +1100,20 @@ discard block |
||
| 1100 | 1100 | foreach ( $groups as $group_id => $name ) { |
| 1101 | 1101 | |
| 1102 | 1102 | // If the form was submitted and failed, set the submitted/chosen values as the default |
| 1103 | - if ( isset( $_POST[ 'group-' . $field['group_id'] ] ) && $form_submitted === 0 ) { |
|
| 1103 | + if ( isset( $_POST[ 'group-' . $field[ 'group_id' ] ] ) && $form_submitted === 0 ) { |
|
| 1104 | 1104 | |
| 1105 | 1105 | // Format default choice as array |
| 1106 | - $default_choice = ( is_array( $_POST[ 'group-' . $field['group_id'] ] ) ) ? $_POST[ 'group-' . $field['group_id'] ] : array( $_POST[ 'group-' . $field['group_id'] ] ); |
|
| 1106 | + $default_choice = ( is_array( $_POST[ 'group-' . $field[ 'group_id' ] ] ) ) ? $_POST[ 'group-' . $field[ 'group_id' ] ] : array( $_POST[ 'group-' . $field[ 'group_id' ] ] ); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | ?> |
| 1110 | - <label for="<?php echo esc_attr( $field['group_id'] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ' , $custom_classes ); if( $x === $count ) { ?> last-selection<?php } ?>"> |
|
| 1110 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ', $custom_classes ); if ( $x === $count ) { ?> last-selection<?php } ?>"> |
|
| 1111 | 1111 | <input |
| 1112 | - <?php if( isset( $field['require'] ) && $field['require'] == 1 ) { if ( $field['type'] !== 'checkboxes' ) { ?> required="required" <?php } ?> |
|
| 1112 | + <?php if ( isset( $field[ 'require' ] ) && $field[ 'require' ] == 1 ) { if ( $field[ 'type' ] !== 'checkboxes' ) { ?> required="required" <?php } ?> |
|
| 1113 | 1113 | class="yikes-interest-group-required" <?php } ?> |
| 1114 | 1114 | type="<?php echo esc_attr( $type ); ?>" |
| 1115 | - name="group-<?php echo esc_attr( $field['group_id'] ); ?>[]" |
|
| 1116 | - id="<?php echo esc_attr( $field['group_id'] . '-' . $i ); ?>" |
|
| 1115 | + name="group-<?php echo esc_attr( $field[ 'group_id' ] ); ?>[]" |
|
| 1116 | + id="<?php echo esc_attr( $field[ 'group_id' ] . '-' . $i ); ?>" |
|
| 1117 | 1117 | <?php if ( in_array( $group_id, $default_choice ) ) { echo 'checked="checked"'; } ?> |
| 1118 | 1118 | value="<?php echo esc_attr( $group_id ); ?>"> |
| 1119 | 1119 | <?php echo esc_attr( $name ); ?> |
@@ -1135,32 +1135,32 @@ discard block |
||
| 1135 | 1135 | |
| 1136 | 1136 | ?> |
| 1137 | 1137 | |
| 1138 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 1138 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 1139 | 1139 | <!-- dictate label visibility --> |
| 1140 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 1141 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?>"> |
|
| 1142 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 1140 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 1141 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?>"> |
|
| 1142 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 1143 | 1143 | </span> |
| 1144 | 1144 | <?php } ?> |
| 1145 | 1145 | |
| 1146 | 1146 | <!-- Description Above --> |
| 1147 | 1147 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 1148 | 1148 | |
| 1149 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
| 1149 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
| 1150 | 1150 | |
| 1151 | 1151 | <?php |
| 1152 | - $no_default = $field['default_choice'] === 'no-default' || isset( $field['default_choice'][0] ) && $field['default_choice'][0] === 'no-default'; |
|
| 1152 | + $no_default = $field[ 'default_choice' ] === 'no-default' || isset( $field[ 'default_choice' ][ 0 ] ) && $field[ 'default_choice' ][ 0 ] === 'no-default'; |
|
| 1153 | 1153 | $no_default_name = apply_filters( 'yikes-mailchimp-dropdown-ig-no-default-option-name', __( 'Select...', 'yikes-inc-easy-mailchimp-extender' ), $form_id ); |
| 1154 | 1154 | echo $no_default === true ? '<option value="">' . $no_default_name . '</option>' : ''; |
| 1155 | 1155 | |
| 1156 | 1156 | $i = 0; |
| 1157 | - foreach( $groups as $group_id => $name ) { |
|
| 1157 | + foreach ( $groups as $group_id => $name ) { |
|
| 1158 | 1158 | |
| 1159 | 1159 | // If the form was submitted and failed, set the submitted/chosen values as the default |
| 1160 | - if( isset( $_POST[ 'group-' . $field['group_id'] ] ) && $form_submitted === 0 ) { |
|
| 1160 | + if ( isset( $_POST[ 'group-' . $field[ 'group_id' ] ] ) && $form_submitted === 0 ) { |
|
| 1161 | 1161 | |
| 1162 | 1162 | // Format default choice as array |
| 1163 | - $default_choice = ( is_array( $_POST[ 'group-' . $field['group_id'] ] ) ) ? $_POST[ 'group-' . $field['group_id'] ] : array( $_POST[ 'group-' . $field['group_id'] ] ); |
|
| 1163 | + $default_choice = ( is_array( $_POST[ 'group-' . $field[ 'group_id' ] ] ) ) ? $_POST[ 'group-' . $field[ 'group_id' ] ] : array( $_POST[ 'group-' . $field[ 'group_id' ] ] ); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | ?> |
| 1166 | 1166 | <option |
@@ -1188,12 +1188,12 @@ discard block |
||
| 1188 | 1188 | |
| 1189 | 1189 | ?> |
| 1190 | 1190 | |
| 1191 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 1191 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 1192 | 1192 | |
| 1193 | 1193 | <!-- dictate label visibility --> |
| 1194 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 1195 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?> checkbox-parent-label" style="display:none;"> |
|
| 1196 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['group_id'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 1194 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 1195 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?> checkbox-parent-label" style="display:none;"> |
|
| 1196 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 1197 | 1197 | </span> |
| 1198 | 1198 | <?php } |
| 1199 | 1199 | |
@@ -1203,17 +1203,17 @@ discard block |
||
| 1203 | 1203 | // Turn $default_choice into an array if it isn't already |
| 1204 | 1204 | $default_choice = ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice : array( $default_choice ); |
| 1205 | 1205 | |
| 1206 | - foreach( $groups as $group_id => $name ) { |
|
| 1206 | + foreach ( $groups as $group_id => $name ) { |
|
| 1207 | 1207 | ?> |
| 1208 | - <label for="<?php echo esc_attr( $field['group_id'] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ' , $custom_classes ); if ( $x === $count ) { echo ' last-selection'; } ?>" style="display:none;"> |
|
| 1208 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ', $custom_classes ); if ( $x === $count ) { echo ' last-selection'; } ?>" style="display:none;"> |
|
| 1209 | 1209 | <input |
| 1210 | 1210 | type="checkbox" |
| 1211 | - name="group-<?php echo esc_attr( $field['group_id'] ); ?>[]" |
|
| 1212 | - id="<?php echo esc_attr( $field['group_id'] ) . '-' . $i; ?>" |
|
| 1211 | + name="group-<?php echo esc_attr( $field[ 'group_id' ] ); ?>[]" |
|
| 1212 | + id="<?php echo esc_attr( $field[ 'group_id' ] ) . '-' . $i; ?>" |
|
| 1213 | 1213 | value="<?php echo esc_attr( $group_id ) ?>" |
| 1214 | 1214 | <?php if ( in_array( $group_id, $default_choice ) ) { echo 'checked="checked"'; } ?> |
| 1215 | 1215 | > |
| 1216 | - <?php echo esc_attr( stripslashes( str_replace( '' , '\'', $name ) ) ); ?> |
|
| 1216 | + <?php echo esc_attr( stripslashes( str_replace( '', '\'', $name ) ) ); ?> |
|
| 1217 | 1217 | </label> |
| 1218 | 1218 | <?php |
| 1219 | 1219 | $i++; |
@@ -1238,14 +1238,14 @@ discard block |
||
| 1238 | 1238 | echo $recaptcha_box; |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | - $admin_class = is_user_logged_in() && current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ? ' admin-logged-in' : ''; |
|
| 1241 | + $admin_class = is_user_logged_in() && current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ? ' admin-logged-in' : ''; |
|
| 1242 | 1242 | ?> |
| 1243 | 1243 | |
| 1244 | 1244 | <!-- Honeypot Trap --> |
| 1245 | 1245 | <input type="hidden" name="yikes-mailchimp-honeypot" id="yikes-mailchimp-honeypot-<?php echo esc_attr( $form_id ); ?>" value=""> |
| 1246 | 1246 | |
| 1247 | 1247 | <!-- List ID --> |
| 1248 | - <input type="hidden" name="yikes-mailchimp-associated-list-id" id="yikes-mailchimp-associated-list-id-<?php echo esc_attr( $form_id ); ?>" value="<?php echo esc_attr( $form_data['list_id'] ); ?>"> |
|
| 1248 | + <input type="hidden" name="yikes-mailchimp-associated-list-id" id="yikes-mailchimp-associated-list-id-<?php echo esc_attr( $form_id ); ?>" value="<?php echo esc_attr( $form_data[ 'list_id' ] ); ?>"> |
|
| 1249 | 1249 | |
| 1250 | 1250 | <!-- The form that is being submitted! Used to display error/success messages above the correct form --> |
| 1251 | 1251 | <input type="hidden" name="yikes-mailchimp-submitted-form" id="yikes-mailchimp-submitted-form-<?php echo esc_attr( $form_id ); ?>" value="<?php echo esc_attr( $form_id ); ?>"> |
@@ -1259,15 +1259,15 @@ discard block |
||
| 1259 | 1259 | // If the number of fields, is equal to the hidden label count, add our class |
| 1260 | 1260 | // eg: All field labels are set to hidden. |
| 1261 | 1261 | if ( absint( $field_count ) === absint( $hidden_label_count ) ) { |
| 1262 | - $submit_button_label_classes[] = 'labels-hidden'; |
|
| 1262 | + $submit_button_label_classes[ ] = 'labels-hidden'; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | echo '<label class="empty-form-inline-label submit-button-inline-label"><span class="' . implode( ' ', $submit_button_label_classes ) . '"> </span>'; |
| 1265 | 1265 | } |
| 1266 | 1266 | // Display the image or text based button. |
| 1267 | 1267 | if ( $submit_button_type === 'text' ) { |
| 1268 | - 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'] ) . '"> <span class="yikes-mailchimp-submit-button-span-text">' . apply_filters( 'yikes-mailchimp-form-submit-button-text', esc_attr( stripslashes( $submit ) ), $form_data['id'] ) . '</span></button>', $form_data['id'] ); |
|
| 1268 | + 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' ] ) . '"> <span class="yikes-mailchimp-submit-button-span-text">' . apply_filters( 'yikes-mailchimp-form-submit-button-text', esc_attr( stripslashes( $submit ) ), $form_data[ 'id' ] ) . '</span></button>', $form_data[ 'id' ] ); |
|
| 1269 | 1269 | } else { |
| 1270 | - 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'] ); |
|
| 1270 | + 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' ] ); |
|
| 1271 | 1271 | } |
| 1272 | 1272 | if ( $form_inline && ! $inline_form_override ) { |
| 1273 | 1273 | echo '</label>'; |
@@ -1282,8 +1282,8 @@ discard block |
||
| 1282 | 1282 | |
| 1283 | 1283 | <?php |
| 1284 | 1284 | /* If the current user is logged in, and an admin...lets display our 'Edit Form' link */ |
| 1285 | - if( is_user_logged_in() ) { |
|
| 1286 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
| 1285 | + if ( is_user_logged_in() ) { |
|
| 1286 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
| 1287 | 1287 | echo $edit_form_link; |
| 1288 | 1288 | } |
| 1289 | 1289 | } |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | * for non-admins |
| 1300 | 1300 | */ |
| 1301 | 1301 | if ( ! current_user_can( 'manage_options' ) ) { |
| 1302 | - $impressions = $form_data['impressions'] + 1; |
|
| 1302 | + $impressions = $form_data[ 'impressions' ] + 1; |
|
| 1303 | 1303 | $interface->update_form_field( $form_id, 'impressions', $impressions ); |
| 1304 | 1304 | } |
| 1305 | 1305 | |