Completed
Pull Request — staging (#840)
by
unknown
16:08
created
admin/partials/ajax/add_interest_group_to_form.php 1 patch
Spacing   +57 added lines, -57 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,19 +114,19 @@  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
-										<input type="checkbox" name="field[<?php echo $group['group_id']; ?>][default_choice][]" value="<?php echo $id; ?>" <?php checked( $pre_selected, $id ); ?>><?php echo stripslashes( $interest_group['name'] ); ?>
125
+										<input type="checkbox" name="field[<?php echo $group[ 'group_id' ]; ?>][default_choice][]" value="<?php echo $id; ?>" <?php checked( $pre_selected, $id ); ?>><?php echo stripslashes( $interest_group[ 'name' ] ); ?>
126 126
 										<?php
127 127
 									}
128 128
 									?>
129
-									<p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
129
+									<p class="description"><small><?php _e( "Select the option that should be selected by default.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
130 130
 								</td>
131 131
 							</tr>
132 132
 
@@ -138,38 +138,38 @@  discard block
 block discarded – undo
138 138
 							<!-- Placeholder -->
139 139
 							<tr valign="top">
140 140
 								<td scope="row">
141
-									<label for="placeholder_<?php echo esc_attr( $field['merge'] ); ?>">
141
+									<label for="placeholder_<?php echo esc_attr( $field[ 'merge' ] ); ?>">
142 142
 										<?php _e( 'Placeholder', 'yikes-inc-easy-mailchimp-extender' ); ?>
143 143
 									</label>
144 144
 								</td>
145 145
 								<td>
146
-									<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'] : '' ; ?>" />
147
-									<p class="description"><small><?php _e( "Assign a placeholder value for the select option.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
146
+									<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' ] : ''; ?>" />
147
+									<p class="description"><small><?php _e( "Assign a placeholder value for the select option.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
148 148
 								</td>
149 149
 							</tr>
150 150
 
151 151
 							<tr valign="top">
152 152
 								<td scope="row">
153 153
 									<label for="placeholder">
154
-										<?php _e( 'Default Selection' , 'yikes-inc-easy-mailchimp-extender' ); ?>
154
+										<?php _e( 'Default Selection', 'yikes-inc-easy-mailchimp-extender' ); ?>
155 155
 									</label>
156 156
 								</td>
157 157
 								<td>
158
-									<select type="default" name="field[<?php echo $group['group_id']; ?>][default_choice]">
159
-										<?php $pre_selected = ! empty( $field_data['default_choice'] ) ? $field_data['default_choice'] : 'no-default'; ?>
158
+									<select type="default" name="field[<?php echo $group[ 'group_id' ]; ?>][default_choice]">
159
+										<?php $pre_selected = ! empty( $field_data[ 'default_choice' ] ) ? $field_data[ 'default_choice' ] : 'no-default'; ?>
160 160
 										<option value="no-default">No Default</option>
161
-										<?php foreach ( $field_data['items'] as $id => $interest_group ) { ?>
162
-											<option value="<?php echo $id; ?>" <?php selected( $pre_selected, $id ); ?>><?php echo $interest_group['name']; ?></option>
161
+										<?php foreach ( $field_data[ 'items' ] as $id => $interest_group ) { ?>
162
+											<option value="<?php echo $id; ?>" <?php selected( $pre_selected, $id ); ?>><?php echo $interest_group[ 'name' ]; ?></option>
163 163
 										<?php } ?>
164 164
 									</select>
165
-									<p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
165
+									<p class="description"><small><?php _e( "Which option should be selected by default?", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
166 166
 								</td>
167 167
 							</tr>
168 168
 
169 169
 							<?php
170 170
 								echo '<pre>';
171
-								$pre_selected = ! empty( $field_data['default_choice'] ) ? $field_data['default_choice'] : 'no-default';
172
-								var_dump($pre_selected);
171
+								$pre_selected = ! empty( $field_data[ 'default_choice' ] ) ? $field_data[ 'default_choice' ] : 'no-default';
172
+								var_dump( $pre_selected );
173 173
 								echo '</pre>';
174 174
 								die;
175 175
 							?>
@@ -182,25 +182,25 @@  discard block
 block discarded – undo
182 182
 					<tr valign="top">
183 183
 						<td scope="row">
184 184
 							<label for="placeholder">
185
-								<?php _e( 'Description' , 'yikes-inc-easy-mailchimp-extender' ); ?>
185
+								<?php _e( 'Description', 'yikes-inc-easy-mailchimp-extender' ); ?>
186 186
 							</label>
187 187
 						</td>
188 188
 						<td>
189
-							<textarea class="widefat field-description-input" name="field[<?php echo $group['group_id']; ?>][description]"></textarea>
190
-							<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>
189
+							<textarea class="widefat field-description-input" name="field[<?php echo $group[ 'group_id' ]; ?>][description]"></textarea>
190
+							<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>
191 191
 						</td>
192 192
 					</tr>
193 193
 
194 194
 					<!-- Description Above Field -->
195 195
 					<tr valign="top" class="yikes-checkbox-container">
196 196
 						<td scope="row">
197
-							<label for="description_above_<?php echo esc_attr( $group['group_id'] ); ?>">
198
-								<?php _e( 'Description Above Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>
197
+							<label for="description_above_<?php echo esc_attr( $group[ 'group_id' ] ); ?>">
198
+								<?php _e( 'Description Above Field', 'yikes-inc-easy-mailchimp-extender' ); ?>
199 199
 							</label>
200 200
 						</td>
201 201
 						<td>
202
-							<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" />
203
-							<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>
202
+							<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" />
203
+							<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>
204 204
 						</td>
205 205
 					</tr>
206 206
 
@@ -208,48 +208,48 @@  discard block
 block discarded – undo
208 208
 					<tr valign="top">
209 209
 						<td scope="row">
210 210
 							<label for="placeholder">
211
-								<?php _e( 'Additional Classes' , 'yikes-inc-easy-mailchimp-extender' ); ?>
211
+								<?php _e( 'Additional Classes', 'yikes-inc-easy-mailchimp-extender' ); ?>
212 212
 							</label>
213 213
 						</td>
214 214
 						<td>
215
-							<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'] ) ) : '' ; ?>" />
216
-							<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>
215
+							<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' ] ) ) : ''; ?>" />
216
+							<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>
217 217
 						</td>
218 218
 						</tr>
219 219
 						<!-- Required Toggle -->
220 220
 						<tr valign="top" class="yikes-checkbox-container">
221 221
 							<td scope="row">
222 222
 								<label for="field-required">
223
-									<?php _e( 'Field Required?' , 'yikes-inc-easy-mailchimp-extender' ); ?>
223
+									<?php _e( 'Field Required?', 'yikes-inc-easy-mailchimp-extender' ); ?>
224 224
 								</label>
225 225
 							</td>
226 226
 							<td>
227
-								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group['group_id']; ?>][require]">
228
-								<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>
227
+								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group[ 'group_id' ]; ?>][require]">
228
+								<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>
229 229
 							</td>
230 230
 						</tr>
231 231
 						<!-- Visible Toggle -->
232 232
 						<tr valign="top" class="yikes-checkbox-container">
233 233
 							<td scope="row">
234 234
 								<label for="hide-field">
235
-									<?php _e( 'Hide Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>
235
+									<?php _e( 'Hide Field', 'yikes-inc-easy-mailchimp-extender' ); ?>
236 236
 								</label>
237 237
 							</td>
238 238
 							<td>
239
-								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group['group_id']; ?>][hide]">
240
-								<p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
239
+								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group[ 'group_id' ]; ?>][hide]">
240
+								<p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
241 241
 							</td>
242 242
 						</tr>
243 243
 						<!-- Toggle Field Label Visibility -->
244 244
 						<tr valign="top" class="yikes-checkbox-container">
245 245
 							<td scope="row">
246 246
 								<label for="placeholder">
247
-									<?php _e( 'Hide Label' , 'yikes-inc-easy-mailchimp-extender' ); ?>
247
+									<?php _e( 'Hide Label', 'yikes-inc-easy-mailchimp-extender' ); ?>
248 248
 								</label>
249 249
 							</td>
250 250
 							<td>
251
-								<input type="checkbox" name="field[<?php echo $group['group_id']; ?>][hide-label]" value="1" />
252
-								<p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
251
+								<input type="checkbox" name="field[<?php echo $group[ 'group_id' ]; ?>][hide-label]" value="1" />
252
+								<p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
253 253
 							</td>
254 254
 						</tr>
255 255
 						<!-- Toggle Buttons -->
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 							</td>
260 260
 							<td>
261 261
 								<span class="toggle-container">
262
-									<a href="#" class="hide-field"><?php _e( "Close" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
263
-									<a href="#" class="remove-field" alt="<?php echo $group['group_id']; ?>"><?php _e( "Remove Field" , 'yikes-inc-easy-mailchimp-extender' ); ?></a>
262
+									<a href="#" class="hide-field"><?php _e( "Close", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
263
+									<a href="#" class="remove-field" alt="<?php echo $group[ 'group_id' ]; ?>"><?php _e( "Remove Field", 'yikes-inc-easy-mailchimp-extender' ); ?></a>
264 264
 								</span>
265 265
 							</td>
266 266
 						</tr>
Please login to merge, or discard this patch.