Completed
Pull Request — staging (#840)
by
unknown
17:30
created
admin/partials/ajax/add_interest_group_to_form.php 1 patch
Spacing   +55 added lines, -55 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,31 +138,31 @@  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
 
@@ -174,25 +174,25 @@  discard block
 block discarded – undo
174 174
 					<tr valign="top">
175 175
 						<td scope="row">
176 176
 							<label for="placeholder">
177
-								<?php _e( 'Description' , 'yikes-inc-easy-mailchimp-extender' ); ?>
177
+								<?php _e( 'Description', 'yikes-inc-easy-mailchimp-extender' ); ?>
178 178
 							</label>
179 179
 						</td>
180 180
 						<td>
181
-							<textarea class="widefat field-description-input" name="field[<?php echo $group['group_id']; ?>][description]"></textarea>
182
-							<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>
181
+							<textarea class="widefat field-description-input" name="field[<?php echo $group[ 'group_id' ]; ?>][description]"></textarea>
182
+							<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 183
 						</td>
184 184
 					</tr>
185 185
 
186 186
 					<!-- Description Above Field -->
187 187
 					<tr valign="top" class="yikes-checkbox-container">
188 188
 						<td scope="row">
189
-							<label for="description_above_<?php echo esc_attr( $group['group_id'] ); ?>">
190
-								<?php _e( 'Description Above Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>
189
+							<label for="description_above_<?php echo esc_attr( $group[ 'group_id' ] ); ?>">
190
+								<?php _e( 'Description Above Field', 'yikes-inc-easy-mailchimp-extender' ); ?>
191 191
 							</label>
192 192
 						</td>
193 193
 						<td>
194
-							<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" />
195
-							<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>
194
+							<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" />
195
+							<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 196
 						</td>
197 197
 					</tr>
198 198
 
@@ -200,48 +200,48 @@  discard block
 block discarded – undo
200 200
 					<tr valign="top">
201 201
 						<td scope="row">
202 202
 							<label for="placeholder">
203
-								<?php _e( 'Additional Classes' , 'yikes-inc-easy-mailchimp-extender' ); ?>
203
+								<?php _e( 'Additional Classes', 'yikes-inc-easy-mailchimp-extender' ); ?>
204 204
 							</label>
205 205
 						</td>
206 206
 						<td>
207
-							<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'] ) ) : '' ; ?>" />
208
-							<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>
207
+							<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' ] ) ) : ''; ?>" />
208
+							<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 209
 						</td>
210 210
 						</tr>
211 211
 						<!-- Required Toggle -->
212 212
 						<tr valign="top" class="yikes-checkbox-container">
213 213
 							<td scope="row">
214 214
 								<label for="field-required">
215
-									<?php _e( 'Field Required?' , 'yikes-inc-easy-mailchimp-extender' ); ?>
215
+									<?php _e( 'Field Required?', 'yikes-inc-easy-mailchimp-extender' ); ?>
216 216
 								</label>
217 217
 							</td>
218 218
 							<td>
219
-								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group['group_id']; ?>][require]">
220
-								<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>
219
+								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group[ 'group_id' ]; ?>][require]">
220
+								<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 221
 							</td>
222 222
 						</tr>
223 223
 						<!-- Visible Toggle -->
224 224
 						<tr valign="top" class="yikes-checkbox-container">
225 225
 							<td scope="row">
226 226
 								<label for="hide-field">
227
-									<?php _e( 'Hide Field' , 'yikes-inc-easy-mailchimp-extender' ); ?>
227
+									<?php _e( 'Hide Field', 'yikes-inc-easy-mailchimp-extender' ); ?>
228 228
 								</label>
229 229
 							</td>
230 230
 							<td>
231
-								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group['group_id']; ?>][hide]">
232
-								<p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
231
+								<input type="checkbox" class="widefat" value="1" name="field[<?php echo $group[ 'group_id' ]; ?>][hide]">
232
+								<p class="description"><small><?php _e( "Hide this field from being displayed on the front end.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
233 233
 							</td>
234 234
 						</tr>
235 235
 						<!-- Toggle Field Label Visibility -->
236 236
 						<tr valign="top" class="yikes-checkbox-container">
237 237
 							<td scope="row">
238 238
 								<label for="placeholder">
239
-									<?php _e( 'Hide Label' , 'yikes-inc-easy-mailchimp-extender' ); ?>
239
+									<?php _e( 'Hide Label', 'yikes-inc-easy-mailchimp-extender' ); ?>
240 240
 								</label>
241 241
 							</td>
242 242
 							<td>
243
-								<input type="checkbox" name="field[<?php echo $group['group_id']; ?>][hide-label]" value="1" />
244
-								<p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' );?></small></p>
243
+								<input type="checkbox" name="field[<?php echo $group[ 'group_id' ]; ?>][hide-label]" value="1" />
244
+								<p class="description"><small><?php _e( "Toggle field label visibility.", 'yikes-inc-easy-mailchimp-extender' ); ?></small></p>
245 245
 							</td>
246 246
 						</tr>
247 247
 						<!-- Toggle Buttons -->
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 							</td>
252 252
 							<td>
253 253
 								<span class="toggle-container">
254
-									<a href="#" class="hide-field"><?php _e( "Close" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
255
-									<a href="#" class="remove-field" alt="<?php echo $group['group_id']; ?>"><?php _e( "Remove Field" , 'yikes-inc-easy-mailchimp-extender' ); ?></a>
254
+									<a href="#" class="hide-field"><?php _e( "Close", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
255
+									<a href="#" class="remove-field" alt="<?php echo $group[ 'group_id' ]; ?>"><?php _e( "Remove Field", 'yikes-inc-easy-mailchimp-extender' ); ?></a>
256 256
 								</span>
257 257
 							</td>
258 258
 						</tr>
Please login to merge, or discard this patch.