Passed
Push — master ( 3b0158...93685b )
by Warwick
02:41
created
classes/class-settings.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 			'height'                             => '600',
59 59
 			'scaling'                            => 'h',
60 60
 		);
61
-		$this->fields   = array_keys( $this->defaults );
62
-		add_action( 'admin_init', array( $this, 'save_options' ) );
61
+		$this->fields = array_keys($this->defaults);
62
+		add_action('admin_init', array($this, 'save_options'));
63 63
 	}
64 64
 
65 65
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public static function get_instance() {
71 71
 		// If the single instance hasn't been set, set it now.
72
-		if ( ! isset( self::$instance ) ) {
72
+		if (!isset(self::$instance)) {
73 73
 			self::$instance = new self();
74 74
 		}
75 75
 		return self::$instance;
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function display_page() {
82 82
 		$options = \lsx_wetu_importer\includes\helpers\get_options();
83
-		foreach ( $options as $key => $value ) {
84
-			$value = trim( $value );
83
+		foreach ($options as $key => $value) {
84
+			$value = trim($value);
85 85
 		}
86
-		$options = wp_parse_args( $options, $this->defaults );
86
+		$options = wp_parse_args($options, $this->defaults);
87 87
 		?>
88 88
 		<div class="wrap">
89 89
 			<form method="post" class="">
90
-				<?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?>
91
-				<h1><?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></h1>
90
+				<?php wp_nonce_field('lsx_wetu_importer_save', 'lsx_wetu_importer_save_options'); ?>
91
+				<h1><?php esc_html_e('General', 'lsx-wetu-importer'); ?></h1>
92 92
 				<table class="form-table">
93 93
 					<tbody>
94 94
 						<tr class="form-field">
95 95
 							<th scope="row">
96
-								<label for="wetu_api_key"> <?php esc_html_e( 'API Key', 'lsx-wetu-importer' ); ?></label>
96
+								<label for="wetu_api_key"> <?php esc_html_e('API Key', 'lsx-wetu-importer'); ?></label>
97 97
 							</th>
98 98
 							<td>
99 99
 								<input type="text" value="
100 100
 								<?php
101
-								if ( isset( $options['api_key'] ) ) {
102
-									echo esc_attr( $options['api_key'] );
101
+								if (isset($options['api_key'])) {
102
+									echo esc_attr($options['api_key']);
103 103
 								}
104 104
 								?>
105 105
 								" name="api_key" />
@@ -107,96 +107,96 @@  discard block
 block discarded – undo
107 107
 						</tr>
108 108
 						<tr class="form-field -wrap">
109 109
 							<th scope="row">
110
-								<label for="disable_tour_descriptions"><?php esc_html_e( 'Disable Tour Descriptions', 'lsx-wetu-importer' ); ?></label>
110
+								<label for="disable_tour_descriptions"><?php esc_html_e('Disable Tour Descriptions', 'lsx-wetu-importer'); ?></label>
111 111
 							</th>
112 112
 							<td>
113 113
 								<input type="checkbox"
114 114
 								<?php
115
-								if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
116
-									echo esc_attr( 'checked="checked"' );
115
+								if (isset($options['disable_tour_descriptions']) && '' !== $options['disable_tour_descriptions']) {
116
+									echo esc_attr('checked="checked"');
117 117
 								}
118 118
 								?>
119 119
 								name="disable_tour_descriptions" />
120 120
 
121
-								<small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small>
121
+								<small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small>
122 122
 							</td>
123 123
 						</tr>
124 124
 						<tr class="form-field -wrap">
125 125
 							<th scope="row">
126
-								<label for="disable_accommodation_descriptions"><?php esc_html_e( 'Disable Accommodation Descriptions', 'lsx-wetu-importer' ); ?></label>
126
+								<label for="disable_accommodation_descriptions"><?php esc_html_e('Disable Accommodation Descriptions', 'lsx-wetu-importer'); ?></label>
127 127
 							</th>
128 128
 							<td>
129 129
 								<input type="checkbox"
130 130
 								<?php
131
-								if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
132
-									echo esc_attr( 'checked="checked"' );
131
+								if (isset($options['disable_accommodation_descriptions']) && '' !== $options['disable_accommodation_descriptions']) {
132
+									echo esc_attr('checked="checked"');
133 133
 								}
134 134
 								?>
135 135
 								name="disable_accommodation_descriptions" />
136
-								<small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small>
136
+								<small><?php esc_html_e('If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer'); ?></small>
137 137
 							</td>
138 138
 						</tr>
139 139
 						<tr class="form-field -wrap">
140 140
 							<th scope="row">
141
-								<label for="disable_accommodation_excerpts"><?php esc_html_e( 'Disable Accommodation Excerpts', 'lsx-wetu-importer' ); ?></label>
141
+								<label for="disable_accommodation_excerpts"><?php esc_html_e('Disable Accommodation Excerpts', 'lsx-wetu-importer'); ?></label>
142 142
 							</th>
143 143
 							<td>
144 144
 								<input type="checkbox"
145 145
 								<?php
146
-								if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
147
-									echo esc_attr( 'checked="checked"' );
146
+								if (isset($options['disable_accommodation_excerpts']) && '' !== $options['disable_accommodation_excerpts']) {
147
+									echo esc_attr('checked="checked"');
148 148
 								}
149 149
 								?>
150 150
 								name="disable_accommodation_excerpts" />
151
-								<small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small>
151
+								<small><?php esc_html_e('If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer'); ?></small>
152 152
 							</td>
153 153
 						</tr>
154 154
 						<tr class="form-field -wrap">
155 155
 							<th scope="row">
156
-								<label for="disable_destination_descriptions"><?php esc_html_e( 'Disable Destinations Descriptions', 'lsx-wetu-importer' ); ?></label>
156
+								<label for="disable_destination_descriptions"><?php esc_html_e('Disable Destinations Descriptions', 'lsx-wetu-importer'); ?></label>
157 157
 							</th>
158 158
 							<td>
159 159
 								<input type="checkbox"
160 160
 								<?php
161
-								if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
162
-									echo esc_attr( 'checked="checked"' );
161
+								if (isset($options['disable_destination_descriptions']) && '' !== $options['disable_destination_descriptions']) {
162
+									echo esc_attr('checked="checked"');
163 163
 								}
164 164
 								?>
165 165
 								name="disable_destination_descriptions" />
166
-								<small><?php esc_html_e( 'If you are going to edit the destination descriptions on this site then enable this setting.', 'lsx-wetu-importer' ); ?></small>
166
+								<small><?php esc_html_e('If you are going to edit the destination descriptions on this site then enable this setting.', 'lsx-wetu-importer'); ?></small>
167 167
 							</td>
168 168
 						</tr>					
169 169
 					</tbody>
170 170
 				</table>
171 171
 
172
-				<h1><?php esc_html_e( 'Images', 'lsx-wetu-importer' ); ?></h1>
172
+				<h1><?php esc_html_e('Images', 'lsx-wetu-importer'); ?></h1>
173 173
 
174 174
 				<table class="form-table">
175 175
 					<tbody>
176 176
 						<tr class="form-field -wrap">
177 177
 							<th scope="row">
178
-								<label for="image_replacing"><?php esc_html_e( 'Replace Images', 'lsx-wetu-importer' ); ?></label>
178
+								<label for="image_replacing"><?php esc_html_e('Replace Images', 'lsx-wetu-importer'); ?></label>
179 179
 							</th>
180 180
 							<td>
181 181
 								<input type="checkbox"
182 182
 								<?php
183
-								if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
184
-									echo esc_attr( 'checked="checked"' );
183
+								if (isset($options['image_replacing']) && '' !== $options['image_replacing']) {
184
+									echo esc_attr('checked="checked"');
185 185
 								}
186 186
 								?>
187 187
 								name="image_replacing" />
188
-								<p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p>
188
+								<p><?php esc_html_e('Do you want your images to be replaced on each import.', 'lsx-wetu-importer'); ?></p>
189 189
 							</td>
190 190
 						</tr>
191 191
 						<tr class="form-field -wrap">
192 192
 							<th scope="row">
193
-								<label for="image_limit"> <?php esc_html_e( 'Limit the amount of images imported to the gallery', 'lsx-wetu-importer' ); ?></label>
193
+								<label for="image_limit"> <?php esc_html_e('Limit the amount of images imported to the gallery', 'lsx-wetu-importer'); ?></label>
194 194
 							</th>
195 195
 							<td>
196 196
 								<input placeholder="" type="text" value="
197 197
 								<?php
198
-								if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
199
-									echo esc_attr( $options['image_limit'] );
198
+								if (isset($options['image_limit']) && '' !== $options['image_limit']) {
199
+									echo esc_attr($options['image_limit']);
200 200
 								}
201 201
 								?>
202 202
 								"
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
 
207 207
 						<tr class="form-field -wrap">
208 208
 							<th scope="row">
209
-								<label for="image_scaling"><?php esc_html_e( 'Enable Image Scaling', 'lsx-wetu-importer' ); ?></label>
209
+								<label for="image_scaling"><?php esc_html_e('Enable Image Scaling', 'lsx-wetu-importer'); ?></label>
210 210
 							</th>
211 211
 							<td>
212 212
 								<input type="checkbox"
213 213
 								<?php
214
-								if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
215
-									echo esc_attr( 'checked="checked"' );
214
+								if (isset($options['image_scaling']) && '' !== $options['image_scaling']) {
215
+									echo esc_attr('checked="checked"');
216 216
 								}
217 217
 								?>
218 218
 								name="image_scaling" />
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 						</tr>
221 221
 						<tr class="form-field -wrap">
222 222
 							<th scope="row">
223
-								<label for="width"> <?php esc_html_e( 'Width (px)', 'lsx-wetu-importer' ); ?></label>
223
+								<label for="width"> <?php esc_html_e('Width (px)', 'lsx-wetu-importer'); ?></label>
224 224
 							</th>
225 225
 							<td>
226 226
 								<input placeholder="800" type="text" value="
227 227
 								<?php
228
-								if ( isset( $options['width'] ) && '' !== $options['width'] ) {
229
-									echo esc_attr( $options['width'] );
228
+								if (isset($options['width']) && '' !== $options['width']) {
229
+									echo esc_attr($options['width']);
230 230
 								}
231 231
 								?>
232 232
 								"
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 						</tr>
236 236
 						<tr class="form-field -wrap">
237 237
 							<th scope="row">
238
-								<label for="height"> <?php esc_html_e( 'Height (px)', 'lsx-wetu-importer' ); ?></label>
238
+								<label for="height"> <?php esc_html_e('Height (px)', 'lsx-wetu-importer'); ?></label>
239 239
 							</th>
240 240
 							<td>
241 241
 								<input placeholder="600" type="text" value="
242 242
 								<?php
243
-								if ( isset( $options['height'] ) && '' !== $options['height'] ) {
244
-									echo esc_attr( $options['height'] );
243
+								if (isset($options['height']) && '' !== $options['height']) {
244
+									echo esc_attr($options['height']);
245 245
 								}
246 246
 								?>
247 247
 								"
@@ -251,63 +251,63 @@  discard block
 block discarded – undo
251 251
 
252 252
 						<tr class="form-field -wrap">
253 253
 							<th scope="row">
254
-								<label for="scaling"> <?php esc_html_e( 'Scaling', 'lsx-wetu-importer' ); ?></label>
254
+								<label for="scaling"> <?php esc_html_e('Scaling', 'lsx-wetu-importer'); ?></label>
255 255
 							</th>
256 256
 							<td>
257 257
 								<input type="radio"
258 258
 								<?php
259
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
260
-									echo esc_attr( 'checked="checked"' );
259
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'raw' === $options['scaling']) {
260
+									echo esc_attr('checked="checked"');
261 261
 								}
262 262
 								?>
263
-								name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br />
263
+								name="scaling" value="raw" /> <?php esc_html_e('Get the Full size image, no cropping takes place.', 'lsx-wetu-importer'); ?><br />
264 264
 								<input type="radio"
265 265
 								<?php
266
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
267
-									echo esc_attr( 'checked="checked"' );
266
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'c' === $options['scaling']) {
267
+									echo esc_attr('checked="checked"');
268 268
 								}
269 269
 								?>
270
-								name="scaling"  value="c" /> <?php esc_html_e( 'Crop image to fit fully into the frame, Crop is taken from middle, preserving as much of the image as possible.', 'lsx-wetu-importer' ); ?><br />
270
+								name="scaling"  value="c" /> <?php esc_html_e('Crop image to fit fully into the frame, Crop is taken from middle, preserving as much of the image as possible.', 'lsx-wetu-importer'); ?><br />
271 271
 								<input type="radio"
272 272
 								<?php
273
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
274
-									echo esc_attr( 'checked="checked"' );
273
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'h' === $options['scaling']) {
274
+									echo esc_attr('checked="checked"');
275 275
 								}
276 276
 								?>
277
-								name="scaling"  value="h" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to height first, then crop on width if needed', 'lsx-wetu-importer' ); ?><br />
277
+								name="scaling"  value="h" /> <?php esc_html_e('Crop image to fit fully into the frame, but resize to height first, then crop on width if needed', 'lsx-wetu-importer'); ?><br />
278 278
 								<input type="radio"
279 279
 								<?php
280
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
281
-									echo esc_attr( 'checked="checked"' );
280
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'w' === $options['scaling']) {
281
+									echo esc_attr('checked="checked"');
282 282
 								}
283 283
 								?>
284
-								name="scaling"  value="w" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to width first, then crop on height if needed', 'lsx-wetu-importer' ); ?><br />
284
+								name="scaling"  value="w" /> <?php esc_html_e('Crop image to fit fully into the frame, but resize to width first, then crop on height if needed', 'lsx-wetu-importer'); ?><br />
285 285
 								<input type="radio"
286 286
 								<?php
287
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
288
-									echo esc_attr( 'checked="checked"' );
287
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'nf' === $options['scaling']) {
288
+									echo esc_attr('checked="checked"');
289 289
 								}
290 290
 								?>
291
-								name="scaling"  value="nf" /> <?php esc_html_e( 'Resize the image to fit within the frame. but pad the image with white to ensure the resolution matches the frame', 'lsx-wetu-importer' ); ?><br />
291
+								name="scaling"  value="nf" /> <?php esc_html_e('Resize the image to fit within the frame. but pad the image with white to ensure the resolution matches the frame', 'lsx-wetu-importer'); ?><br />
292 292
 								<input type="radio"
293 293
 								<?php
294
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
295
-									echo esc_attr( 'checked="checked"' );
294
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'n' === $options['scaling']) {
295
+									echo esc_attr('checked="checked"');
296 296
 								}
297 297
 								?>
298
-								name="scaling"  value="n" /> <?php esc_html_e( 'Resize the image to fit within the frame. but do not upscale the image.', 'lsx-wetu-importer' ); ?><br />
298
+								name="scaling"  value="n" /> <?php esc_html_e('Resize the image to fit within the frame. but do not upscale the image.', 'lsx-wetu-importer'); ?><br />
299 299
 								<input type="radio"
300 300
 								<?php
301
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
302
-									echo esc_attr( 'checked="checked"' );
301
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'W' === $options['scaling']) {
302
+									echo esc_attr('checked="checked"');
303 303
 								}
