Completed
Push — staging ( 8d1003...af0e5e )
by
unknown
20:05
created
admin/partials/ajax/add_interest_group_to_form.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 $error = 0;
6 6
 
7 7
 // Get our $_POST variables
8
-$list_id = isset( $_POST['list_id'] ) ? $_POST['list_id'] : '';
9
-$interest_groups = isset( $_POST['interest_groups'] ) ? $_POST['interest_groups'] : array();
8
+$list_id = isset( $_POST[ 'list_id' ] ) ? $_POST[ 'list_id' ] : '';
9
+$interest_groups = isset( $_POST[ 'interest_groups' ] ) ? $_POST[ 'interest_groups' ] : array();
10 10
 
11 11
 // Make sure our $_POST variables aren't empty
12 12
 if ( empty( $list_id ) ) {
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 // Loop through the interest groups data (group_id, field_name, field_type) and add the fields to the form
52
-foreach( $interest_groups as $group ) {
52
+foreach ( $interest_groups as $group ) {
53 53
 
54 54
 	// find and return the location of this merge field in the array
55
-	$index      = $this->findMCListIndex( $group['group_id'], $interest_groupings, 'id' );
55
+	$index      = $this->findMCListIndex( $group[ 'group_id' ], $interest_groupings, 'id' );
56 56
 	$field_data = $interest_groupings[ $index ];
57
-	$groups     = wp_list_pluck( $field_data['items'], 'name' );
57
+	$groups     = wp_list_pluck( $field_data[ 'items' ], 'name' );
58 58
 
59 59
 	?>
60
-	<section class="draggable" id="<?php echo $group['group_id']; ?>">
60
+	<section class="draggable" id="<?php echo $group[ 'group_id' ]; ?>">
61 61
 		<!-- top -->
62 62
 		<a href="#" class="expansion-section-title settings-sidebar">
63
-			<span class="dashicons dashicons-plus yikes-mc-expansion-toggle" title="<?php _e( 'Expand Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>"></span>
64
-			<?php echo stripslashes( $group['field_name'] ); ?>
65
-			<span class="field-type-text"><small><?php echo __( 'type' , 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $group['field_type']; ?></small></span>
63
+			<span class="dashicons dashicons-plus yikes-mc-expansion-toggle" title="<?php _e( 'Expand Field', 'yikes-inc-easy-mailchimp-extender' ); ?>"></span>
64
+			<?php echo stripslashes( $group[ 'field_name' ] ); ?>
65
+			<span class="field-type-text"><small><?php echo __( 'type', 'yikes-inc-easy-mailchimp-extender' ) . ' : ' . $group[ 'field_type' ]; ?></small></span>
66 66
 		</a>
67 67
 		<!-- expansion section -->
68 68
 		<div class="yikes-mc-settings-expansion-section">
@@ -70,37 +70,37 @@  discard block
 block discarded – undo
70 70
 			<!-- Single or Double Opt-in -->
71 71
 			<p class="type-container"><!-- necessary to prevent skipping on slideToggle(); -->
72 72
 				<!-- store the label -->
73
-				<input type="hidden" name="field[<?php echo $group['group_id']; ?>][label]" value="<?php echo htmlspecialchars( $group['field_name'] ); ?>" />
74
-				<input type="hidden" name="field[<?php echo $group['group_id']; ?>][type]" value="<?php echo $group['field_type']; ?>" />
75
-				<input type="hidden" name="field[<?php echo $group['group_id']; ?>][group_id]" value="<?php echo $group['group_id']; ?>" />
76
-				<input type="hidden" name="field[<?php echo $group['group_id']; ?>][groups]" value='<?php echo esc_attr( json_encode( $groups, true ) ); ?>' />
73
+				<input type="hidden" name="field[<?php echo $group[ 'group_id' ]; ?>][label]" value="<?php echo htmlspecialchars( $group[ 'field_name' ] ); ?>" />
74
+				<input type="hidden" name="field[<?php echo $group[ 'group_id' ]; ?>][type]" value="<?php echo $group[ 'field_type' ]; ?>" />
75
+				<input type="hidden" name="field[<?php echo $group[ 'group_id' ]; ?>][group_id]" value="<?php echo $group[ 'group_id' ]; ?>" />
76
+				<input type="hidden" name="field[<?php echo $group[ 'group_id' ]; ?>][groups]" value='<?php echo esc_attr( json_encode( $groups, true ) ); ?>' />
77 77
 
78 78
 
79 79
 				<table class="form-table form-field-container">
80 80
 
81 81
 					<!-- Default Value -->
82
-					<?php switch( $group['field_type'] ) {
82
+					<?php switch ( $group[ 'field_type' ] ) {
83 83
 
84 84
 						case 'radio':
85 85
 						?>
86 86
 							<tr valign="top">
87 87
 								<td scope="row">
88 88
 									<label for="placeholder">
89
-										<?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?>
89
+										<?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?>
90 90
 									</label>
91 91
 								</td>
92 92
 								<td>
93 93
 
94
-									<?php $pre_selected = ! empty( $field_data['default_choice'] ) ? $field_data['default_choice'] : 'no-default'; ?>
94
+									<?php $pre_selected = ! empty( $field_data[ 'default_choice' ] ) ? $field_data[ 'default_choice' ] : 'no-default'; ?>
95 95
 
96 96
 									<!-- No Default option for radio buttons -->
97
-									<input type="radio" name="field[<?php echo $group['group_id']; ?>][default_choice][]" value="no-default" <?php checked( $pre_selected, 'no-default' ); ?>>No Default
97
+									<input type="radio" name="field[<?php echo $group[ 'group_id' ]; ?>][default_choice][]" value="no-default" <?php checked( $pre_selected, 'no-default' ); ?>>No Default
98 98
 
99
-									<?php foreach ( $field_data['items'] as $id => $interest_group ) { ?>
100
-										<input type="radio" name="field[<?php echo $group['group_id']; ?>][default_choice][]" value="<?php echo esc_attr( $id ); ?>" <?php checked( $pre_selected, $id ); ?>><?php echo stripslashes( $interest_group['name'] );
99
+									<?php foreach ( $field_data[ 'items' ] as $id => $interest_group ) { ?>
100
+										<input type="radio" name="field[<?php echo $group[ 'group_id' ]; ?>][default_choice][]" value="<?php echo esc_attr( $id ); ?>" <?php checked( $pre_selected, $id ); ?>><?php echo stripslashes( $interest_group[ 'name' ] );
101 101
 									} ?>
102 102
 
103
-									<p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
103
+									<p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
104 104
 								</td>
105 105
 							</tr>
106 106
 
@@ -114,22 +114,22 @@  discard block
 block discarded – undo
114 114
 							<tr valign="top" class="yikes-checkbox-container">
115 115
 								<td scope="row">
116 116
 									<label for="placeholder">
117
-										<?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?>
117
+										<?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?>
118 118
 									</label>
119 119
 								</td>
120 120
 								<td>
121 121
 									<?php
122
-									foreach ( $field_data['items'] as $id => $interest_group ) {
123
-										$pre_selected = ! empty( $field_data['default_choice'] ) ? $field_data['default_choice'] : '0';
122
+									foreach ( $field_data[ 'items' ] as $id => $interest_group ) {
123
+										$pre_selected = ! empty( $field_data[ 'default_choice' ] ) ? $field_data[ 'default_choice' ] : '0';
124 124
 										?>
125 125
 										<label>
126
-											<input type="checkbox" name="field[<?php echo $group['group_id']; ?>][default_choice][]" value="<?php echo $id; ?>" <?php checked( $pre_selected, $id ); ?>>
127
-											<?php echo stripslashes( $interest_group['name'] ); ?>
126
+											<input type="checkbox" name="field[<?php echo $group[ 'group_id' ]; ?>][default_choice][]" value="<?php echo $id; ?>" <?php checked( $pre_selected, $id ); ?>>
127
+											<?php echo stripslashes( $interest_group[ 'name' ] ); ?>
128 128
 										</label>
129 129
 										<?php
130 130
 									}
131 131
 									?>
132
-									<p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
132
+									<p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
133 133
 								</td>
134 134
 							</tr>
135 135
 
@@ -141,30 +141,30 @@  discard block
 block discarded – undo
141 141
 							<!-- Placeholder -->
142 142
 							<tr valign="top">
143 143
 								<td scope="row">
144
-									<label for="placeholder_<?php echo esc_attr( $field['merge'] ); ?>">
144
+									<label for="placeholder_<?php echo esc_attr( $field[ 'merge' ] ); ?>">
145 145
 										<?php _e( 'Placeholder', 'yikes-inc-easy-mailchimp-extender' ); ?>
146 146
 									</label>
147 147
 								</td>
148 148
 								<td>
149
-									<input type="text" id="placeholder_<?php echo esc_attr( $field['merge'] ); ?>" class="widefat" name="field[<?php echo $field['merge']; ?>][placeholder]" value="<?php echo isset( $field['placeholder'] ) ? $field['placeholder'] : '' ; ?>" />
150
-									<p class="description"><small><?php _e( "Assign a placeholder value for the select option.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
149
+									<input type="text" id="placeholder_<?php echo esc_attr( $field[ 'merge' ] ); ?>" class="widefat" name="field[<?php echo $field[ 'merge' ]; ?>][placeholder]" value="<?php echo isset( $field[ 'placeholder' ] ) ? $field[ 'placeholder' ] : ''; ?>" />
150
+									<p class="description"><small><?php _e( "Assign a placeholder value for the select option.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
151 151
 								</td>
152 152
 							</tr>
153 153
 							<tr valign="top">
154 154
 								<td scope="row">
155 155
 									<label for="placeholder">
156
-										<?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?>
156
+										<?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?>
157 157
 									</label>
158 158
 								</td>
159 159
 								<td>
160
-									<select type="default" name="field[<?php echo $group['group_id']; ?>][default_choice]">
161
-										<?php $pre_selected = ! empty( $field_data['default_choice'] ) ? $field_data['default_choice'] : 'no-default'; ?>
160
+									<select type="default" name="field[<?php echo $group[ 'group_id' ]; ?>][default_choice]">
161
+										<?php $pre_selected = ! empty( $field_data[ 'default_choice' ] ) ? $field_data[ 'default_choice' ] : 'no-default'; ?>
162 162
 										<option value="no-default">No Default</option>
163
-										<?php foreach ( $field_data['items'] as $id => $interest_group ) { ?>
164
-											<option value="<?php echo $id; ?>" <?php selected( $pre_selected, $id ); ?>><?php echo $interest_group['name']; ?></option>
163
+										<?php foreach ( $field_data[ 'items' ] as $id => $interest_group ) { ?>
164
+											<option value="<?php echo $id; ?>" <?php selected( $pre_selected, $id ); ?>><?php echo $interest_group[ 'name' ]; ?></option>
165 165
 										<?php } ?>
166 166
 									</select>
167
-									<p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
167
+									<p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
168 168
 								</td>
169 169
 							</tr>
170 170
 
@@ -176,25 +176,25 @@  discard block
 block discarded – undo
176 176
 					<tr valign="top">
177 177
 						<td scope="row">
178 178
 							<label for="placeholder">
179
-								<?php _e( 'Description' , 'yikes-inc-easy-mailchimp-extender' ); ?>
179
+								<?php _e( 'Description', 'yikes-inc-easy-mailchimp-extender' ); ?>
180 180
 							</label>
181 181
 						</td>
182 182
 						<td>
183
-							<textarea class="widefat field-description-input" name="field[<?php echo $group['group_id']; ?>][description]"></textarea>
184
-							<p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
183
+							<textarea class="widefat field-description-input" name="field[<?php echo $group[ 'group_id' ]; ?>][description]"></textarea>
184
+							<p class="description"><small><?php _e( "Enter the description for the form field. This will be displayed to the user and provide some direction on how the field should be filled out or selected.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
185 185
 						</td>
186 186
 					</tr>
187 187
 
188 188
 					<!-- Description Above Field -->
189 189
 					<tr valign="top" class="yikes-checkbox-container">
190 190
 						<td scope="row">
191
-							<label for="description_above_<?php echo esc_attr( $group['group_id'] ); ?>">
192
-								<?php _e( 'Description Above Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>
191
+							<label for="description_above_<?php echo esc_attr( $group[ 'group_id' ] ); ?>">
192
+								<?php _e( 'Description Above Field', 'yikes-inc-easy-mailchimp-extender' ); ?>
193 193
 							</label>
194 194
 						</td>
195 195
 						<td>
196
-							<input type="checkbox" id="description_above_<?php echo esc_attr( $group['group_id'] ); ?>" class="widefat field-description-input" name="field[<?php echo $group['group_id']; ?>][description_above]" value="1" />
197
-							<p class="description"><small><?php _e( "By default the description will appear undearneath the field. Check this box if you'd like the description to appear above the field.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
196
+							<input type="checkbox" id="description_above_<?php echo esc_attr( $group[ 'group_id' ] ); ?>" class="widefat field-description-input" name="field[<?php echo $group[ 'group_id' ]; ?>][description_above]" value="1" />
197
+							<p class="description"><small><?php _e( "By default the description will appear undearneath the field. Check this box if you'd like the description to appear above the field.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
198 198
 						</td>
199 199
 					</tr>
200 200
 
@@ -202,48 +202,48 @@  discard block
 block discarded – undo
202 202
 					<tr valign="top">
203 203
 						<td scope="row">
204 204
 							<label for="placeholder">
205
-								<?php _e( 'Additional Classes' , 'yikes-inc-easy-mailchimp-extender' ); ?>
205
+								<?php _e( 'Additional Classes', 'yikes-inc-easy-mailchimp-extender' ); ?>
206 206
 							</label>
207 207
 						</td>
208 208
 						<td>
209
-							<input type="text" class="widefat" name="field[<?php echo $group['group_id']; ?>][additional-classes]" value="<?php echo isset( $group['classes'] ) ? stripslashes( wp_strip_all_tags( $group['classes'] ) ) : '' ; ?>" />
210
-							<p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' );?></small></p>
209
+							<input type="text" class="widefat" name="field[<?php echo $group[ 'group_id' ]; ?>][additional-classes]" value="<?php echo isset( $group[ 'classes' ] ) ? stripslashes( wp_strip_all_tags( $group[ 'classes' ] ) ) : ''; ?>" />
210
+							<p class="description"><small><?php printf( __( "Assign additional classes to this field. %s.", 'yikes-inc-easy-mailchimp-extender' ), '<a target="_blank" href="' . esc_url( 'https://yikesplugins.com/support/knowledge-base/bundled-css-classes/' ) . '">' . __( 'View bundled classes', 'yikes-inc-easy-mailchimp-extender' ) . '</a>' ); ?></small></p>
211 211
 						</td>
212 212
 						</tr>
213 213
 						<!-- Required Toggle -->
214 214
 						<tr valign="top" class="yikes-checkbox-container">
215 215
 							<td scope="row">
216 216
 								<label for="field-required">
217
-									<?php _e( 'Field Required?' , 'yikes-inc-easy-mailchimp-extender' ); ?>
217
+									<?php _e( 'Field Required?', 'yikes-inc-easy-mailchimp-extender' ); ?>
218 218
 								</label>
219 219
 							</td>
220 220
 							<td>
221
-								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group['group_id']; ?>][require]">
222
-								<p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
221
+								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group[ 'group_id' ]; ?>][require]">
222
+								<p class="description"><small><?php _e( "Require this field to be filled in before the form can be submitted.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
223 223
 							</td>
224 224
 						</tr>
225 225
 						<!-- Visible Toggle -->
226 226
 						<tr valign="top" class="yikes-checkbox-container">
227 227
 							<td scope="row">
228 228
 								<label for="hide-field">
229
-									<?php _e( 'Hide Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>
229
+									<?php _e( 'Hide Field', 'yikes-inc-easy-mailchimp-extender' ); ?>
230 230
 								</label>
231 231
 							</td>
232 232
 							<td>
233
-								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group['group_id']; ?>][hide]">
234
-								<p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
233
+								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group[ 'group_id' ]; ?>][hide]">
234
+								<p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
235 235
 							</td>
236 236
 						</tr>
237 237
 						<!-- Toggle Field Label Visibility -->
238 238
 						<tr valign="top" class="yikes-checkbox-container">
239 239
 							<td scope="row">
240 240
 								<label for="placeholder">
241
-									<?php _e( 'Hide Label' , 'yikes-inc-easy-mailchimp-extender' ); ?>
241
+									<?php _e( 'Hide Label', 'yikes-inc-easy-mailchimp-extender' ); ?>
242 242
 								</label>
243 243
 							</td>
244 244
 							<td>
245
-								<input type="checkbox" name="field[<?php echo $group['group_id']; ?>][hide-label]" value="1" />
246
-								<p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
245
+								<input type="checkbox" name="field[<?php echo $group[ 'group_id' ]; ?>][hide-label]" value="1" />
246
+								<p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
247 247
 							</td>
248 248
 						</tr>
249 249
 						<!-- Toggle Buttons -->
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 							</td>
254 254
 							<td>
255 255
 								<span class="toggle-container">
256
-									<a href="#" class="hide-field"><?php _e( "Close" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
257
-									<a href="#" class="remove-field" alt="<?php echo $group['group_id']; ?>"><?php _e( "Remove Field" , 'yikes-inc-easy-mailchimp-extender' ); ?></a>
256
+									<a href="#" class="hide-field"><?php _e( "Close", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
257
+									<a href="#" class="remove-field" alt="<?php echo $group[ 'group_id' ]; ?>"><?php _e( "Remove Field", 'yikes-inc-easy-mailchimp-extender' ); ?></a>
258 258
 								</span>
259 259
 							</td>
260 260
 						</tr>
Please login to merge, or discard this patch.