@@ -6,13 +6,13 @@ discard block |
||
| 6 | 6 | $all_forms = $form_interface->get_all_forms(); |
| 7 | 7 | |
| 8 | 8 | /* Store Data if User is Authorized */ |
| 9 | -if( $this->is_user_mc_api_valid_form( false ) == 'valid' ) { |
|
| 9 | +if ( $this->is_user_mc_api_valid_form( false ) == 'valid' ) { |
|
| 10 | 10 | $list_data = yikes_get_mc_api_manager()->get_list_handler()->get_lists(); |
| 11 | 11 | if ( is_wp_error( $list_data ) ) { |
| 12 | 12 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 13 | 13 | $error_logging->maybe_write_to_log( |
| 14 | 14 | $list_data->get_error_code(), |
| 15 | - __( "Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), |
|
| 15 | + __( "Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 16 | 16 | "Manage Forms Page" |
| 17 | 17 | ); |
| 18 | 18 | $list_data = array(); |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | ?> |
| 24 | 24 | <div class="wrap"> |
| 25 | 25 | <!-- Freddie Logo --> |
| 26 | - <img src="<?php echo YIKES_MC_URL . 'includes/images/MailChimp_Assets/Freddie_60px.png'; ?>" alt="<?php _e( 'Freddie - MailChimp Mascot' , 'yikes-inc-easy-mailchimp-extender' ); ?>" class="yikes-mc-freddie-logo" /> |
|
| 26 | + <img src="<?php echo YIKES_MC_URL . 'includes/images/MailChimp_Assets/Freddie_60px.png'; ?>" alt="<?php _e( 'Freddie - MailChimp Mascot', 'yikes-inc-easy-mailchimp-extender' ); ?>" class="yikes-mc-freddie-logo" /> |
|
| 27 | 27 | |
| 28 | - <h1>Easy Forms for MailChimp | <?php _e( 'Manage Forms' , 'yikes-inc-easy-mailchimp-extender' ) ?></h1> |
|
| 28 | + <h1>Easy Forms for MailChimp | <?php _e( 'Manage Forms', 'yikes-inc-easy-mailchimp-extender' ) ?></h1> |
|
| 29 | 29 | |
| 30 | 30 | <!-- Settings Page Description --> |
| 31 | - <p class="yikes-easy-mc-about-text about-text"><?php _e( 'Create and manage your MailChimp forms.' , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 31 | + <p class="yikes-easy-mc-about-text about-text"><?php _e( 'Create and manage your MailChimp forms.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 32 | 32 | |
| 33 | 33 | <!-- Action Notices --> |
| 34 | 34 | <?php |
| 35 | 35 | |
| 36 | 36 | /* If the user hasn't authenticated yet, lets kill off */ |
| 37 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) != 'valid_api_key' ) { |
|
| 38 | - wp_die( '<div class="error"><p>' . sprintf( __( 'You need to connect to MailChimp before you can start creating forms. Head over to the <a href="%s" title="Settings Page">Settings Page</a> and enter your API key.' , 'yikes-inc-easy-mailchimp-extender' ), esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings' ) ) ) . '</p></div>' , 500 ); |
|
| 37 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) != 'valid_api_key' ) { |
|
| 38 | + wp_die( '<div class="error"><p>' . sprintf( __( 'You need to connect to MailChimp before you can start creating forms. Head over to the <a href="%s" title="Settings Page">Settings Page</a> and enter your API key.', 'yikes-inc-easy-mailchimp-extender' ), esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp-settings' ) ) ) . '</p></div>', 500 ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /* Display our admin notices here */ |
| 42 | 42 | // delete form success |
| 43 | - if( isset( $_REQUEST['deleted-form'] ) && $_REQUEST['deleted-form'] == 'true' ) { |
|
| 43 | + if ( isset( $_REQUEST[ 'deleted-form' ] ) && $_REQUEST[ 'deleted-form' ] == 'true' ) { |
|
| 44 | 44 | ?> |
| 45 | 45 | <div class="updated manage-form-admin-notice"> |
| 46 | 46 | <p><?php _e( 'Opt-in form successfully deleted.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | <?php |
| 49 | 49 | } |
| 50 | 50 | // duplicate form success |
| 51 | - if( isset( $_REQUEST['duplicated-form'] ) && $_REQUEST['duplicated-form'] == 'true' ) { |
|
| 51 | + if ( isset( $_REQUEST[ 'duplicated-form' ] ) && $_REQUEST[ 'duplicated-form' ] == 'true' ) { |
|
| 52 | 52 | ?> |
| 53 | 53 | <div class="updated manage-form-admin-notice"> |
| 54 | 54 | <p><?php _e( 'MailChimp Form successfully cloned.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | <?php |
| 57 | 57 | } |
| 58 | 58 | // duplicate form error |
| 59 | - if( isset( $_REQUEST['duplicated-form'] ) && $_REQUEST['duplicated-form'] == 'false' ) { |
|
| 59 | + if ( isset( $_REQUEST[ 'duplicated-form' ] ) && $_REQUEST[ 'duplicated-form' ] == 'false' ) { |
|
| 60 | 60 | ?> |
| 61 | 61 | <div class="error manage-form-admin-notice"> |
| 62 | 62 | <p><?php _e( 'There was an error trying to clone your form. Please try again. If this error persists, please contact the YIKES Inc. support team.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | <?php |
| 65 | 65 | } |
| 66 | 66 | // reset form submission stats success |
| 67 | - if( isset( $_REQUEST['reset-stats'] ) && $_REQUEST['reset-stats'] == 'true' ) { |
|
| 67 | + if ( isset( $_REQUEST[ 'reset-stats' ] ) && $_REQUEST[ 'reset-stats' ] == 'true' ) { |
|
| 68 | 68 | ?> |
| 69 | 69 | <div class="updated manage-form-admin-notice"> |
| 70 | 70 | <p><?php _e( 'Form submission stats/rates successfully reset.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | <?php |
| 73 | 73 | } |
| 74 | 74 | // reset form submission stats error |
| 75 | - if( isset( $_REQUEST['reset-stats'] ) && $_REQUEST['reset-stats'] == 'false' ) { |
|
| 75 | + if ( isset( $_REQUEST[ 'reset-stats' ] ) && $_REQUEST[ 'reset-stats' ] == 'false' ) { |
|
| 76 | 76 | ?> |
| 77 | 77 | <div class="error manage-form-admin-notice"> |
| 78 | 78 | <p><?php _e( 'There was an error trying to reset the form submission stats/rates. Please try again. If this error persists, please contact the YIKES Inc. support team.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | <thead> |
| 100 | 100 | <tr> |
| 101 | 101 | <th id="cb" class="manage-column column-cb check-column num" scope="col"><input type="checkbox" /></th> |
| 102 | - <th id="columnname" class="manage-column column-columnname num yikes-form-id-number" scope="col"><?php _e( 'ID' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 103 | - <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 104 | - <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Description' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 105 | - <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'List' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 106 | - <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Impressions' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 107 | - <th id="columnname" class="manage-column column-columnname num" scope="col" ><?php _e( 'Submissions' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 108 | - <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Conversion Rate' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 102 | + <th id="columnname" class="manage-column column-columnname num yikes-form-id-number" scope="col"><?php _e( 'ID', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 103 | + <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Name', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 104 | + <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Description', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 105 | + <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'List', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 106 | + <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Impressions', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 107 | + <th id="columnname" class="manage-column column-columnname num" scope="col" ><?php _e( 'Submissions', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 108 | + <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Conversion Rate', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 109 | 109 | </tr> |
| 110 | 110 | </thead> |
| 111 | 111 | <!-- end header --> |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | <tfoot> |
| 115 | 115 | <tr> |
| 116 | 116 | <th class="manage-column column-cb check-column num" scope="col"><input type="checkbox" /></th> |
| 117 | - <th id="columnname" class="manage-column column-columnname num yikes-form-id-number" scope="col"><?php _e( 'ID' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 118 | - <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 119 | - <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Description' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 120 | - <th class="manage-column column-columnname" scope="col"><?php _e( 'List' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 121 | - <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Impressions' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 122 | - <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Submissions' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 123 | - <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Conversion Rate' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 117 | + <th id="columnname" class="manage-column column-columnname num yikes-form-id-number" scope="col"><?php _e( 'ID', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 118 | + <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Name', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 119 | + <th id="columnname" class="manage-column column-columnname" scope="col"><?php _e( 'Form Description', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 120 | + <th class="manage-column column-columnname" scope="col"><?php _e( 'List', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 121 | + <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Impressions', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 122 | + <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Submissions', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 123 | + <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Conversion Rate', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 124 | 124 | </tr> |
| 125 | 125 | </tfoot> |
| 126 | 126 | <!-- end footer --> |
@@ -130,40 +130,40 @@ discard block |
||
| 130 | 130 | <?php |
| 131 | 131 | if ( count( $all_forms ) > 0 ) { |
| 132 | 132 | $i = 1; |
| 133 | - foreach( $all_forms as $id => $form ) { |
|
| 133 | + foreach ( $all_forms as $id => $form ) { |
|
| 134 | 134 | ?> |
| 135 | - <tr class="<?php if( $i % 2 == 0 ) { echo 'alternate'; } ?>"> |
|
| 135 | + <tr class="<?php if ( $i % 2 == 0 ) { echo 'alternate'; } ?>"> |
|
| 136 | 136 | <th class="check-column num" scope="row"><input type="checkbox" /></th> |
| 137 | 137 | <td class="column-columnname num"><span class="form-id-container"><?php echo intval( $id ); ?></span></td> |
| 138 | 138 | <td class="column-columnname"> |
| 139 | 139 | <!-- row title/link --> |
| 140 | - <a href="<?php echo esc_url_raw( add_query_arg( array( 'id' => $id ) , admin_url( 'admin.php?page=yikes-mailchimp-edit-form' ) ) ); ?>" class="row-title"> |
|
| 141 | - <?php echo stripslashes( $form['form_name'] ); ?> |
|
| 140 | + <a href="<?php echo esc_url_raw( add_query_arg( array( 'id' => $id ), admin_url( 'admin.php?page=yikes-mailchimp-edit-form' ) ) ); ?>" class="row-title"> |
|
| 141 | + <?php echo stripslashes( $form[ 'form_name' ] ); ?> |
|
| 142 | 142 | </a> |
| 143 | 143 | <div class="row-actions"> |
| 144 | - <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'id' => $id ) , admin_url( 'admin.php?page=yikes-mailchimp-edit-form' ) ) ); ?>"><?php _e( "Edit" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 145 | - <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-duplicate-form', 'mailchimp-form' => $id , 'nonce' => wp_create_nonce( 'duplicate-mailchimp-form-'.$id ) ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ) ); ?>"><?php _e( "Duplicate" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 146 | - <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-reset-stats', 'mailchimp-form' => $id , 'nonce' => wp_create_nonce( 'reset-stats-mailchimp-form-'.$id ) ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ) ); ?>"><?php _e( "Reset Stats" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 147 | - <span><a href="#" class="view-yikes-mc-form-shortcode" data-alt-text="<?php _e( 'Stats' , 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( "Shortcode" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 144 | + <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'id' => $id ), admin_url( 'admin.php?page=yikes-mailchimp-edit-form' ) ) ); ?>"><?php _e( "Edit", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 145 | + <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-duplicate-form', 'mailchimp-form' => $id, 'nonce' => wp_create_nonce( 'duplicate-mailchimp-form-' . $id ) ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ) ); ?>"><?php _e( "Duplicate", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 146 | + <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-reset-stats', 'mailchimp-form' => $id, 'nonce' => wp_create_nonce( 'reset-stats-mailchimp-form-' . $id ) ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ) ); ?>"><?php _e( "Reset Stats", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 147 | + <span><a href="#" class="view-yikes-mc-form-shortcode" data-alt-text="<?php _e( 'Stats', 'yikes-inc-easy-mailchimp-extender' ); ?>"><?php _e( "Shortcode", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 148 | 148 | <?php |
| 149 | 149 | /* |
| 150 | 150 | * Custom action to allow users to add additional action links |
| 151 | 151 | * to each form. We use this in our add-ons. |
| 152 | 152 | * - Delete should remain last |
| 153 | 153 | */ |
| 154 | - do_action( 'yikes-mailchimp-custom-form-actions' , $id ); |
|
| 154 | + do_action( 'yikes-mailchimp-custom-form-actions', $id ); |
|
| 155 | 155 | ?> |
| 156 | - <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-delete-form', 'mailchimp-form' => $id , 'nonce' => wp_create_nonce( 'delete-mailchimp-form-'.$id ) ) , admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ) ); ?>" class="yikes-delete-mailchimp-form" onclick="return confirm('<?php printf( __( 'Are you sure you want to delete the %s form? This cannot be undone.' , 'yikes-inc-easy-mailchimp-extender' ), stripslashes( $form['form_name'] ) ); ?>');"><?php _e( "Delete" , 'yikes-inc-easy-mailchimp-extender' ); ?></a></span> |
|
| 156 | + <span><a href="<?php echo esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-delete-form', 'mailchimp-form' => $id, 'nonce' => wp_create_nonce( 'delete-mailchimp-form-' . $id ) ), admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ) ); ?>" class="yikes-delete-mailchimp-form" onclick="return confirm('<?php printf( __( 'Are you sure you want to delete the %s form? This cannot be undone.', 'yikes-inc-easy-mailchimp-extender' ), stripslashes( $form[ 'form_name' ] ) ); ?>');"><?php _e( "Delete", 'yikes-inc-easy-mailchimp-extender' ); ?></a></span> |
|
| 157 | 157 | </div> |
| 158 | 158 | </td> |
| 159 | 159 | |
| 160 | - <td class="column-columnname"><?php echo isset( $form['form_description'] ) ? str_replace( '[yikes-mailchimp-subscriber-count]', do_shortcode( '[yikes-mailchimp-subscriber-count form="' . $id . '"]' ), $form['form_description'] ) : ''; ?></td> |
|
| 160 | + <td class="column-columnname"><?php echo isset( $form[ 'form_description' ] ) ? str_replace( '[yikes-mailchimp-subscriber-count]', do_shortcode( '[yikes-mailchimp-subscriber-count form="' . $id . '"]' ), $form[ 'form_description' ] ) : ''; ?></td> |
|
| 161 | 161 | <td class="column-columnname"> |
| 162 | 162 | <?php |
| 163 | 163 | if ( $list_data && count( $list_data ) > 0 ) { |
| 164 | 164 | $parsed = wp_list_pluck( $list_data, 'name', 'id' ); |
| 165 | - if ( isset( $parsed[ $form['list_id'] ] ) ) { |
|
| 166 | - echo esc_textarea( $parsed[ $form['list_id'] ] ); |
|
| 165 | + if ( isset( $parsed[ $form[ 'list_id' ] ] ) ) { |
|
| 166 | + echo esc_textarea( $parsed[ $form[ 'list_id' ] ] ); |
|
| 167 | 167 | } else { |
| 168 | 168 | echo '<strong>' . __( 'List Not Found', 'yikes-inc-easy-mailchimp-extender' ) . '</strong>'; |
| 169 | 169 | } |
@@ -172,25 +172,25 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | <td class="column-columnname num stat-container"> |
| 174 | 174 | <?php |
| 175 | - $impressions = number_format( $form['impressions'] ); |
|
| 176 | - echo '<span title="' . __( 'Impressions' , 'yikes-inc-easy-mailchimp-extender' ) . '">' . $impressions . '</span>'; |
|
| 175 | + $impressions = number_format( $form[ 'impressions' ] ); |
|
| 176 | + echo '<span title="' . __( 'Impressions', 'yikes-inc-easy-mailchimp-extender' ) . '">' . $impressions . '</span>'; |
|
| 177 | 177 | ?> |
| 178 | 178 | </td> |
| 179 | 179 | <td class="column-columnname num stat-container"> |
| 180 | 180 | <?php |
| 181 | - $submissions = number_format( $form['submissions'] ); |
|
| 182 | - echo '<span title="' . __( 'Submissions' , 'yikes-inc-easy-mailchimp-extender' ) . '">' . $submissions . '</span>'; |
|
| 181 | + $submissions = number_format( $form[ 'submissions' ] ); |
|
| 182 | + echo '<span title="' . __( 'Submissions', 'yikes-inc-easy-mailchimp-extender' ) . '">' . $submissions . '</span>'; |
|
| 183 | 183 | ?> |
| 184 | 184 | </td> |
| 185 | 185 | <td class="column-columnname num stat-container"> |
| 186 | 186 | <?php |
| 187 | - if( $impressions != 0 ) { |
|
| 188 | - $conversion_rate = ( round( 100 * $form['submissions'] / $form['impressions'] , 3 ) ); |
|
| 189 | - if( $conversion_rate >= '15' ) { |
|
| 187 | + if ( $impressions != 0 ) { |
|
| 188 | + $conversion_rate = ( round( 100 * $form[ 'submissions' ] / $form[ 'impressions' ], 3 ) ); |
|
| 189 | + if ( $conversion_rate >= '15' ) { |
|
| 190 | 190 | $conversion_color = '#00cc00'; // green (unicorn!) |
| 191 | - } else if( $conversion_rate < '15' && $conversion_rate >= '10' ) { |
|
| 191 | + } else if ( $conversion_rate < '15' && $conversion_rate >= '10' ) { |
|
| 192 | 192 | $conversion_color = '#0080FF'; // light blue (good) |
| 193 | - } else if( $conversion_rate < '10' && $conversion_rate >= '5' ) { |
|
| 193 | + } else if ( $conversion_rate < '10' && $conversion_rate >= '5' ) { |
|
| 194 | 194 | $conversion_color = '#FFFF32'; // yellow (ok) |
| 195 | 195 | } else { |
| 196 | 196 | $conversion_color = '#FF0000'; // red (no bueno) |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $conversion_rate = '0'; |
| 200 | 200 | $conversion_color = '#333333'; |
| 201 | 201 | } |
| 202 | - echo '<span style="color:' . esc_attr( $conversion_color ) . ';" title="' . esc_attr__( 'Conversion Rate' , 'yikes-inc-easy-mailchimp-extender' ) . '">' . $conversion_rate . '%</span>'; |
|
| 202 | + echo '<span style="color:' . esc_attr( $conversion_color ) . ';" title="' . esc_attr__( 'Conversion Rate', 'yikes-inc-easy-mailchimp-extender' ) . '">' . $conversion_rate . '%</span>'; |
|
| 203 | 203 | ?> |
| 204 | 204 | </td> |
| 205 | 205 | <!-- shortcode --> |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | } else { ?> |
| 214 | 214 | <tr class="no-items"> |
| 215 | - <td class="colspanchange no-mailchimp-forms-found" colspan="8"><em><?php _e( 'No MailChimp forms found. Use the form to the right to create a new one.' , 'yikes-inc-easy-mailchimp-extender' ); ?></em></td> |
|
| 215 | + <td class="colspanchange no-mailchimp-forms-found" colspan="8"><em><?php _e( 'No MailChimp forms found. Use the form to the right to create a new one.', 'yikes-inc-easy-mailchimp-extender' ); ?></em></td> |
|
| 216 | 216 | </tr> |
| 217 | 217 | <?php } ?> |
| 218 | 218 | </tbody> |
@@ -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 { |
@@ -301,17 +301,17 @@ discard block |
||
| 301 | 301 | * Set a custom title using custom_title="lorem ipsum" parameter in the shortcode |
| 302 | 302 | * - This takes precedence over the title set |
| 303 | 303 | */ |
| 304 | - if ( $atts['title'] ) { |
|
| 305 | - if ( ! empty( $atts['custom_title'] ) ) { |
|
| 304 | + if ( $atts[ 'title' ] ) { |
|
| 305 | + if ( ! empty( $atts[ 'custom_title' ] ) ) { |
|
| 306 | 306 | /** |
| 307 | 307 | * Filter the title that is displayed through the shortcode. |
| 308 | 308 | * |
| 309 | 309 | * @param string $title The title to display. |
| 310 | 310 | * @param int $form_id The form ID. |
| 311 | 311 | */ |
| 312 | - $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $atts['custom_title'] ), $form_id ); |
|
| 312 | + $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $atts[ 'custom_title' ] ), $form_id ); |
|
| 313 | 313 | } else { |
| 314 | - $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_data['form_name'] ), $form_id ); |
|
| 314 | + $title = apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_data[ 'form_name' ] ), $form_id ); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | echo sprintf( '<h3 class="yikes-mailchimp-form-title yikes-mailchimp-form-title-%1$s">%2$s</h3>', $form_id, $title ); |
@@ -321,17 +321,17 @@ discard block |
||
| 321 | 321 | * Allow users to specify a custom description for this form, no html support |
| 322 | 322 | * @since 6.0.3.8 |
| 323 | 323 | */ |
| 324 | - if ( $atts['description'] ) { |
|
| 325 | - if ( ! empty( $atts['custom_description'] ) ) { |
|
| 324 | + if ( $atts[ 'description' ] ) { |
|
| 325 | + if ( ! empty( $atts[ 'custom_description' ] ) ) { |
|
| 326 | 326 | /** |
| 327 | 327 | * Filter the description that is displayed through the shortcode. |
| 328 | 328 | * |
| 329 | 329 | * @param string $title The title to display. |
| 330 | 330 | * @param int $form_id The form ID. |
| 331 | 331 | */ |
| 332 | - $description = apply_filters( 'yikes-mailchimp-form-description', $atts['custom_description'], $form_id ); |
|
| 332 | + $description = apply_filters( 'yikes-mailchimp-form-description', $atts[ 'custom_description' ], $form_id ); |
|
| 333 | 333 | } else { |
| 334 | - $description = apply_filters( 'yikes-mailchimp-form-description', $form_data['form_description'], $form_id ); |
|
| 334 | + $description = apply_filters( 'yikes-mailchimp-form-description', $form_data[ 'form_description' ], $form_id ); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | echo sprintf( '<section class="yikes-mailchimp-form-description yikes-mailchimp-form-description-%1$s">%2$s</section>', $form_id, $description ); |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 347 | 347 | |
| 348 | 348 | // Check for AJAX |
| 349 | - if( ( ! empty( $atts['ajax'] ) && $atts['ajax'] == 1 ) || $form_data['submission_settings']['ajax'] == 1 ) { |
|
| 349 | + if ( ( ! empty( $atts[ 'ajax' ] ) && $atts[ 'ajax' ] == 1 ) || $form_data[ 'submission_settings' ][ 'ajax' ] == 1 ) { |
|
| 350 | 350 | |
| 351 | 351 | // Enqueue our ajax script |
| 352 | - wp_enqueue_script( 'yikes-easy-mc-ajax' , YIKES_MC_URL . "public/js/yikes-mc-ajax-forms{$min}.js" , array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 352 | + wp_enqueue_script( 'yikes-easy-mc-ajax', YIKES_MC_URL . "public/js/yikes-mc-ajax-forms{$min}.js", array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 353 | 353 | wp_localize_script( 'yikes-easy-mc-ajax', 'yikes_mailchimp_ajax', array( |
| 354 | 354 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 355 | 355 | 'page_data' => $page_data, |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // Generic JavaScript functions for interacting with the form |
| 364 | - wp_enqueue_script( 'form-submission-helpers', YIKES_MC_URL . "public/js/form-submission-helpers{$min}.js" , array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 364 | + wp_enqueue_script( 'form-submission-helpers', YIKES_MC_URL . "public/js/form-submission-helpers{$min}.js", array( 'jquery' ), YIKES_MC_VERSION, false ); |
|
| 365 | 365 | wp_localize_script( 'form-submission-helpers', 'form_submission_helpers', array( |
| 366 | 366 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 367 | 367 | 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) ), |
@@ -380,67 +380,67 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | // render the form! |
| 382 | 382 | ?> |
| 383 | - <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 ); ?>"> |
|
| 383 | + <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 ); ?>"> |
|
| 384 | 384 | |
| 385 | 385 | <?php |
| 386 | 386 | // Set a default constant for hidden fields |
| 387 | 387 | $hidden_label_count = 0; |
| 388 | 388 | |
| 389 | 389 | // Loop over our form fields |
| 390 | - foreach( $form_data['fields'] as $field ) { |
|
| 390 | + foreach ( $form_data[ 'fields' ] as $field ) { |
|
| 391 | 391 | // input array |
| 392 | 392 | $field_array = array(); |
| 393 | 393 | // label array |
| 394 | 394 | $label_array = array(); |
| 395 | 395 | // label classes array |
| 396 | 396 | $label_class_array = array(); |
| 397 | - if( $field['additional-classes'] != '' ) { |
|
| 397 | + if ( $field[ 'additional-classes' ] != '' ) { |
|
| 398 | 398 | // split custom classes at spaces |
| 399 | - $custom_classes = explode( ' ' , $field['additional-classes'] ); |
|
| 399 | + $custom_classes = explode( ' ', $field[ 'additional-classes' ] ); |
|
| 400 | 400 | // check our custom class array for field-left/field-right |
| 401 | 401 | // if it's set we need to assign it to our label and remove it from the field classes |
| 402 | 402 | // input half left |
| 403 | - if( in_array( 'field-left-half' , $custom_classes ) ) { |
|
| 403 | + if ( in_array( 'field-left-half', $custom_classes ) ) { |
|
| 404 | 404 | // $label_array['class'] = 'class="field-left-half"'; |
| 405 | - $label_class_array[] = 'field-left-half'; |
|
| 406 | - $key = array_search( 'field-left-half' , $custom_classes ); |
|
| 407 | - unset( $custom_classes[$key] ); |
|
| 405 | + $label_class_array[ ] = 'field-left-half'; |
|
| 406 | + $key = array_search( 'field-left-half', $custom_classes ); |
|
| 407 | + unset( $custom_classes[ $key ] ); |
|
| 408 | 408 | } // input half right |
| 409 | - if( in_array( 'field-right-half' , $custom_classes ) ) { |
|
| 409 | + if ( in_array( 'field-right-half', $custom_classes ) ) { |
|
| 410 | 410 | // $label_array['class'] = 'class="field-right-half"'; |
| 411 | - $label_class_array[] = 'field-right-half'; |
|
| 412 | - $key = array_search( 'field-right-half' , $custom_classes ); |
|
| 413 | - unset( $custom_classes[$key] ); |
|
| 411 | + $label_class_array[ ] = 'field-right-half'; |
|
| 412 | + $key = array_search( 'field-right-half', $custom_classes ); |
|
| 413 | + unset( $custom_classes[ $key ] ); |
|
| 414 | 414 | } // input thirds (1/3 width, floated left) |
| 415 | - if( in_array( 'field-third' , $custom_classes ) ) { |
|
| 415 | + if ( in_array( 'field-third', $custom_classes ) ) { |
|
| 416 | 416 | // $label_array['class'] = 'class="field-third"'; |
| 417 | - $label_class_array[] = 'field-third'; |
|
| 418 | - $key = array_search( 'field-third' , $custom_classes ); |
|
| 419 | - unset( $custom_classes[$key] ); |
|
| 417 | + $label_class_array[ ] = 'field-third'; |
|
| 418 | + $key = array_search( 'field-third', $custom_classes ); |
|
| 419 | + unset( $custom_classes[ $key ] ); |
|
| 420 | 420 | } // 2 column radio |
| 421 | - if( in_array( 'option-2-col' , $custom_classes ) ) { |
|
| 421 | + if ( in_array( 'option-2-col', $custom_classes ) ) { |
|
| 422 | 422 | // $label_array['class'] = 'class="option-2-col"'; |
| 423 | - $label_class_array[] = 'option-2-col'; |
|
| 424 | - $key = array_search( 'option-2-col' , $custom_classes ); |
|
| 425 | - unset( $custom_classes[$key] ); |
|
| 423 | + $label_class_array[ ] = 'option-2-col'; |
|
| 424 | + $key = array_search( 'option-2-col', $custom_classes ); |
|
| 425 | + unset( $custom_classes[ $key ] ); |
|
| 426 | 426 | } // 3 column radio |
| 427 | - if( in_array( 'option-3-col' , $custom_classes ) ) { |
|
| 427 | + if ( in_array( 'option-3-col', $custom_classes ) ) { |
|
| 428 | 428 | // $label_array['class'] = 'class="option-3-col"'; |
| 429 | - $label_class_array[] = 'option-3-col'; |
|
| 430 | - $key = array_search( 'option-3-col' , $custom_classes ); |
|
| 431 | - unset( $custom_classes[$key] ); |
|
| 429 | + $label_class_array[ ] = 'option-3-col'; |
|
| 430 | + $key = array_search( 'option-3-col', $custom_classes ); |
|
| 431 | + unset( $custom_classes[ $key ] ); |
|
| 432 | 432 | } // 4 column radio |
| 433 | - if( in_array( 'option-4-col' , $custom_classes ) ) { |
|
| 433 | + if ( in_array( 'option-4-col', $custom_classes ) ) { |
|
| 434 | 434 | // $label_array['class'] = 'class="option-4-col"'; |
| 435 | - $label_class_array[] = 'option-4-col'; |
|
| 436 | - $key = array_search( 'option-4-col' , $custom_classes ); |
|
| 437 | - unset( $custom_classes[$key] ); |
|
| 435 | + $label_class_array[ ] = 'option-4-col'; |
|
| 436 | + $key = array_search( 'option-4-col', $custom_classes ); |
|
| 437 | + unset( $custom_classes[ $key ] ); |
|
| 438 | 438 | } // inline radio & checkboxes etc |
| 439 | - if( in_array( 'option-inline' , $custom_classes ) ) { |
|
| 439 | + if ( in_array( 'option-inline', $custom_classes ) ) { |
|
| 440 | 440 | // $label_array['class'] = 'class="option-inline"'; |
| 441 | - $label_class_array[] = 'option-inline'; |
|
| 442 | - $key = array_search( 'option-inline' , $custom_classes ); |
|
| 443 | - unset( $custom_classes[$key] ); |
|
| 441 | + $label_class_array[ ] = 'option-inline'; |
|
| 442 | + $key = array_search( 'option-inline', $custom_classes ); |
|
| 443 | + unset( $custom_classes[ $key ] ); |
|
| 444 | 444 | } |
| 445 | 445 | } else { |
| 446 | 446 | $custom_classes = array(); |
@@ -448,19 +448,19 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | // if the form is set to inline, add the inline class to our labels |
| 450 | 450 | // since @6.0.3.8 |
| 451 | - if( $form_inline ) { |
|
| 452 | - $label_class_array[] = 'label-inline'; |
|
| 451 | + if ( $form_inline ) { |
|
| 452 | + $label_class_array[ ] = 'label-inline'; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if( isset( $field['hide-label'] ) ) { |
|
| 456 | - if( absint( $field['hide-label'] ) === 1 ) { |
|
| 455 | + if ( isset( $field[ 'hide-label' ] ) ) { |
|
| 456 | + if ( absint( $field[ 'hide-label' ] ) === 1 ) { |
|
| 457 | 457 | $hidden_label_count++; |
| 458 | - $custom_classes[] = 'field-no-label'; |
|
| 458 | + $custom_classes[ ] = 'field-no-label'; |
|
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /* Store tag variable based on field type */ |
| 463 | - if( isset( $field['merge'] ) ) { |
|
| 463 | + if ( isset( $field[ 'merge' ] ) ) { |
|
| 464 | 464 | $group = ''; |
| 465 | 465 | $tag = 'merge'; |
| 466 | 466 | } else { |
@@ -470,28 +470,28 @@ discard block |
||
| 470 | 470 | |
| 471 | 471 | // build up our array |
| 472 | 472 | $field_id_string = 'yikes-easy-mc-form-' . $form_id . '-' . $field[ $tag ]; |
| 473 | - $field_array['id'] = 'id="' . esc_attr( $field_id_string ) . '" '; |
|
| 474 | - $field_array['name'] = 'name="' . $group . esc_attr( $field[ $tag ] ) . '" '; |
|
| 475 | - $field_array['placeholder'] = isset( $field['placeholder'] ) ? 'placeholder="' . esc_attr( stripslashes( $field['placeholder'] ) ) . '" ' : ''; |
|
| 476 | - $field_array['classes'] = 'class="yikes-easy-mc-'.$field['type'] . ' ' . esc_attr( trim( implode( ' ' , $custom_classes ) ) ) . '" '; |
|
| 473 | + $field_array[ 'id' ] = 'id="' . esc_attr( $field_id_string ) . '" '; |
|
| 474 | + $field_array[ 'name' ] = 'name="' . $group . esc_attr( $field[ $tag ] ) . '" '; |
|
| 475 | + $field_array[ 'placeholder' ] = isset( $field[ 'placeholder' ] ) ? 'placeholder="' . esc_attr( stripslashes( $field[ 'placeholder' ] ) ) . '" ' : ''; |
|
| 476 | + $field_array[ 'classes' ] = 'class="yikes-easy-mc-' . $field[ 'type' ] . ' ' . esc_attr( trim( implode( ' ', $custom_classes ) ) ) . '" '; |
|
| 477 | 477 | |
| 478 | 478 | // email must always be required and visible |
| 479 | - if( $field['type'] == 'email' ) { |
|
| 480 | - $field_array['required'] = 'required="required"'; |
|
| 481 | - $label_array['visible'] = ''; |
|
| 482 | - $label_class_array[] = $field['merge'] . '-label'; |
|
| 483 | - $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 479 | + if ( $field[ 'type' ] == 'email' ) { |
|
| 480 | + $field_array[ 'required' ] = 'required="required"'; |
|
| 481 | + $label_array[ 'visible' ] = ''; |
|
| 482 | + $label_class_array[ ] = $field[ 'merge' ] . '-label'; |
|
| 483 | + $label_class_array[ ] = 'yikes-mailchimp-field-required'; |
|
| 484 | 484 | } else { |
| 485 | - $field_array['required'] = isset( $field['require'] ) ? 'required="required"' : ''; |
|
| 486 | - $label_array['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
| 487 | - $label_class_array[] = ( $tag === 'merge' ) ? $field['merge'] . '-label' : $field['group_id'] . '-label'; |
|
| 488 | - if ( isset( $field['require'] ) ) $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 485 | + $field_array[ 'required' ] = isset( $field[ 'require' ] ) ? 'required="required"' : ''; |
|
| 486 | + $label_array[ 'visible' ] = isset( $field[ 'hide' ] ) ? 'style="display:none;"' : ''; |
|
| 487 | + $label_class_array[ ] = ( $tag === 'merge' ) ? $field[ 'merge' ] . '-label' : $field[ 'group_id' ] . '-label'; |
|
| 488 | + if ( isset( $field[ 'require' ] ) ) $label_class_array[ ] = 'yikes-mailchimp-field-required'; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | // if both hide label and hide field are checked, we gotta hide the field! |
| 492 | - if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
| 493 | - if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
| 494 | - $field_array['visible'] = 'style="display:none;"'; |
|
| 492 | + if ( isset( $field[ 'hide' ] ) && $field[ 'hide' ] == 1 ) { |
|
| 493 | + if ( isset( $field[ 'hide-label' ] ) && $field[ 'hide-label' ] == 1 ) { |
|
| 494 | + $field_array[ 'visible' ] = 'style="display:none;"'; |
|
| 495 | 495 | } |
| 496 | 496 | } |
| 497 | 497 | |
@@ -499,20 +499,20 @@ discard block |
||
| 499 | 499 | $label_class_array = function_exists( 'sanitize_html_class' ) ? array_map( 'sanitize_html_class', $label_class_array ) : $label_class_array; |
| 500 | 500 | |
| 501 | 501 | // Turn the clases into a string |
| 502 | - $label_array['classes'] = 'class="' . implode( ' ', $label_class_array ) . ' "'; |
|
| 502 | + $label_array[ 'classes' ] = 'class="' . implode( ' ', $label_class_array ) . ' "'; |
|
| 503 | 503 | |
| 504 | 504 | // Filter the field array data |
| 505 | 505 | $field_array = apply_filters( 'yikes-mailchimp-field-data', $field_array, $field, $form_id ); |
| 506 | 506 | |
| 507 | 507 | /* Loop Over Standard Fields (aka merge variables) */ |
| 508 | - if( isset( $field['merge'] ) ) { |
|
| 508 | + if ( isset( $field[ 'merge' ] ) ) { |
|
| 509 | 509 | |
| 510 | 510 | // Handle the Description logic in one spot, here: |
| 511 | - $show_description = isset( $field['description'] ) && trim( $field['description'] ) !== '' ? true : false; |
|
| 512 | - $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 511 | + $show_description = isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) !== '' ? true : false; |
|
| 512 | + $description_above = isset( $field[ 'description_above' ] ) && $field[ 'description_above' ] === '1' ? true : false; |
|
| 513 | 513 | if ( $show_description === true ) { |
| 514 | - $description = '<p class="form-field-description" id="form-field-description-' . $field['merge'] . '">'; |
|
| 515 | - $description .= apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 514 | + $description = '<p class="form-field-description" id="form-field-description-' . $field[ 'merge' ] . '">'; |
|
| 515 | + $description .= apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 516 | 516 | $description .= '</p>'; |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -524,11 +524,11 @@ discard block |
||
| 524 | 524 | * @param string | $field['description'] | The field's description text |
| 525 | 525 | * @param int | $form_id |
| 526 | 526 | */ |
| 527 | - $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description-html', $description, esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 527 | + $description = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description-html', $description, esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | // loop over our fields by Type |
| 531 | - switch ( $field['type'] ) { |
|
| 531 | + switch ( $field[ 'type' ] ) { |
|
| 532 | 532 | |
| 533 | 533 | default: |
| 534 | 534 | case 'email': |
@@ -536,24 +536,24 @@ discard block |
||
| 536 | 536 | case 'number': |
| 537 | 537 | |
| 538 | 538 | // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
| 539 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 539 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 540 | 540 | $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
| 541 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 541 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 542 | 542 | |
| 543 | 543 | ?> |
| 544 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 544 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 545 | 545 | |
| 546 | 546 | <!-- dictate label visibility --> |
| 547 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 548 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 549 | - <?php if( ! isset( $field['hide-label'] ) ) { echo apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label' , esc_attr( stripslashes( $field['label'] ) ), $form_id ); } ?> |
|
| 547 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 548 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 549 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ), $form_id ); } ?> |
|
| 550 | 550 | </span> |
| 551 | 551 | <?php } ?> |
| 552 | 552 | |
| 553 | 553 | <!-- Description Above --> |
| 554 | 554 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 555 | 555 | |
| 556 | - <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 ); } ?>"> |
|
| 556 | + <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 ); } ?>"> |
|
| 557 | 557 | |
| 558 | 558 | <!-- Description Below --> |
| 559 | 559 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -565,23 +565,23 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | case 'url': |
| 567 | 567 | case 'imageurl': |
| 568 | - $default_value = ( isset( $field['default'] ) ) ? $field['default'] : ''; |
|
| 569 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 568 | + $default_value = ( isset( $field[ 'default' ] ) ) ? $field[ 'default' ] : ''; |
|
| 569 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 570 | 570 | ?> |
| 571 | 571 | |
| 572 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 572 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 573 | 573 | |
| 574 | 574 | <!-- dictate label visibility --> |
| 575 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 576 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 577 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 575 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 576 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 577 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 578 | 578 | </span> |
| 579 | 579 | <?php } ?> |
| 580 | 580 | |
| 581 | 581 | <!-- Description Above --> |
| 582 | 582 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 583 | 583 | |
| 584 | - <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 ); } ?>" > |
|
| 584 | + <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 ); } ?>" > |
|
| 585 | 585 | |
| 586 | 586 | <!-- Description Below --> |
| 587 | 587 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -592,24 +592,24 @@ discard block |
||
| 592 | 592 | break; |
| 593 | 593 | |
| 594 | 594 | case 'phone': |
| 595 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 596 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 597 | - $phone_format = $field['phone_format']; |
|
| 595 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 596 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 597 | + $phone_format = $field[ 'phone_format' ]; |
|
| 598 | 598 | ?> |
| 599 | 599 | |
| 600 | - <label for="<?php echo esc_attr( $field_id_string ) ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 600 | + <label for="<?php echo esc_attr( $field_id_string ) ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 601 | 601 | |
| 602 | 602 | <!-- dictate label visibility --> |
| 603 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 604 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 605 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 603 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 604 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 605 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 606 | 606 | </span> |
| 607 | 607 | <?php } ?> |
| 608 | 608 | |
| 609 | 609 | <!-- Description Above --> |
| 610 | 610 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 611 | 611 | |
| 612 | - <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 ); } ?>"> |
|
| 612 | + <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 ); } ?>"> |
|
| 613 | 613 | |
| 614 | 614 | <!-- Description Below --> |
| 615 | 615 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -619,23 +619,23 @@ discard block |
||
| 619 | 619 | break; |
| 620 | 620 | |
| 621 | 621 | case 'zip': |
| 622 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 623 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 622 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 623 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 624 | 624 | |
| 625 | 625 | ?> |
| 626 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 626 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 627 | 627 | |
| 628 | 628 | <!-- dictate label visibility --> |
| 629 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 630 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 631 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 629 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 630 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 631 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 632 | 632 | </span> |
| 633 | 633 | <?php } ?> |
| 634 | 634 | |
| 635 | 635 | <!-- Description Above --> |
| 636 | 636 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 637 | 637 | |
| 638 | - <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 ); } ?>"> |
|
| 638 | + <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 ); } ?>"> |
|
| 639 | 639 | |
| 640 | 640 | <!-- Description Below --> |
| 641 | 641 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | case 'address': |
| 649 | 649 | |
| 650 | 650 | // required fields |
| 651 | - $required_fields = array( 'addr1' => 'address' , 'addr2' => 'address 2', 'city' => 'city', 'state' =>'state', 'zip' =>'zip' , 'country' => 'country' ); |
|
| 651 | + $required_fields = array( 'addr1' => 'address', 'addr2' => 'address 2', 'city' => 'city', 'state' =>'state', 'zip' =>'zip', 'country' => 'country' ); |
|
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | 654 | * Filter to control the default country (the option pre-selected in the country dropdown). |
@@ -664,55 +664,55 @@ discard block |
||
| 664 | 664 | if ( $show_description === true && $description_above === true ) { echo $description; } |
| 665 | 665 | |
| 666 | 666 | // Placeholder logic |
| 667 | - if ( ! empty( $field_array['placeholder'] ) ) { |
|
| 667 | + if ( ! empty( $field_array[ 'placeholder' ] ) ) { |
|
| 668 | 668 | |
| 669 | 669 | $use_address_placeholder = true; |
| 670 | 670 | |
| 671 | 671 | // Don't use the address field's array placeholder - use the custom placeholder |
| 672 | - unset( $field_array['placeholder'] ); |
|
| 672 | + unset( $field_array[ 'placeholder' ] ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | // store number for looping |
| 676 | 676 | $x = 1; |
| 677 | - foreach( $required_fields as $type => $label ) { |
|
| 677 | + foreach ( $required_fields as $type => $label ) { |
|
| 678 | 678 | |
| 679 | 679 | // set the field names for the address fields |
| 680 | - $field_array['name'] = 'name="' . $field[$tag] . '[' . $type . ']' . '"'; |
|
| 680 | + $field_array[ 'name' ] = 'name="' . $field[ $tag ] . '[' . $type . ']' . '"'; |
|
| 681 | 681 | |
| 682 | 682 | // Set the placeholder value if we need to |
| 683 | 683 | $placeholder = isset( $use_address_placeholder ) ? apply_filters( 'yikes-mailchimp-address-' . $type . '-placeholder', ucwords( $label ) ) : ''; |
| 684 | 684 | |
| 685 | 685 | // reset the label classes for left-half/right-half for addresses |
| 686 | - if( isset( $label_array['class'] ) ) { |
|
| 686 | + if ( isset( $label_array[ 'class' ] ) ) { |
|
| 687 | 687 | if ( $x % 2 == 0 ) { |
| 688 | - $label_array['class'] = str_replace( 'field-left-half', 'field-right-half', $label_array['class'] ); |
|
| 688 | + $label_array[ 'class' ] = str_replace( 'field-left-half', 'field-right-half', $label_array[ 'class' ] ); |
|
| 689 | 689 | } else { |
| 690 | - $label_array['class'] = str_replace( 'field-right-half', 'field-left-half', $label_array['class'] ); |
|
| 690 | + $label_array[ 'class' ] = str_replace( 'field-right-half', 'field-left-half', $label_array[ 'class' ] ); |
|
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | // Never force addr2 to be required |
| 695 | 695 | if ( $type === 'addr2' ) { |
| 696 | - $field_array['required'] = apply_filters( 'yikes-mailchimp-address-2-required', '', $form_id ); |
|
| 696 | + $field_array[ 'required' ] = apply_filters( 'yikes-mailchimp-address-2-required', '', $form_id ); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - switch( $type ) { |
|
| 699 | + switch ( $type ) { |
|
| 700 | 700 | |
| 701 | 701 | default: |
| 702 | 702 | case 'addr1': |
| 703 | 703 | case 'addr2': |
| 704 | 704 | case 'city': |
| 705 | 705 | ?> |
| 706 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 706 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ', $label_array ); ?>> |
|
| 707 | 707 | |
| 708 | 708 | <!-- dictate label visibility --> |
| 709 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 710 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 711 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 709 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 710 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 711 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 712 | 712 | </span> |
| 713 | 713 | <?php } ?> |
| 714 | 714 | |
| 715 | - <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] ); } ?>"> |
|
| 715 | + <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 ] ); } ?>"> |
|
| 716 | 716 | |
| 717 | 717 | </label> |
| 718 | 718 | <?php |
@@ -721,16 +721,16 @@ discard block |
||
| 721 | 721 | |
| 722 | 722 | case 'state': |
| 723 | 723 | ?> |
| 724 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" <?php echo implode( ' ' , $label_array ); ?> data-attr-name="state-dropdown"> |
|
| 724 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" <?php echo implode( ' ', $label_array ); ?> data-attr-name="state-dropdown"> |
|
| 725 | 725 | |
| 726 | 726 | <!-- dictate label visibility --> |
| 727 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 728 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 729 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 727 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 728 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 729 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 730 | 730 | </span> |
| 731 | 731 | <?php } ?> |
| 732 | 732 | |
| 733 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
| 733 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
| 734 | 734 | <?php |
| 735 | 735 | $state_and_province_list = file_get_contents( YIKES_MC_PATH . 'public/partials/shortcodes/templates/state-and-province-dropdown.php' ); |
| 736 | 736 | /** |
@@ -756,21 +756,21 @@ discard block |
||
| 756 | 756 | case 'zip': |
| 757 | 757 | |
| 758 | 758 | ?> |
| 759 | - <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 } ?>> |
|
| 759 | + <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 } ?>> |
|
| 760 | 760 | |
| 761 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 762 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 763 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 761 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 762 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 763 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 764 | 764 | </span> |
| 765 | 765 | <?php } ?> |
| 766 | 766 | |
| 767 | 767 | <?php |
| 768 | 768 | // If zip lookup plugin is installed, the ZIP field comes back as an array and we need to handle it differently... |
| 769 | - if( isset( $_POST[$field['merge']] ) && $form_submitted != 1 ) { |
|
| 770 | - if ( is_array( $_POST[$field['merge']] ) && isset( $_POST[$field['merge']]['zip'] ) ) { |
|
| 771 | - $zip_value = $_POST[$field['merge']]['zip']; |
|
| 769 | + if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted != 1 ) { |
|
| 770 | + if ( is_array( $_POST[ $field[ 'merge' ] ] ) && isset( $_POST[ $field[ 'merge' ] ][ 'zip' ] ) ) { |
|
| 771 | + $zip_value = $_POST[ $field[ 'merge' ] ][ 'zip' ]; |
|
| 772 | 772 | } else { |
| 773 | - $zip_value = $_POST[$field['merge']]; |
|
| 773 | + $zip_value = $_POST[ $field[ 'merge' ] ]; |
|
| 774 | 774 | } |
| 775 | 775 | } else { |
| 776 | 776 | |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | } |
| 791 | 791 | ?> |
| 792 | 792 | |
| 793 | - <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 ); ?>"> |
|
| 793 | + <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 ); ?>"> |
|
| 794 | 794 | |
| 795 | 795 | </label> |
| 796 | 796 | <?php |
@@ -800,16 +800,16 @@ discard block |
||
| 800 | 800 | case 'country': |
| 801 | 801 | ?> |
| 802 | 802 | |
| 803 | - <label for="<?php echo esc_attr( $field['merge'] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 803 | + <label for="<?php echo esc_attr( $field[ 'merge' ] ); ?>" data-attr-name="<?php echo esc_attr( $type ); ?>-field" <?php echo implode( ' ', $label_array ); ?>> |
|
| 804 | 804 | |
| 805 | 805 | <!-- dictate label visibility --> |
| 806 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 807 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 808 | - <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label' , esc_attr( $label ), $form_id ) ); ?> |
|
| 806 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 807 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 808 | + <?php echo ucwords( apply_filters( 'yikes-mailchimp-address-' . $type . '-label', esc_attr( $label ), $form_id ) ); ?> |
|
| 809 | 809 | </span> |
| 810 | 810 | <?php } ?> |
| 811 | 811 | |
| 812 | - <select <?php echo implode( ' ' , $field_array ); ?> data-country="true"> |
|
| 812 | + <select <?php echo implode( ' ', $field_array ); ?> data-country="true"> |
|
| 813 | 813 | <?php include( YIKES_MC_PATH . 'public/partials/shortcodes/templates/country-dropdown.php' ); ?> |
| 814 | 814 | </select> |
| 815 | 815 | </label> |
@@ -855,40 +855,40 @@ discard block |
||
| 855 | 855 | wp_register_script( 'yikes-datepicker-scripts', YIKES_MC_URL . 'public/js/yikes-datepicker-scripts.min.js', array( 'jquery-ui-datepicker' ), YIKES_MC_VERSION, false ); |
| 856 | 856 | wp_localize_script( 'yikes-datepicker-scripts', 'datepicker_settings', $datepicker_options ); |
| 857 | 857 | wp_enqueue_script( 'yikes-datepicker-scripts' ); |
| 858 | - wp_enqueue_style( 'jquery-datepicker-styles' , YIKES_MC_URL . 'public/css/jquery-ui.min.css' ); |
|
| 859 | - wp_enqueue_style( 'yikes-datepicker-styles' , YIKES_MC_URL . 'public/css/yikes-datepicker-styles.min.css' ); |
|
| 858 | + wp_enqueue_style( 'jquery-datepicker-styles', YIKES_MC_URL . 'public/css/jquery-ui.min.css' ); |
|
| 859 | + wp_enqueue_style( 'yikes-datepicker-styles', YIKES_MC_URL . 'public/css/yikes-datepicker-styles.min.css' ); |
|
| 860 | 860 | |
| 861 | - switch ( $field['type'] ) { |
|
| 861 | + switch ( $field[ 'type' ] ) { |
|
| 862 | 862 | default: |
| 863 | 863 | case 'date': |
| 864 | - $date_format = ( isset( $field['date_format'] ) ) ? $field['date_format'] : 'mm/dd/yyyy'; |
|
| 864 | + $date_format = ( isset( $field[ 'date_format' ] ) ) ? $field[ 'date_format' ] : 'mm/dd/yyyy'; |
|
| 865 | 865 | break; |
| 866 | 866 | |
| 867 | 867 | case 'birthday': |
| 868 | - $date_format = ( isset( $field['date_format'] ) ) ? strtolower( $field['date_format'] ) : 'mm/dd'; |
|
| 868 | + $date_format = ( isset( $field[ 'date_format' ] ) ) ? strtolower( $field[ 'date_format' ] ) : 'mm/dd'; |
|
| 869 | 869 | break; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 873 | - $default_value = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $form_id ); |
|
| 872 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 873 | + $default_value = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $form_id ); |
|
| 874 | 874 | |
| 875 | 875 | // store empty number for looping |
| 876 | 876 | $x = 0; |
| 877 | 877 | |
| 878 | 878 | ?> |
| 879 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 879 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 880 | 880 | |
| 881 | 881 | <!-- dictate label visibility --> |
| 882 | - <?php if( !isset( $field['hide-label'] ) ) { ?> |
|
| 883 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 884 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 882 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 883 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 884 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 885 | 885 | </span> |
| 886 | 886 | <?php } ?> |
| 887 | 887 | |
| 888 | 888 | <!-- Description Above --> |
| 889 | 889 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 890 | 890 | |
| 891 | - <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 ) ); ?>"> |
|
| 891 | + <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 ) ); ?>"> |
|
| 892 | 892 | |
| 893 | 893 | <!-- Description Below --> |
| 894 | 894 | <?php if ( $show_description === true && $description_above === false ) { echo $description; } ?> |
@@ -899,26 +899,26 @@ discard block |
||
| 899 | 899 | break; |
| 900 | 900 | |
| 901 | 901 | case 'dropdown': |
| 902 | - $no_default = $field['default_choice'] === 'no-default' || isset( $field['default_choice'][0] ) && $field['default_choice'][0] === 'no-default'; |
|
| 903 | - $default_choice = is_array( $field['default_choice'] ) ? $field['default_choice'] : array( $field['default_choice'] ); |
|
| 902 | + $no_default = $field[ 'default_choice' ] === 'no-default' || isset( $field[ 'default_choice' ][ 0 ] ) && $field[ 'default_choice' ][ 0 ] === 'no-default'; |
|
| 903 | + $default_choice = is_array( $field[ 'default_choice' ] ) ? $field[ 'default_choice' ] : array( $field[ 'default_choice' ] ); |
|
| 904 | 904 | |
| 905 | 905 | // store empty number for looping |
| 906 | 906 | $x = 0; |
| 907 | 907 | ?> |
| 908 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 908 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 909 | 909 | <!-- dictate label visibility --> |
| 910 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 911 | - <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>"> |
|
| 912 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 910 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 911 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"> |
|
| 912 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 913 | 913 | </span> |
| 914 | 914 | <?php } |
| 915 | 915 | |
| 916 | 916 | // decode for looping |
| 917 | - $choices = json_decode( $field['choices'], true ); |
|
| 917 | + $choices = json_decode( $field[ 'choices' ], true ); |
|
| 918 | 918 | |
| 919 | 919 | // If the form was submitted, but failed, let's default to the chosen option |
| 920 | - if( isset( $_POST[ $field['merge'] ] ) && $form_submitted === 0 ) { |
|
| 921 | - $default_choice = is_array( $_POST[ $field['merge'] ] ) ? $_POST[ $field['merge'] ] : array( $_POST[ $field['merge'] ] ); |
|
| 920 | + if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted === 0 ) { |
|
| 921 | + $default_choice = is_array( $_POST[ $field[ 'merge' ] ] ) ? $_POST[ $field[ 'merge' ] ] : array( $_POST[ $field[ 'merge' ] ] ); |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | ?> |
@@ -926,11 +926,11 @@ discard block |
||
| 926 | 926 | <!-- Description Above --> |
| 927 | 927 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 928 | 928 | |
| 929 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
| 929 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
| 930 | 930 | <?php |
| 931 | 931 | $no_default_name = apply_filters( 'yikes-mailchimp-dropdown-field-no-default-option-name', __( 'Select...', 'yikes-inc-easy-mailchimp-extender' ), $form_id ); |
| 932 | 932 | echo $no_default === true ? '<option value="">' . $no_default_name . '</option>' : ''; |
| 933 | - foreach( $choices as $choice ) { ?> |
|
| 933 | + foreach ( $choices as $choice ) { ?> |
|
| 934 | 934 | <option |
| 935 | 935 | value="<?php echo esc_attr( $choice ); ?>" |
| 936 | 936 | <?php if ( $no_default !== true && in_array( $x, $default_choice ) || in_array( $choice, $default_choice, true ) ) { echo 'selected="selected"'; } ?>> |
@@ -953,17 +953,17 @@ discard block |
||
| 953 | 953 | case 'radio': |
| 954 | 954 | case 'checkbox': |
| 955 | 955 | // remove the ID (as to not assign the same ID to every radio button) |
| 956 | - unset( $field_array['id'] ); |
|
| 957 | - $choices = json_decode( $field['choices'], true ); |
|
| 956 | + unset( $field_array[ 'id' ] ); |
|
| 957 | + $choices = json_decode( $field[ 'choices' ], true ); |
|
| 958 | 958 | |
| 959 | 959 | // assign a default choice |
| 960 | - $no_default = $field['default_choice'] === 'no-default' || isset( $field['default_choice'][0] ) && $field['default_choice'][0] === 'no-default'; |
|
| 961 | - $default_choice = ( isset( $field['default_choice'] ) && ! empty( $field['default_choice'] ) ) ? $field['default_choice'] : $choices[0]; |
|
| 960 | + $no_default = $field[ 'default_choice' ] === 'no-default' || isset( $field[ 'default_choice' ][ 0 ] ) && $field[ 'default_choice' ][ 0 ] === 'no-default'; |
|
| 961 | + $default_choice = ( isset( $field[ 'default_choice' ] ) && ! empty( $field[ 'default_choice' ] ) ) ? $field[ 'default_choice' ] : $choices[ 0 ]; |
|
| 962 | 962 | $default_choice = ( is_array( $default_choice ) ) ? $default_choice : array( $default_choice ); |
| 963 | 963 | |
| 964 | 964 | // If the form was submitted, but failed, let's default to the chosen option |
| 965 | - if( isset( $_POST[ $field['merge'] ] ) && $form_submitted === 0 ) { |
|
| 966 | - $default_choice = is_array( $_POST[ $field['merge'] ] ) ? $_POST[ $field['merge'] ] : array( $_POST[ $field['merge'] ] ); |
|
| 965 | + if ( isset( $_POST[ $field[ 'merge' ] ] ) && $form_submitted === 0 ) { |
|
| 966 | + $default_choice = is_array( $_POST[ $field[ 'merge' ] ] ) ? $_POST[ $field[ 'merge' ] ] : array( $_POST[ $field[ 'merge' ] ] ); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | $count = count( $choices ); |
@@ -971,29 +971,29 @@ discard block |
||
| 971 | 971 | $x = 0; |
| 972 | 972 | |
| 973 | 973 | ?> |
| 974 | - <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 974 | + <label for="<?php echo esc_attr( $field_id_string ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 975 | 975 | |
| 976 | 976 | <!-- dictate label visibility --> |
| 977 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 978 | - <span class="<?php echo esc_attr( $field['merge'] ). '-label'; ?> checkbox-parent-label"> |
|
| 979 | - <?php echo esc_attr( apply_filters( 'yikes-mailchimp-'.$field['merge'].'-label', stripslashes( $field['label'] ) ) ); ?> |
|
| 977 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 978 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?> checkbox-parent-label"> |
|
| 979 | + <?php echo esc_attr( apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-label', stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 980 | 980 | </span> |
| 981 | 981 | <?php } |
| 982 | 982 | |
| 983 | 983 | // <!-- Description Above --> |
| 984 | 984 | if ( $show_description === true && $description_above === true ) { echo $description; } |
| 985 | 985 | |
| 986 | - foreach( $choices as $choice ) { |
|
| 986 | + foreach ( $choices as $choice ) { |
|
| 987 | 987 | ?> |
| 988 | - <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 } ?>"> |
|
| 988 | + <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 } ?>"> |
|
| 989 | 989 | <input |
| 990 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
| 991 | - name="<?php echo esc_attr( $field['merge'] ); ?>" |
|
| 992 | - id="<?php echo esc_attr( $field['merge'] . '-' . $i ); ?>" |
|
| 990 | + type="<?php echo esc_attr( $field[ 'type' ] ); ?>" |
|
| 991 | + name="<?php echo esc_attr( $field[ 'merge' ] ); ?>" |
|
| 992 | + id="<?php echo esc_attr( $field[ 'merge' ] . '-' . $i ); ?>" |
|
| 993 | 993 | <?php if ( $no_default !== true && in_array( $x, $default_choice ) || in_array( $choice, $default_choice, true ) ) { echo 'checked="checked"'; } ?> |
| 994 | - <?php echo $field_array['required']; ?> |
|
| 994 | + <?php echo $field_array[ 'required' ]; ?> |
|
| 995 | 995 | value="<?php echo esc_attr( $choice ); ?>"> |
| 996 | - <span class="<?php echo esc_attr( $field['merge'] ). '-label'; ?>"><?php echo stripslashes( $choice ); ?></span> |
|
| 996 | + <span class="<?php echo esc_attr( $field[ 'merge' ] ) . '-label'; ?>"><?php echo stripslashes( $choice ); ?></span> |
|
| 997 | 997 | </label> |
| 998 | 998 | <?php |
| 999 | 999 | $i++; |
@@ -1014,11 +1014,11 @@ discard block |
||
| 1014 | 1014 | /**** Interest Groups ****/ |
| 1015 | 1015 | |
| 1016 | 1016 | // Handle the Description logic in one spot, here: |
| 1017 | - $show_description = isset( $field['description'] ) && trim( $field['description'] ) !== '' ? true : false; |
|
| 1018 | - $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 1017 | + $show_description = isset( $field[ 'description' ] ) && trim( $field[ 'description' ] ) !== '' ? true : false; |
|
| 1018 | + $description_above = isset( $field[ 'description_above' ] ) && $field[ 'description_above' ] === '1' ? true : false; |
|
| 1019 | 1019 | if ( $show_description === true ) { |
| 1020 | - $description = '<p class="form-field-description" id="form-field-description-' . $field['group_id'] . '">'; |
|
| 1021 | - $description .= apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 1020 | + $description = '<p class="form-field-description" id="form-field-description-' . $field[ 'group_id' ] . '">'; |
|
| 1021 | + $description .= apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 1022 | 1022 | $description .= '</p>'; |
| 1023 | 1023 | |
| 1024 | 1024 | /** |
@@ -1030,26 +1030,26 @@ discard block |
||
| 1030 | 1030 | * @param string | $field['description'] | The field's description text |
| 1031 | 1031 | * @param int | $form_id |
| 1032 | 1032 | */ |
| 1033 | - $description = apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-description-html', $description, esc_attr( stripslashes( $field['description'] ) ), $form_id ); |
|
| 1033 | + $description = apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-description-html', $description, esc_attr( stripslashes( $field[ 'description' ] ) ), $form_id ); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | // Get the default choice(s) from the field settings and turn them into an array if not already |
| 1037 | - $default_choice = ( isset( $field['default_choice'] ) ) ? $field['default_choice'] : ''; |
|
| 1037 | + $default_choice = ( isset( $field[ 'default_choice' ] ) ) ? $field[ 'default_choice' ] : ''; |
|
| 1038 | 1038 | $default_choice = ( is_array( $default_choice ) ) ? $default_choice : array( $default_choice ); |
| 1039 | 1039 | |
| 1040 | 1040 | // get our groups |
| 1041 | - $groups = ( isset( $field['groups'] ) && ! empty( $field['groups'] ) ) ? json_decode( $field['groups'], true ) : array(); |
|
| 1041 | + $groups = ( isset( $field[ 'groups' ] ) && ! empty( $field[ 'groups' ] ) ) ? json_decode( $field[ 'groups' ], true ) : array(); |
|
| 1042 | 1042 | |
| 1043 | 1043 | $count = count( $groups ); |
| 1044 | 1044 | |
| 1045 | - if( $field['type'] === 'checkboxes' ) { |
|
| 1045 | + if ( $field[ 'type' ] === 'checkboxes' ) { |
|
| 1046 | 1046 | $type = 'checkbox'; |
| 1047 | - } else if( $field['type'] === 'radio' ) { |
|
| 1047 | + } else if ( $field[ 'type' ] === 'radio' ) { |
|
| 1048 | 1048 | $type = 'radio'; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | // loop over the interest group field types |
| 1052 | - switch ( $field['type'] ) { |
|
| 1052 | + switch ( $field[ 'type' ] ) { |
|
| 1053 | 1053 | |
| 1054 | 1054 | case 'checkboxes': |
| 1055 | 1055 | case 'radio': |
@@ -1057,11 +1057,11 @@ discard block |
||
| 1057 | 1057 | $x = 1; // used to find the last item of our array |
| 1058 | 1058 | |
| 1059 | 1059 | ?> |
| 1060 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 1061 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 1060 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 1061 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 1062 | 1062 | <!-- dictate label visibility --> |
| 1063 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?> checkbox-parent-label"> |
|
| 1064 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 1063 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?> checkbox-parent-label"> |
|
| 1064 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 1065 | 1065 | </span> |
| 1066 | 1066 | <?php |
| 1067 | 1067 | } |
@@ -1070,8 +1070,8 @@ discard block |
||
| 1070 | 1070 | if ( $show_description === true && $description_above === true ) { echo $description; } |
| 1071 | 1071 | |
| 1072 | 1072 | // Display Submission Errors |
| 1073 | - if( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
| 1074 | - if( in_array( $field['group_id'], $missing_required_checkbox_interest_groups ) ) { |
|
| 1073 | + if ( ! empty( $missing_required_checkbox_interest_groups ) ) { |
|
| 1074 | + if ( in_array( $field[ 'group_id' ], $missing_required_checkbox_interest_groups ) ) { |
|
| 1075 | 1075 | ?> |
| 1076 | 1076 | <p class="yikes-mailchimp-required-interest-group-error"> |
| 1077 | 1077 | <?php echo apply_filters( 'yikes-mailchimp-interest-group-checkbox-error', __( 'This field is required.', 'yikes-inc-easy-mailchimp-extender' ), $form_id ); ?> |
@@ -1083,20 +1083,20 @@ discard block |
||
| 1083 | 1083 | foreach ( $groups as $group_id => $name ) { |
| 1084 | 1084 | |
| 1085 | 1085 | // If the form was submitted and failed, set the submitted/chosen values as the default |
| 1086 | - if( isset( $_POST[ 'group-' . $field['group_id'] ] ) && $form_submitted === 0 ) { |
|
| 1086 | + if ( isset( $_POST[ 'group-' . $field[ 'group_id' ] ] ) && $form_submitted === 0 ) { |
|
| 1087 | 1087 | |
| 1088 | 1088 | // Format default choice as array |
| 1089 | - $default_choice = ( is_array( $_POST[ 'group-' . $field['group_id'] ] ) ) ? $_POST[ 'group-' . $field['group_id'] ] : array( $_POST[ 'group-' . $field['group_id'] ] ); |
|
| 1089 | + $default_choice = ( is_array( $_POST[ 'group-' . $field[ 'group_id' ] ] ) ) ? $_POST[ 'group-' . $field[ 'group_id' ] ] : array( $_POST[ 'group-' . $field[ 'group_id' ] ] ); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | ?> |
| 1093 | - <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 } ?>"> |
|
| 1093 | + <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 } ?>"> |
|
| 1094 | 1094 | <input |
| 1095 | - <?php if( isset( $field['require'] ) && $field['require'] == 1 ) { if ( $field['type'] !== 'checkboxes' ) { ?> required="required" <?php } ?> |
|
| 1095 | + <?php if ( isset( $field[ 'require' ] ) && $field[ 'require' ] == 1 ) { if ( $field[ 'type' ] !== 'checkboxes' ) { ?> required="required" <?php } ?> |
|
| 1096 | 1096 | class="yikes-interest-group-required" <?php } ?> |
| 1097 | 1097 | type="<?php echo esc_attr( $type ); ?>" |
| 1098 | - name="group-<?php echo esc_attr( $field['group_id'] ); ?>[]" |
|
| 1099 | - id="<?php echo esc_attr( $field['group_id'] . '-' . $i ); ?>" |
|
| 1098 | + name="group-<?php echo esc_attr( $field[ 'group_id' ] ); ?>[]" |
|
| 1099 | + id="<?php echo esc_attr( $field[ 'group_id' ] . '-' . $i ); ?>" |
|
| 1100 | 1100 | <?php if ( in_array( $group_id, $default_choice ) ) { echo 'checked="checked"'; } ?> |
| 1101 | 1101 | value="<?php echo esc_attr( $group_id ); ?>"> |
| 1102 | 1102 | <?php echo esc_attr( $name ); ?> |
@@ -1118,32 +1118,32 @@ discard block |
||
| 1118 | 1118 | |
| 1119 | 1119 | ?> |
| 1120 | 1120 | |
| 1121 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 1121 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 1122 | 1122 | <!-- dictate label visibility --> |
| 1123 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 1124 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?>"> |
|
| 1125 | - <?php echo apply_filters( 'yikes-mailchimp-' . $field['group_id'] . '-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 1123 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 1124 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?>"> |
|
| 1125 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 1126 | 1126 | </span> |
| 1127 | 1127 | <?php } ?> |
| 1128 | 1128 | |
| 1129 | 1129 | <!-- Description Above --> |
| 1130 | 1130 | <?php if ( $show_description === true && $description_above === true ) { echo $description; } ?> |
| 1131 | 1131 | |
| 1132 | - <select <?php echo implode( ' ' , $field_array ); ?>> |
|
| 1132 | + <select <?php echo implode( ' ', $field_array ); ?>> |
|
| 1133 | 1133 | |
| 1134 | 1134 | <?php |
| 1135 | - $no_default = $field['default_choice'] === 'no-default' || isset( $field['default_choice'][0] ) && $field['default_choice'][0] === 'no-default'; |
|
| 1135 | + $no_default = $field[ 'default_choice' ] === 'no-default' || isset( $field[ 'default_choice' ][ 0 ] ) && $field[ 'default_choice' ][ 0 ] === 'no-default'; |
|
| 1136 | 1136 | $no_default_name = apply_filters( 'yikes-mailchimp-dropdown-ig-no-default-option-name', __( 'Select...', 'yikes-inc-easy-mailchimp-extender' ), $form_id ); |
| 1137 | 1137 | echo $no_default === true ? '<option value="">' . $no_default_name . '</option>' : ''; |
| 1138 | 1138 | |
| 1139 | 1139 | $i = 0; |
| 1140 | - foreach( $groups as $group_id => $name ) { |
|
| 1140 | + foreach ( $groups as $group_id => $name ) { |
|
| 1141 | 1141 | |
| 1142 | 1142 | // If the form was submitted and failed, set the submitted/chosen values as the default |
| 1143 | - if( isset( $_POST[ 'group-' . $field['group_id'] ] ) && $form_submitted === 0 ) { |
|
| 1143 | + if ( isset( $_POST[ 'group-' . $field[ 'group_id' ] ] ) && $form_submitted === 0 ) { |
|
| 1144 | 1144 | |
| 1145 | 1145 | // Format default choice as array |
| 1146 | - $default_choice = ( is_array( $_POST[ 'group-' . $field['group_id'] ] ) ) ? $_POST[ 'group-' . $field['group_id'] ] : array( $_POST[ 'group-' . $field['group_id'] ] ); |
|
| 1146 | + $default_choice = ( is_array( $_POST[ 'group-' . $field[ 'group_id' ] ] ) ) ? $_POST[ 'group-' . $field[ 'group_id' ] ] : array( $_POST[ 'group-' . $field[ 'group_id' ] ] ); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | ?> |
| 1149 | 1149 | <option |
@@ -1171,12 +1171,12 @@ discard block |
||
| 1171 | 1171 | |
| 1172 | 1172 | ?> |
| 1173 | 1173 | |
| 1174 | - <label for="<?php echo esc_attr( $field['group_id'] ); ?>" <?php echo implode( ' ' , $label_array ); ?>> |
|
| 1174 | + <label for="<?php echo esc_attr( $field[ 'group_id' ] ); ?>" <?php echo implode( ' ', $label_array ); ?>> |
|
| 1175 | 1175 | |
| 1176 | 1176 | <!-- dictate label visibility --> |
| 1177 | - <?php if( ! isset( $field['hide-label'] ) ) { ?> |
|
| 1178 | - <span class="<?php echo esc_attr( $field['group_id'] ) . '-label'; ?> checkbox-parent-label" style="display:none;"> |
|
| 1179 | - <?php echo apply_filters( 'yikes-mailchimp-'.$field['group_id'].'-label' , esc_attr( stripslashes( $field['label'] ) ) ); ?> |
|
| 1177 | + <?php if ( ! isset( $field[ 'hide-label' ] ) ) { ?> |
|
| 1178 | + <span class="<?php echo esc_attr( $field[ 'group_id' ] ) . '-label'; ?> checkbox-parent-label" style="display:none;"> |
|
| 1179 | + <?php echo apply_filters( 'yikes-mailchimp-' . $field[ 'group_id' ] . '-label', esc_attr( stripslashes( $field[ 'label' ] ) ) ); ?> |
|
| 1180 | 1180 | </span> |
| 1181 | 1181 | <?php } |
| 1182 | 1182 | |
@@ -1186,17 +1186,17 @@ discard block |
||
| 1186 | 1186 | // Turn $default_choice into an array if it isn't already |
| 1187 | 1187 | $default_choice = ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice : array( $default_choice ); |
| 1188 | 1188 | |
| 1189 | - foreach( $groups as $group_id => $name ) { |
|
| 1189 | + foreach ( $groups as $group_id => $name ) { |
|
| 1190 | 1190 | ?> |
| 1191 | - <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;"> |
|
| 1191 | + <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;"> |
|
| 1192 | 1192 | <input |
| 1193 | 1193 | type="checkbox" |
| 1194 | - name="group-<?php echo esc_attr( $field['group_id'] ); ?>[]" |
|
| 1195 | - id="<?php echo esc_attr( $field['group_id'] ) . '-' . $i; ?>" |
|
| 1194 | + name="group-<?php echo esc_attr( $field[ 'group_id' ] ); ?>[]" |
|
| 1195 | + id="<?php echo esc_attr( $field[ 'group_id' ] ) . '-' . $i; ?>" |
|
| 1196 | 1196 | value="<?php echo esc_attr( $group_id ) ?>" |
| 1197 | 1197 | <?php if ( in_array( $group_id, $default_choice ) ) { echo 'checked="checked"'; } ?> |
| 1198 | 1198 | > |
| 1199 | - <?php echo esc_attr( stripslashes( str_replace( '' , '\'', $name ) ) ); ?> |
|
| 1199 | + <?php echo esc_attr( stripslashes( str_replace( '', '\'', $name ) ) ); ?> |
|
| 1200 | 1200 | </label> |
| 1201 | 1201 | <?php |
| 1202 | 1202 | $i++; |
@@ -1221,14 +1221,14 @@ discard block |
||
| 1221 | 1221 | echo $recaptcha_box; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - $admin_class = is_user_logged_in() && current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ? ' admin-logged-in' : ''; |
|
| 1224 | + $admin_class = is_user_logged_in() && current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ? ' admin-logged-in' : ''; |
|
| 1225 | 1225 | ?> |
| 1226 | 1226 | |
| 1227 | 1227 | <!-- Honeypot Trap --> |
| 1228 | 1228 | <input type="hidden" name="yikes-mailchimp-honeypot" id="yikes-mailchimp-honeypot-<?php echo esc_attr( $form_id ); ?>" value=""> |
| 1229 | 1229 | |
| 1230 | 1230 | <!-- List ID --> |
| 1231 | - <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'] ); ?>"> |
|
| 1231 | + <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' ] ); ?>"> |
|
| 1232 | 1232 | |
| 1233 | 1233 | <!-- The form that is being submitted! Used to display error/success messages above the correct form --> |
| 1234 | 1234 | <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 ); ?>"> |
@@ -1242,15 +1242,15 @@ discard block |
||
| 1242 | 1242 | // If the number of fields, is equal to the hidden label count, add our class |
| 1243 | 1243 | // eg: All field labels are set to hidden. |
| 1244 | 1244 | if ( absint( $field_count ) === absint( $hidden_label_count ) ) { |
| 1245 | - $submit_button_label_classes[] = 'labels-hidden'; |
|
| 1245 | + $submit_button_label_classes[ ] = 'labels-hidden'; |
|
| 1246 | 1246 | } |
| 1247 | 1247 | echo '<label class="empty-form-inline-label submit-button-inline-label"><span class="' . implode( ' ', $submit_button_label_classes ) . '"> </span>'; |
| 1248 | 1248 | } |
| 1249 | 1249 | // Display the image or text based button. |
| 1250 | 1250 | if ( $submit_button_type === 'text' ) { |
| 1251 | - 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'] ); |
|
| 1251 | + 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' ] ); |
|
| 1252 | 1252 | } else { |
| 1253 | - 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'] ); |
|
| 1253 | + 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' ] ); |
|
| 1254 | 1254 | } |
| 1255 | 1255 | if ( $form_inline && ! $inline_form_override ) { |
| 1256 | 1256 | echo '</label>'; |
@@ -1263,8 +1263,8 @@ discard block |
||
| 1263 | 1263 | |
| 1264 | 1264 | <?php |
| 1265 | 1265 | /* If the current user is logged in, and an admin...lets display our 'Edit Form' link */ |
| 1266 | - if( is_user_logged_in() ) { |
|
| 1267 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
| 1266 | + if ( is_user_logged_in() ) { |
|
| 1267 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
| 1268 | 1268 | echo $edit_form_link; |
| 1269 | 1269 | } |
| 1270 | 1270 | } |
@@ -1280,7 +1280,7 @@ discard block |
||
| 1280 | 1280 | * for non-admins |
| 1281 | 1281 | */ |
| 1282 | 1282 | if ( ! current_user_can( 'manage_options' ) ) { |
| 1283 | - $impressions = $form_data['impressions'] + 1; |
|
| 1283 | + $impressions = $form_data[ 'impressions' ] + 1; |
|
| 1284 | 1284 | $interface->update_form_field( $form_id, 'impressions', $impressions ); |
| 1285 | 1285 | } |
| 1286 | 1286 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | <?php settings_fields( 'yikes_inc_easy_mc_recaptcha_settings_page' ); ?> |
| 30 | 30 | |
| 31 | 31 | <label for="yikes-mc-recaptcha-setting"> |
| 32 | - <input type="checkbox" id="yikes-mc-recaptcha-setting" name="yikes-mc-recaptcha-status" class="recaptcha-setting-checkbox" value="1" <?php checked( get_option( 'yikes-mc-recaptcha-status', '' ) , '1' ); ?>> |
|
| 32 | + <input type="checkbox" id="yikes-mc-recaptcha-setting" name="yikes-mc-recaptcha-status" class="recaptcha-setting-checkbox" value="1" <?php checked( get_option( 'yikes-mc-recaptcha-status', '' ), '1' ); ?>> |
|
| 33 | 33 | <strong><?php _e( 'Enable reCAPTCHA Protection', 'yikes-inc-easy-mailchimp-extender' ); ?></strong> |
| 34 | 34 | </label> |
| 35 | 35 | |