304 304
 								?>
305
-								name="scaling"  value="W" /> <?php esc_html_e( 'Resize the image to fit within the frame. Image will not exceed specified dimensions', 'lsx-wetu-importer' ); ?>
305
+								name="scaling"  value="W" /> <?php esc_html_e('Resize the image to fit within the frame. Image will not exceed specified dimensions', 'lsx-wetu-importer'); ?>
306 306
 							</td>
307 307
 						</tr>
308 308
 					</tbody>
309 309
 				</table>
310
-				<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_html_e( 'Save Changes', 'lsx-wetu-importer' ); ?>"></p>
310
+				<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_html_e('Save Changes', 'lsx-wetu-importer'); ?>"></p>
311 311
 			</form>
312 312
 		</div>
313 313
 		<?php
@@ -319,17 +319,17 @@  discard block
 block discarded – undo
319 319
 	 * @return void
320 320
 	 */
321 321
 	public function save_options() {
322
-		if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
322
+		if (!isset($_POST['lsx_wetu_importer_save_options']) || !wp_verify_nonce($_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save')) {
323 323
 			return;
324 324
 		}
325 325
 		$data_to_save = array();
326
-		foreach ( $this->defaults as $key => $field ) {
327
-			if ( isset( $_POST[ $key ] ) ) {
328
-				$data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] );
329
-			} else {
330
-				$data_to_save[ $key ] = '';
326
+		foreach ($this->defaults as $key => $field) {
327
+			if (isset($_POST[$key])) {
328
+				$data_to_save[$key] = sanitize_text_field($_POST[$key]);
329
+			}else {
330
+				$data_to_save[$key] = '';
331 331
 			}
332 332
 		}
333
-		update_option( 'lsx_wetu_importer_settings', $data_to_save );
333
+		update_option('lsx_wetu_importer_settings', $data_to_save);
334 334
 	}
335 335
 }
Please login to merge, or discard this patch.