Passed
Push — master ( 6f8b88...9b072c )
by Warwick
03:24 queued 12s
created
classes/class-lsx-wetu-importer-settings.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -14,85 +14,85 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class LSX_WETU_Importer_Settings {
16 16
 
17
-	/**
18
-	 * Holds instance of the class
19
-	 *
20
-	 * @var object
21
-	 */
22
-	private static $instance;
17
+     /**
18
+      * Holds instance of the class
19
+      *
20
+      * @var object
21
+      */
22
+     private static $instance;
23 23
 
24
-	/**
25
-	 * Holds the default settings.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	public $defaults = array();
24
+     /**
25
+      * Holds the default settings.
26
+      *
27
+      * @var array
28
+      */
29
+     public $defaults = array();
30 30
 
31
-	/**
32
-	 * Holds the settings fields available.
33
-	 *
34
-	 * @var array
35
-	 */
36
-	public $fields = array();
31
+     /**
32
+      * Holds the settings fields available.
33
+      *
34
+      * @var array
35
+      */
36
+     public $fields = array();
37 37
 
38
-	/**
39
-	 * Initialize the plugin by setting localization, filters, and administration functions.
40
-	 *
41
-	 * @since 1.0.0
42
-	 *
43
-	 * @access private
44
-	 */
45
-	public function __construct() {
46
-		$this->defaults = array(
47
-			'api_key'                            => '',
48
-			'disable_tour_title'                 => '',
49
-			'disable_tour_descriptions'          => '',
50
-			'disable_tour_tags'                  => 'on',
51
-			'enable_tour_featured_random'        => '',
52
-			'disable_accommodation_title'        => '',
53
-			'disable_accommodation_descriptions' => '',
54
-			'disable_accommodation_filtering'    => '',
55
-			'disable_accommodation_excerpts'     => '',
56
-			'disable_destination_title'          => '',
57
-			'disable_destination_descriptions'   => '',
58
-			'image_replacing'                    => 'on',
59
-			'image_limit'                        => '15',
60
-			'image_scaling'                      => 'on',
61
-			'width'                              => '800',
62
-			'height'                             => '600',
63
-			'scaling'                            => 'h',
64
-			'enable_tour_ref_column'             => '',
65
-			'cron_schedule'                      => 'daily',
66
-			'accommodation_images_cron'          => '',
67
-			'accommodation_images_cron_featured' => '',
68
-		);
69
-		$this->fields   = array_keys( $this->defaults );
70
-		add_action( 'admin_init', array( $this, 'save_options' ) );
71
-	}
38
+     /**
39
+      * Initialize the plugin by setting localization, filters, and administration functions.
40
+      *
41
+      * @since 1.0.0
42
+      *
43
+      * @access private
44
+      */
45
+     public function __construct() {
46
+          $this->defaults = array(
47
+               'api_key'                            => '',
48
+               'disable_tour_title'                 => '',
49
+               'disable_tour_descriptions'          => '',
50
+               'disable_tour_tags'                  => 'on',
51
+               'enable_tour_featured_random'        => '',
52
+               'disable_accommodation_title'        => '',
53
+               'disable_accommodation_descriptions' => '',
54
+               'disable_accommodation_filtering'    => '',
55
+               'disable_accommodation_excerpts'     => '',
56
+               'disable_destination_title'          => '',
57
+               'disable_destination_descriptions'   => '',
58
+               'image_replacing'                    => 'on',
59
+               'image_limit'                        => '15',
60
+               'image_scaling'                      => 'on',
61
+               'width'                              => '800',
62
+               'height'                             => '600',
63
+               'scaling'                            => 'h',
64
+               'enable_tour_ref_column'             => '',
65
+               'cron_schedule'                      => 'daily',
66
+               'accommodation_images_cron'          => '',
67
+               'accommodation_images_cron_featured' => '',
68
+          );
69
+          $this->fields   = array_keys( $this->defaults );
70
+          add_action( 'admin_init', array( $this, 'save_options' ) );
71
+     }
72 72
 
73
-	/**
74
-	 * Return an instance of this class.
75
-	 *
76
-	 * @return  object
77
-	 */
78
-	public static function get_instance() {
79
-		// If the single instance hasn't been set, set it now.
80
-		if ( ! isset( self::$instance ) ) {
81
-			self::$instance = new self();
82
-		}
83
-		return self::$instance;
84
-	}
73
+     /**
74
+      * Return an instance of this class.
75
+      *
76
+      * @return  object
77
+      */
78
+     public static function get_instance() {
79
+          // If the single instance hasn't been set, set it now.
80
+          if ( ! isset( self::$instance ) ) {
81
+               self::$instance = new self();
82
+          }
83
+          return self::$instance;
84
+     }
85 85
 
86
-	/**
87
-	 * Display the importer welcome screen
88
-	 */
89
-	public function display_page() {
90
-		$options = lsx_wetu_get_options();
91
-		foreach ( $options as $key => $value ) {
92
-			$value = trim( $value );
93
-		}
94
-		$options = wp_parse_args( $options, $this->defaults );
95
-		?>
86
+     /**
87
+      * Display the importer welcome screen
88
+      */
89
+     public function display_page() {
90
+          $options = lsx_wetu_get_options();
91
+          foreach ( $options as $key => $value ) {
92
+               $value = trim( $value );
93
+          }
94
+          $options = wp_parse_args( $options, $this->defaults );
95
+          ?>
96 96
 		<div class="wrap">
97 97
 			<form method="post" class="">
98 98
 				<?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?>
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 							<td>
108 108
 								<input data-toggle="tooltip" data-placement="top" title="The API key can be found on your My Account page of your WETU account." type="text" value="
109 109
                                 <?php
110
-								if ( isset( $options['api_key'] ) ) {
111
-									echo esc_attr( $options['api_key'] );
112
-								}
113
-								?>
110
+                                        if ( isset( $options['api_key'] ) ) {
111
+                                             echo esc_attr( $options['api_key'] );
112
+                                        }
113
+                                        ?>
114 114
                                 " name="api_key" />
115 115
 							</td>
116 116
 						</tr>
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 							<td>
128 128
 								<input type="checkbox"
129 129
 								<?php
130
-								if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) {
131
-									echo esc_attr( 'checked="checked"' );
132
-								}
133
-								?>
130
+                                        if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) {
131
+                                             echo esc_attr( 'checked="checked"' );
132
+                                        }
133
+                                        ?>
134 134
 								name="disable_tour_title" />
135 135
 
136 136
 								<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>
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 							<td>
144 144
 								<input type="checkbox"
145 145
 								<?php
146
-								if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
147
-									echo esc_attr( 'checked="checked"' );
148
-								}
149
-								?>
146
+                                        if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
147
+                                             echo esc_attr( 'checked="checked"' );
148
+                                        }
149
+                                        ?>
150 150
 								name="disable_tour_descriptions" />
151 151
 
152 152
 								<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>
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 							<td>
160 160
 								<input type="checkbox"
161 161
 								<?php
162
-								if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) {
163
-									echo esc_attr( 'checked="checked"' );
164
-								}
165
-								?>
162
+                                        if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) {
163
+                                             echo esc_attr( 'checked="checked"' );
164
+                                        }
165
+                                        ?>
166 166
 								name="disable_tour_tags" />
167 167
 
168 168
 								<small><?php esc_html_e( 'Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer' ); ?></small>
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 							<td>
177 177
 								<input type="checkbox"
178 178
 								<?php
179
-								if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) {
180
-									echo esc_attr( 'checked="checked"' );
181
-								}
182
-								?>
179
+                                        if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) {
180
+                                             echo esc_attr( 'checked="checked"' );
181
+                                        }
182
+                                        ?>
183 183
 								name="enable_tour_ref_column" />
184 184
 								<small><?php esc_html_e( 'Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer' ); ?></small>
185 185
 							</td>
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
 							<td>
193 193
 								<input type="checkbox"
194 194
 								<?php
195
-								if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) {
196
-									echo esc_attr( 'checked="checked"' );
197
-								}
198
-								?>
195
+                                        if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) {
196
+                                             echo esc_attr( 'checked="checked"' );
197
+                                        }
198
+                                        ?>
199 199
 								name="enable_tour_featured_random" />
200 200
 								<small><?php esc_html_e( 'This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer' ); ?></small>
201 201
 							</td>
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
 							<td>
215 215
 								<input type="checkbox"
216 216
 								<?php
217
-								if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) {
218
-									echo esc_attr( 'checked="checked"' );
219
-								}
220
-								?>
217
+                                        if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) {
218
+                                             echo esc_attr( 'checked="checked"' );
219
+                                        }
220
+                                        ?>
221 221
 								name="disable_accommodation_title" />
222 222
 
223 223
 								<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>
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 							<td>
231 231
 								<input type="checkbox"
232 232
 								<?php
233
-								if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
234
-									echo esc_attr( 'checked="checked"' );
235
-								}
236
-								?>
233
+                                        if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
234
+                                             echo esc_attr( 'checked="checked"' );
235
+                                        }
236
+                                        ?>
237 237
 								name="disable_accommodation_descriptions" />
238 238
 								<small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small>
239 239
 							</td>
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 							<td>
246 246
 								<input type="checkbox"
247 247
 								<?php
248
-								if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) {
249
-									echo esc_attr( 'checked="checked"' );
250
-								}
251
-								?>
248
+                                        if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) {
249
+                                             echo esc_attr( 'checked="checked"' );
250
+                                        }
251
+                                        ?>
252 252
 								name="disable_accommodation_filtering" />
253 253
 								<small><?php esc_html_e( 'This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer' ); ?></small>
254 254
 							</td>
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 							<td>
262 262
 								<input type="checkbox"
263 263
 								<?php
264
-								if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
265
-									echo esc_attr( 'checked="checked"' );
266
-								}
267
-								?>
264
+                                        if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
265
+                                             echo esc_attr( 'checked="checked"' );
266
+                                        }
267
+                                        ?>
268 268
 								name="disable_accommodation_excerpts" />
269 269
 								<small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small>
270 270
 							</td>
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 							<td>
284 284
 								<input type="checkbox"
285 285
 								<?php
286
-								if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) {
287
-									echo esc_attr( 'checked="checked"' );
288
-								}
289
-								?>
286
+                                        if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) {
287
+                                             echo esc_attr( 'checked="checked"' );
288
+                                        }
289
+                                        ?>
290 290
 								name="disable_destination_title" />
291 291
 
292 292
 								<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>
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 							<td>
300 300
 								<input type="checkbox"
301 301
 								<?php
302
-								if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
303
-									echo esc_attr( 'checked="checked"' );
304
-								}
305
-								?>
302
+                                        if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
303
+                                             echo esc_attr( 'checked="checked"' );
304
+                                        }
305
+                                        ?>
306 306
 								name="disable_destination_descriptions" />
307 307
 								<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>
308 308
 							</td>
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 							<td>
322 322
 								<input type="checkbox"
323 323
 								<?php
324
-								if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
325
-									echo esc_attr( 'checked="checked"' );
326
-								}
327
-								?>
324
+                                        if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
325
+                                             echo esc_attr( 'checked="checked"' );
326
+                                        }
327
+                                        ?>
328 328
 								name="image_replacing" />
329 329
 								<p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p>
330 330
 							</td>
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
 							<td>
337 337
 								<input placeholder="" type="text" value="
338 338
                                 <?php
339
-								if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
340
-									echo esc_attr( $options['image_limit'] );
341
-								}
342
-								?>
339
+                                        if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
340
+                                             echo esc_attr( $options['image_limit'] );
341
+                                        }
342
+                                        ?>
343 343
                                 "
344 344
 								name="image_limit" />
345 345
 							</td>
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 							<td>
353 353
 								<input type="checkbox"
354 354
 								<?php
355
-								if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
356
-									echo esc_attr( 'checked="checked"' );
357
-								}
358
-								?>
355
+                                        if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
356
+                                             echo esc_attr( 'checked="checked"' );
357
+                                        }
358
+                                        ?>
359 359
 								name="image_scaling" />
360 360
 							</td>
361 361
 						</tr>
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 							<td>
367 367
 								<input placeholder="800" type="text" value="
368 368
                                 <?php
369
-								if ( isset( $options['width'] ) && '' !== $options['width'] ) {
370
-									echo esc_attr( $options['width'] );
371
-								}
372
-								?>
369
+                                        if ( isset( $options['width'] ) && '' !== $options['width'] ) {
370
+                                             echo esc_attr( $options['width'] );
371
+                                        }
372
+                                        ?>
373 373
                                 "
374 374
 								name="width" />
375 375
 							</td>
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
 							<td>
382 382
 								<input placeholder="600" type="text" value="
383 383
                                 <?php
384
-								if ( isset( $options['height'] ) && '' !== $options['height'] ) {
385
-									echo esc_attr( $options['height'] );
386
-								}
387
-								?>
384
+                                        if ( isset( $options['height'] ) && '' !== $options['height'] ) {
385
+                                             echo esc_attr( $options['height'] );
386
+                                        }
387
+                                        ?>
388 388
                                 "
389 389
 								name="height" />
390 390
 							</td>
@@ -397,52 +397,52 @@  discard block
 block discarded – undo
397 397
 							<td>
398 398
 								<input type="radio"
399 399
 								<?php
400
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
401
-									echo esc_attr( 'checked="checked"' );
402
-								}
403
-								?>
400
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
401
+                                             echo esc_attr( 'checked="checked"' );
402
+                                        }
403
+                                        ?>
404 404
 								name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br />
405 405
 								<input type="radio"
406 406
 								<?php
407
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
408
-									echo esc_attr( 'checked="checked"' );
409
-								}
410
-								?>
407
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
408
+                                             echo esc_attr( 'checked="checked"' );
409
+                                        }
410
+                                        ?>
411 411
 								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 />
412 412
 								<input type="radio"
413 413
 								<?php
414
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
415
-									echo esc_attr( 'checked="checked"' );
416
-								}
417
-								?>
414
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
415
+                                             echo esc_attr( 'checked="checked"' );
416
+                                        }
417
+                                        ?>
418 418
 								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 />
419 419
 								<input type="radio"
420 420
 								<?php
421
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
422
-									echo esc_attr( 'checked="checked"' );
423
-								}
424
-								?>
421
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
422
+                                             echo esc_attr( 'checked="checked"' );
423
+                                        }
424
+                                        ?>
425 425
 								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 />
426 426
 								<input type="radio"
427 427
 								<?php
428
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
429
-									echo esc_attr( 'checked="checked"' );
430
-								}
431
-								?>
428
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
429
+                                             echo esc_attr( 'checked="checked"' );
430
+                                        }
431
+                                        ?>
432 432
 								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 />
433 433
 								<input type="radio"
434 434
 								<?php
435
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
436
-									echo esc_attr( 'checked="checked"' );
437
-								}
438
-								?>
435
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
436
+                                             echo esc_attr( 'checked="checked"' );
437
+                                        }
438
+                                        ?>
439 439
 								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 />
440 440
 								<input type="radio"
441 441
 								<?php
442
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
443
-									echo esc_attr( 'checked="checked"' );
444
-								}
445
-								?>
442
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
443
+                                             echo esc_attr( 'checked="checked"' );
444
+                                        }
445
+                                        ?>
446 446
 								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' ); ?>
447 447
 							</td>
448 448
 						</tr>
@@ -460,28 +460,28 @@  discard block
 block discarded – undo
460 460
 							<td>
461 461
 								<select name="cron_schedule" id="cron_schedule"	class="widefat layout">
462 462
 									<?php
463
-									if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) {
464
-										$schedule = $options['cron_schedule'];
465
-									} else {
466
-										$schedule = 'daily';
467
-									}
468
-									$timeslots = array(
469
-										'daily'      => __( 'Daily', 'lsx-wetu-importer' ),
470
-										'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ),
471
-										'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ),
472
-										'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ),
473
-										'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ),
474
-										'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ),
475
-										'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ),
476
-										'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ),
477
-									);
478
-									foreach ( $timeslots as $key => $name ) {
479
-										$selected = ( $schedule == $key ) ? ' selected="selected"' : '';
480
-										?>
463
+                                             if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) {
464
+                                                  $schedule = $options['cron_schedule'];
465
+                                             } else {
466
+                                                  $schedule = 'daily';
467
+                                             }
468
+                                             $timeslots = array(
469
+                                                  'daily'      => __( 'Daily', 'lsx-wetu-importer' ),
470
+                                                  'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ),
471
+                                                  'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ),
472
+                                                  'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ),
473
+                                                  'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ),
474
+                                                  'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ),
475
+                                                  'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ),
476
+                                                  'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ),
477
+                                             );
478
+                                             foreach ( $timeslots as $key => $name ) {
479
+                                                  $selected = ( $schedule == $key ) ? ' selected="selected"' : '';
480
+                                                  ?>
481 481
 										<option value="<?php echo wp_kses_post( $key ); ?>" id="<?php echo wp_kses_post( $key ); ?>" <?php echo wp_kses_post( $selected ); ?>><?php echo wp_kses_post( $name ); ?></option>
482 482
 										<?php
483
-									}
484
-									?>
483
+                                             }
484
+                                             ?>
485 485
 								</select>
486 486
 							</td>
487 487
 						</tr>
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 							<td>
493 493
 								<input type="checkbox"
494 494
 								<?php
495
-								if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
496
-									echo esc_attr( 'checked="checked"' );
497
-								}
498
-								?>
495
+                                        if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
496
+                                             echo esc_attr( 'checked="checked"' );
497
+                                        }
498
+                                        ?>
499 499
 								name="accommodation_images_cron" />
500 500
 								<p><?php esc_html_e( 'Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer' ); ?></p>
501 501
 							</td>
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 							<td>
508 508
 								<input type="checkbox"
509 509
 								<?php
510
-								if ( isset( $options['accommodation_images_cron_featured'] ) && '' !== $options['accommodation_images_cron_featured'] ) {
511
-									echo esc_attr( 'checked="checked"' );
512
-								}
513
-								?>
510
+                                        if ( isset( $options['accommodation_images_cron_featured'] ) && '' !== $options['accommodation_images_cron_featured'] ) {
511
+                                             echo esc_attr( 'checked="checked"' );
512
+                                        }
513
+                                        ?>
514 514
 								name="accommodation_images_cron_featured" />
515 515
 								<p><?php esc_html_e( 'Set the featured image when the gallery is created.', 'lsx-wetu-importer' ); ?></p>
516 516
 							</td>
@@ -522,25 +522,25 @@  discard block
 block discarded – undo
522 522
 			</form>
523 523
 		</div>
524 524
 		<?php
525
-	}
525
+     }
526 526
 
527
-	/**
528
-	 * Save the options fields
529
-	 *
530
-	 * @return void
531
-	 */
532
-	public function save_options() {
533
-		if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
534
-			return;
535
-		}
536
-		$data_to_save = array();
537
-		foreach ( $this->defaults as $key => $field ) {
538
-			if ( isset( $_POST[ $key ] ) ) {
539
-				$data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] );
540
-			} else {
541
-				$data_to_save[ $key ] = '';
542
-			}
543
-		}
544
-		update_option( 'lsx_wetu_importer_settings', $data_to_save );
545
-	}
527
+     /**
528
+      * Save the options fields
529
+      *
530
+      * @return void
531
+      */
532
+     public function save_options() {
533
+          if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
534
+               return;
535
+          }
536
+          $data_to_save = array();
537
+          foreach ( $this->defaults as $key => $field ) {
538
+               if ( isset( $_POST[ $key ] ) ) {
539
+                    $data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] );
540
+               } else {
541
+                    $data_to_save[ $key ] = '';
542
+               }
543
+          }
544
+          update_option( 'lsx_wetu_importer_settings', $data_to_save );
545
+     }
546 546
 }
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 			'accommodation_images_cron'          => '',
67 67
 			'accommodation_images_cron_featured' => '',
68 68
 		);
69
-		$this->fields   = array_keys( $this->defaults );
70
-		add_action( 'admin_init', array( $this, 'save_options' ) );
69
+		$this->fields = array_keys($this->defaults);
70
+		add_action('admin_init', array($this, 'save_options'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	public static function get_instance() {
79 79
 		// If the single instance hasn't been set, set it now.
80
-		if ( ! isset( self::$instance ) ) {
80
+		if (!isset(self::$instance)) {
81 81
 			self::$instance = new self();
82 82
 		}
83 83
 		return self::$instance;
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function display_page() {
90 90
 		$options = lsx_wetu_get_options();
91
-		foreach ( $options as $key => $value ) {
92
-			$value = trim( $value );
91
+		foreach ($options as $key => $value) {
92
+			$value = trim($value);
93 93
 		}
94
-		$options = wp_parse_args( $options, $this->defaults );
94
+		$options = wp_parse_args($options, $this->defaults);
95 95
 		?>
96 96
 		<div class="wrap">
97 97
 			<form method="post" class="">
98
-				<?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?>
99
-				<?php do_action( 'lsx_wetu_importer_settings_before' ); ?>
100
-				<h1><?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></h1>
98
+				<?php wp_nonce_field('lsx_wetu_importer_save', 'lsx_wetu_importer_save_options'); ?>
99
+				<?php do_action('lsx_wetu_importer_settings_before'); ?>
100
+				<h1><?php esc_html_e('General', 'lsx-wetu-importer'); ?></h1>
101 101
 				<table class="form-table">
102 102
 					<tbody>
103 103
 						<tr class="form-field">
104 104
 							<th scope="row">
105
-								<label for="wetu_api_key"><span title="The API key can be found on your My Account page of your WETU account." id="doc-tooltip" class="dashicons dashicons-editor-help tooltip"></span> <?php esc_html_e( 'API Key', 'lsx-wetu-importer' ); ?></label>
105
+								<label for="wetu_api_key"><span title="The API key can be found on your My Account page of your WETU account." id="doc-tooltip" class="dashicons dashicons-editor-help tooltip"></span> <?php esc_html_e('API Key', 'lsx-wetu-importer'); ?></label>
106 106
 							</th>
107 107
 							<td>
108 108
 								<input data-toggle="tooltip" data-placement="top" title="The API key can be found on your My Account page of your WETU account." type="text" value="
109 109
                                 <?php
110
-								if ( isset( $options['api_key'] ) ) {
111
-									echo esc_attr( $options['api_key'] );
110
+								if (isset($options['api_key'])) {
111
+									echo esc_attr($options['api_key']);
112 112
 								}
113 113
 								?>
114 114
                                 " name="api_key" />
@@ -117,227 +117,227 @@  discard block
 block discarded – undo
117 117
 					</tbody>
118 118
 				</table>
119 119
 
120
-				<h1><?php esc_html_e( 'Tours', 'lsx-wetu-importer' ); ?></h1>
120
+				<h1><?php esc_html_e('Tours', 'lsx-wetu-importer'); ?></h1>
121 121
 				<table class="form-table">
122 122
 					<tbody>
123 123
 						<tr class="form-field -wrap">
124 124
 							<th scope="row">
125
-								<label for="disable_tour_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label>
125
+								<label for="disable_tour_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label>
126 126
 							</th>
127 127
 							<td>
128 128
 								<input type="checkbox"
129 129
 								<?php
130
-								if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) {
131
-									echo esc_attr( 'checked="checked"' );
130
+								if (isset($options['disable_tour_title']) && '' !== $options['disable_tour_title']) {
131
+									echo esc_attr('checked="checked"');
132 132
 								}
133 133
 								?>
134 134
 								name="disable_tour_title" />
135 135
 
136
-								<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>
136
+								<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>
137 137
 							</td>
138 138
 						</tr>
139 139
 						<tr class="form-field -wrap">
140 140
 							<th scope="row">
141
-								<label for="disable_tour_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label>
141
+								<label for="disable_tour_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label>
142 142
 							</th>
143 143
 							<td>
144 144
 								<input type="checkbox"
145 145
 								<?php
146
-								if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
147
-									echo esc_attr( 'checked="checked"' );
146
+								if (isset($options['disable_tour_descriptions']) && '' !== $options['disable_tour_descriptions']) {
147
+									echo esc_attr('checked="checked"');
148 148
 								}
149 149
 								?>
150 150
 								name="disable_tour_descriptions" />
151 151
 
152
-								<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>
152
+								<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>
153 153
 							</td>
154 154
 						</tr>
155 155
 						<tr class="form-field -wrap">
156 156
 							<th scope="row">
157
-								<label for="disable_tour_tags"><?php esc_html_e( 'Disable Tags / Travel Styles', 'lsx-wetu-importer' ); ?></label>
157
+								<label for="disable_tour_tags"><?php esc_html_e('Disable Tags / Travel Styles', 'lsx-wetu-importer'); ?></label>
158 158
 							</th>
159 159
 							<td>
160 160
 								<input type="checkbox"
161 161
 								<?php
162
-								if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) {
163
-									echo esc_attr( 'checked="checked"' );
162
+								if (isset($options['disable_tour_tags']) && '' !== $options['disable_tour_tags']) {
163
+									echo esc_attr('checked="checked"');
164 164
 								}
165 165
 								?>
166 166
 								name="disable_tour_tags" />
167 167
 
168
-								<small><?php esc_html_e( 'Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer' ); ?></small>
168
+								<small><?php esc_html_e('Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer'); ?></small>
169 169
 							</td>
170 170
 						</tr>
171 171
 
172 172
 						<tr class="form-field -wrap">
173 173
 							<th scope="row">
174
-								<label for="enable_tour_ref_column"><?php esc_html_e( 'Enable Reference Column', 'lsx-wetu-importer' ); ?></label>
174
+								<label for="enable_tour_ref_column"><?php esc_html_e('Enable Reference Column', 'lsx-wetu-importer'); ?></label>
175 175
 							</th>
176 176
 							<td>
177 177
 								<input type="checkbox"
178 178
 								<?php
179
-								if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) {
180
-									echo esc_attr( 'checked="checked"' );
179
+								if (isset($options['enable_tour_ref_column']) && '' !== $options['enable_tour_ref_column']) {
180
+									echo esc_attr('checked="checked"');
181 181
 								}
182 182
 								?>
183 183
 								name="enable_tour_ref_column" />
184
-								<small><?php esc_html_e( 'Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer' ); ?></small>
184
+								<small><?php esc_html_e('Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer'); ?></small>
185 185
 							</td>
186 186
 						</tr>
187 187
 
188 188
 						<tr class="form-field -wrap">
189 189
 							<th scope="row">
190
-								<label for="enable_tour_featured_random"><?php esc_html_e( 'Randomize Featured Image', 'lsx-wetu-importer' ); ?></label>
190
+								<label for="enable_tour_featured_random"><?php esc_html_e('Randomize Featured Image', 'lsx-wetu-importer'); ?></label>
191 191
 							</th>
192 192
 							<td>
193 193
 								<input type="checkbox"
194 194
 								<?php
195
-								if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) {
196
-									echo esc_attr( 'checked="checked"' );
195
+								if (isset($options['enable_tour_featured_random']) && '' !== $options['enable_tour_featured_random']) {
196
+									echo esc_attr('checked="checked"');
197 197
 								}
198 198
 								?>
199 199
 								name="enable_tour_featured_random" />
200
-								<small><?php esc_html_e( 'This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer' ); ?></small>
200
+								<small><?php esc_html_e('This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer'); ?></small>
201 201
 							</td>
202 202
 						</tr>
203 203
 					</tbody>
204 204
 				</table>
205 205
 
206
-				<h1><?php esc_html_e( 'Accommodation', 'lsx-wetu-importer' ); ?></h1>
206
+				<h1><?php esc_html_e('Accommodation', 'lsx-wetu-importer'); ?></h1>
207 207
 
208 208
 				<table class="form-table">
209 209
 					<tbody>
210 210
 						<tr class="form-field -wrap">
211 211
 							<th scope="row">
212
-								<label for="disable_accommodation_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label>
212
+								<label for="disable_accommodation_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label>
213 213
 							</th>
214 214
 							<td>
215 215
 								<input type="checkbox"
216 216
 								<?php
217
-								if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) {
218
-									echo esc_attr( 'checked="checked"' );
217
+								if (isset($options['disable_accommodation_title']) && '' !== $options['disable_accommodation_title']) {
218
+									echo esc_attr('checked="checked"');
219 219
 								}
220 220
 								?>
221 221
 								name="disable_accommodation_title" />
222 222
 
223
-								<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>
223
+								<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>
224 224
 							</td>
225 225
 						</tr>
226 226
 						<tr class="form-field -wrap">
227 227
 							<th scope="row">
228
-								<label for="disable_accommodation_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label>
228
+								<label for="disable_accommodation_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label>
229 229
 							</th>
230 230
 							<td>
231 231
 								<input type="checkbox"
232 232
 								<?php
233
-								if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
234
-									echo esc_attr( 'checked="checked"' );
233
+								if (isset($options['disable_accommodation_descriptions']) && '' !== $options['disable_accommodation_descriptions']) {
234
+									echo esc_attr('checked="checked"');
235 235
 								}
236 236
 								?>
237 237
 								name="disable_accommodation_descriptions" />
238
-								<small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small>
238
+								<small><?php esc_html_e('If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer'); ?></small>
239 239
 							</td>
240 240
 						</tr>
241 241
 						<tr class="form-field -wrap">
242 242
 							<th scope="row">
243
-								<label for="disable_accommodation_filtering"><?php esc_html_e( 'Disable Description Filtering', 'lsx-wetu-importer' ); ?></label>
243
+								<label for="disable_accommodation_filtering"><?php esc_html_e('Disable Description Filtering', 'lsx-wetu-importer'); ?></label>
244 244
 							</th>
245 245
 							<td>
246 246
 								<input type="checkbox"
247 247
 								<?php
248
-								if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) {
249
-									echo esc_attr( 'checked="checked"' );
248
+								if (isset($options['disable_accommodation_filtering']) && '' !== $options['disable_accommodation_filtering']) {
249
+									echo esc_attr('checked="checked"');
250 250
 								}
251 251
 								?>
252 252
 								name="disable_accommodation_filtering" />
253
-								<small><?php esc_html_e( 'This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer' ); ?></small>
253
+								<small><?php esc_html_e('This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer'); ?></small>
254 254
 							</td>
255 255
 						</tr>
256 256
 
257 257
 						<tr class="form-field -wrap">
258 258
 							<th scope="row">
259
-								<label for="disable_accommodation_excerpts"><?php esc_html_e( 'Disable Excerpts', 'lsx-wetu-importer' ); ?></label>
259
+								<label for="disable_accommodation_excerpts"><?php esc_html_e('Disable Excerpts', 'lsx-wetu-importer'); ?></label>
260 260
 							</th>
261 261
 							<td>
262 262
 								<input type="checkbox"
263 263
 								<?php
264
-								if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
265
-									echo esc_attr( 'checked="checked"' );
264
+								if (isset($options['disable_accommodation_excerpts']) && '' !== $options['disable_accommodation_excerpts']) {
265
+									echo esc_attr('checked="checked"');
266 266
 								}
267 267
 								?>
268 268
 								name="disable_accommodation_excerpts" />
269
-								<small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small>
269
+								<small><?php esc_html_e('If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer'); ?></small>
270 270
 							</td>
271 271
 						</tr>
272 272
 					</tbody>
273 273
 				</table>
274 274
 
275
-				<h1><?php esc_html_e( 'Destinations', 'lsx-wetu-importer' ); ?></h1>
275
+				<h1><?php esc_html_e('Destinations', 'lsx-wetu-importer'); ?></h1>
276 276
 
277 277
 				<table class="form-table">
278 278
 					<tbody>
279 279
 						<tr class="form-field -wrap">
280 280
 							<th scope="row">
281
-								<label for="disable_destination_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label>
281
+								<label for="disable_destination_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label>
282 282
 							</th>
283 283
 							<td>
284 284
 								<input type="checkbox"
285 285
 								<?php
286
-								if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) {
287
-									echo esc_attr( 'checked="checked"' );
286
+								if (isset($options['disable_destination_title']) && '' !== $options['disable_destination_title']) {
287
+									echo esc_attr('checked="checked"');
288 288
 								}
289 289
 								?>
290 290
 								name="disable_destination_title" />
291 291
 
292
-								<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>
292
+								<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>
293 293
 							</td>
294 294
 						</tr>
295 295
 						<tr class="form-field -wrap">
296 296
 							<th scope="row">
297
-								<label for="disable_destination_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label>
297
+								<label for="disable_destination_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label>
298 298
 							</th>
299 299
 							<td>
300 300
 								<input type="checkbox"
301 301
 								<?php
302
-								if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
303
-									echo esc_attr( 'checked="checked"' );
302
+								if (isset($options['disable_destination_descriptions']) && '' !== $options['disable_destination_descriptions']) {
303
+									echo esc_attr('checked="checked"');
304 304
 								}
305 305
 								?>
306 306
 								name="disable_destination_descriptions" />
307
-								<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>
307
+								<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>
308 308
 							</td>
309 309
 						</tr>
310 310
 					</tbody>
311 311
 				</table>
312 312
 
313
-				<h1><?php esc_html_e( 'Images', 'lsx-wetu-importer' ); ?></h1>
313
+				<h1><?php esc_html_e('Images', 'lsx-wetu-importer'); ?></h1>
314 314
 
315 315
 				<table class="form-table">
316 316
 					<tbody>
317 317
 						<tr class="form-field -wrap">
318 318
 							<th scope="row">
319
-								<label for="image_replacing"><?php esc_html_e( 'Replace Images', 'lsx-wetu-importer' ); ?></label>
319
+								<label for="image_replacing"><?php esc_html_e('Replace Images', 'lsx-wetu-importer'); ?></label>
320 320
 							</th>
321 321
 							<td>
322 322
 								<input type="checkbox"
323 323
 								<?php
324
-								if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
325
-									echo esc_attr( 'checked="checked"' );
324
+								if (isset($options['image_replacing']) && '' !== $options['image_replacing']) {
325
+									echo esc_attr('checked="checked"');
326 326
 								}
327 327
 								?>
328 328
 								name="image_replacing" />
329
-								<p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p>
329
+								<p><?php esc_html_e('Do you want your images to be replaced on each import.', 'lsx-wetu-importer'); ?></p>
330 330
 							</td>
331 331
 						</tr>
332 332
 						<tr class="form-field -wrap">
333 333
 							<th scope="row">
334
-								<label for="image_limit"> <?php esc_html_e( 'Limit the amount of images imported to the gallery', 'lsx-wetu-importer' ); ?></label>
334
+								<label for="image_limit"> <?php esc_html_e('Limit the amount of images imported to the gallery', 'lsx-wetu-importer'); ?></label>
335 335
 							</th>
336 336
 							<td>
337 337
 								<input placeholder="" type="text" value="
338 338
                                 <?php
339
-								if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
340
-									echo esc_attr( $options['image_limit'] );
339
+								if (isset($options['image_limit']) && '' !== $options['image_limit']) {
340
+									echo esc_attr($options['image_limit']);
341 341
 								}
342 342
 								?>
343 343
                                 "
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 
348 348
 						<tr class="form-field -wrap">
349 349
 							<th scope="row">
350
-								<label for="image_scaling"><?php esc_html_e( 'Enable Image Scaling', 'lsx-wetu-importer' ); ?></label>
350
+								<label for="image_scaling"><?php esc_html_e('Enable Image Scaling', 'lsx-wetu-importer'); ?></label>
351 351
 							</th>
352 352
 							<td>
353 353
 								<input type="checkbox"
354 354
 								<?php
355
-								if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
356
-									echo esc_attr( 'checked="checked"' );
355
+								if (isset($options['image_scaling']) && '' !== $options['image_scaling']) {
356
+									echo esc_attr('checked="checked"');
357 357
 								}
358 358
 								?>
359 359
 								name="image_scaling" />
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 						</tr>
362 362
 						<tr class="form-field -wrap">
363 363
 							<th scope="row">
364
-								<label for="width"> <?php esc_html_e( 'Width (px)', 'lsx-wetu-importer' ); ?></label>
364
+								<label for="width"> <?php esc_html_e('Width (px)', 'lsx-wetu-importer'); ?></label>
365 365
 							</th>
366 366
 							<td>
367 367
 								<input placeholder="800" type="text" value="
368 368
                                 <?php
369
-								if ( isset( $options['width'] ) && '' !== $options['width'] ) {
370
-									echo esc_attr( $options['width'] );
369
+								if (isset($options['width']) && '' !== $options['width']) {
370
+									echo esc_attr($options['width']);
371 371
 								}
372 372
 								?>
373 373
                                 "
@@ -376,13 +376,13 @@  discard block
 block discarded – undo
376 376
 						</tr>
377 377
 						<tr class="form-field -wrap">
378 378
 							<th scope="row">
379
-								<label for="height"> <?php esc_html_e( 'Height (px)', 'lsx-wetu-importer' ); ?></label>
379
+								<label for="height"> <?php esc_html_e('Height (px)', 'lsx-wetu-importer'); ?></label>
380 380
 							</th>
381 381
 							<td>
382 382
 								<input placeholder="600" type="text" value="
383 383
                                 <?php
384
-								if ( isset( $options['height'] ) && '' !== $options['height'] ) {
385
-									echo esc_attr( $options['height'] );
384
+								if (isset($options['height']) && '' !== $options['height']) {
385
+									echo esc_attr($options['height']);
386 386
 								}
387 387
 								?>
388 388
                                 "
@@ -392,93 +392,93 @@  discard block
 block discarded – undo
392 392
 
393 393
 						<tr class="form-field -wrap image-settings">
394 394
 							<th scope="row">
395
-								<label for="scaling"> <?php esc_html_e( 'Scaling', 'lsx-wetu-importer' ); ?></label>
395
+								<label for="scaling"> <?php esc_html_e('Scaling', 'lsx-wetu-importer'); ?></label>
396 396
 							</th>
397 397
 							<td>
398 398
 								<input type="radio"
399 399
 								<?php
400
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
401
-									echo esc_attr( 'checked="checked"' );
400
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'raw' === $options['scaling']) {
401
+									echo esc_attr('checked="checked"');
402 402
 								}
403 403
 								?>
404
-								name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br />
404
+								name="scaling" value="raw" /> <?php esc_html_e('Get the Full size image, no cropping takes place.', 'lsx-wetu-importer'); ?><br />
405 405
 								<input type="radio"
406 406
 								<?php
407
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
408
-									echo esc_attr( 'checked="checked"' );
407
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'c' === $options['scaling']) {
408
+									echo esc_attr('checked="checked"');
409 409
 								}
410 410
 								?>
411
-								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 />
411
+								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 />
412 412
 								<input type="radio"
413 413
 								<?php
414
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
415
-									echo esc_attr( 'checked="checked"' );
414
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'h' === $options['scaling']) {
415
+									echo esc_attr('checked="checked"');
416 416
 								}
417 417
 								?>
418
-								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 />
418
+								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 />
419 419
 								<input type="radio"
420 420
 								<?php
421
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
422
-									echo esc_attr( 'checked="checked"' );
421
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'w' === $options['scaling']) {
422
+									echo esc_attr('checked="checked"');
423 423
 								}
424 424
 								?>
425
-								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 />
425
+								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 />
426 426
 								<input type="radio"
427 427
 								<?php
428
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
429
-									echo esc_attr( 'checked="checked"' );
428
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'nf' === $options['scaling']) {
429
+									echo esc_attr('checked="checked"');
430 430
 								}
431 431
 								?>
432
-								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 />
432
+								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 />
433 433
 								<input type="radio"
434 434
 								<?php
435
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
436
-									echo esc_attr( 'checked="checked"' );
435
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'n' === $options['scaling']) {
436
+									echo esc_attr('checked="checked"');
437 437
 								}
438 438
 								?>
439
-								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 />
439
+								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 />
440 440
 								<input type="radio"
441 441
 								<?php
442
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
443
-									echo esc_attr( 'checked="checked"' );
442
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'W' === $options['scaling']) {
443
+									echo esc_attr('checked="checked"');
444 444
 								}
445 445
 								?>
446
-								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' ); ?>
446
+								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'); ?>
447 447
 							</td>
448 448
 						</tr>
449 449
 					</tbody>
450 450
 				</table>
451 451
 
452
-				<h1><?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?></h1>
452
+				<h1><?php esc_html_e('Sync', 'lsx-wetu-importer'); ?></h1>
453 453
 
454 454
 				<table class="form-table">
455 455
 					<tbody>
456 456
 						<tr class="form-field -wrap">
457 457
 							<th scope="row">
458
-								<label for="cron_schedule"><?php esc_html_e( 'Schedule', 'lsx-wetu-importer' ); ?></label>
458
+								<label for="cron_schedule"><?php esc_html_e('Schedule', 'lsx-wetu-importer'); ?></label>
459 459
 							</th>
460 460
 							<td>
461 461
 								<select name="cron_schedule" id="cron_schedule"	class="widefat layout">
462 462
 									<?php
463
-									if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) {
463
+									if (isset($options['cron_schedule']) && '' !== $options['cron_schedule']) {
464 464
 										$schedule = $options['cron_schedule'];
465
-									} else {
465
+									}else {
466 466
 										$schedule = 'daily';
467 467
 									}
468 468
 									$timeslots = array(
469
-										'daily'      => __( 'Daily', 'lsx-wetu-importer' ),
470
-										'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ),
471
-										'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ),
472
-										'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ),
473
-										'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ),
474
-										'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ),
475
-										'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ),
476
-										'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ),
469
+										'daily'      => __('Daily', 'lsx-wetu-importer'),
470
+										'weekly-mon' => __('Weekly (Monday)', 'lsx-wetu-importer'),
471
+										'weekly-tue' => __('Weekly (Tuesday)', 'lsx-wetu-importer'),
472
+										'weekly-wed' => __('Weekly (Wednesday)', 'lsx-wetu-importer'),
473
+										'weekly-thu' => __('Weekly (Thursday)', 'lsx-wetu-importer'),
474
+										'weekly-fri' => __('Weekly (Friday)', 'lsx-wetu-importer'),
475
+										'weekly-sat' => __('Weekly (Saturday)', 'lsx-wetu-importer'),
476
+										'weekly-sun' => __('Weekly (Sunday)', 'lsx-wetu-importer'),
477 477
 									);
478
-									foreach ( $timeslots as $key => $name ) {
479
-										$selected = ( $schedule == $key ) ? ' selected="selected"' : '';
478
+									foreach ($timeslots as $key => $name) {
479
+										$selected = ($schedule == $key) ? ' selected="selected"' : '';
480 480
 										?>
481
-										<option value="<?php echo wp_kses_post( $key ); ?>" id="<?php echo wp_kses_post( $key ); ?>" <?php echo wp_kses_post( $selected ); ?>><?php echo wp_kses_post( $name ); ?></option>
481
+										<option value="<?php echo wp_kses_post($key); ?>" id="<?php echo wp_kses_post($key); ?>" <?php echo wp_kses_post($selected); ?>><?php echo wp_kses_post($name); ?></option>
482 482
 										<?php
483 483
 									}
484 484
 									?>
@@ -487,38 +487,38 @@  discard block
 block discarded – undo
487 487
 						</tr>
488 488
 						<tr class="form-field -wrap">
489 489
 							<th scope="row">
490
-								<label for="accommodation_images_cron"><?php esc_html_e( 'Accommodation Images', 'lsx-wetu-importer' ); ?></label>
490
+								<label for="accommodation_images_cron"><?php esc_html_e('Accommodation Images', 'lsx-wetu-importer'); ?></label>
491 491
 							</th>
492 492
 							<td>
493 493
 								<input type="checkbox"
494 494
 								<?php
495
-								if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
496
-									echo esc_attr( 'checked="checked"' );
495
+								if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) {
496
+									echo esc_attr('checked="checked"');
497 497
 								}
498 498
 								?>
499 499
 								name="accommodation_images_cron" />
500
-								<p><?php esc_html_e( 'Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer' ); ?></p>
500
+								<p><?php esc_html_e('Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer'); ?></p>
501 501
 							</td>
502 502
 						</tr>
503 503
 						<tr class="form-field -wrap">
504 504
 							<th scope="row">
505
-								<label for="accommodation_images_cron_featured"><?php esc_html_e( 'Featured Images', 'lsx-wetu-importer' ); ?></label>
505
+								<label for="accommodation_images_cron_featured"><?php esc_html_e('Featured Images', 'lsx-wetu-importer'); ?></label>
506 506
 							</th>
507 507
 							<td>
508 508
 								<input type="checkbox"
509 509
 								<?php
510
-								if ( isset( $options['accommodation_images_cron_featured'] ) && '' !== $options['accommodation_images_cron_featured'] ) {
511
-									echo esc_attr( 'checked="checked"' );
510
+								if (isset($options['accommodation_images_cron_featured']) && '' !== $options['accommodation_images_cron_featured']) {
511
+									echo esc_attr('checked="checked"');
512 512
 								}
513 513
 								?>
514 514
 								name="accommodation_images_cron_featured" />
515
-								<p><?php esc_html_e( 'Set the featured image when the gallery is created.', 'lsx-wetu-importer' ); ?></p>
515
+								<p><?php esc_html_e('Set the featured image when the gallery is created.', 'lsx-wetu-importer'); ?></p>
516 516
 							</td>
517 517
 						</tr>
518 518
 					</tbody>
519 519
 				</table>
520 520
 
521
-				<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>
521
+				<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>
522 522
 			</form>
523 523
 		</div>
524 524
 		<?php
@@ -530,17 +530,17 @@  discard block
 block discarded – undo
530 530
 	 * @return void
531 531
 	 */
532 532
 	public function save_options() {
533
-		if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
533
+		if (!isset($_POST['lsx_wetu_importer_save_options']) || !wp_verify_nonce($_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save')) {
534 534
 			return;
535 535
 		}
536 536
 		$data_to_save = array();
537
-		foreach ( $this->defaults as $key => $field ) {
538
-			if ( isset( $_POST[ $key ] ) ) {
539
-				$data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] );
540
-			} else {
541
-				$data_to_save[ $key ] = '';
537
+		foreach ($this->defaults as $key => $field) {
538
+			if (isset($_POST[$key])) {
539
+				$data_to_save[$key] = sanitize_text_field($_POST[$key]);
540
+			}else {
541
+				$data_to_save[$key] = '';
542 542
 			}
543 543
 		}
544
-		update_option( 'lsx_wetu_importer_settings', $data_to_save );
544
+		update_option('lsx_wetu_importer_settings', $data_to_save);
545 545
 	}
546 546
 }
Please login to merge, or discard this patch.
classes/class-cron.php 2 patches
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -16,266 +16,266 @@
 block discarded – undo
16 16
  */
17 17
 class Cron {
18 18
 
19
-	/**
20
-	 * Holds class instance
21
-	 *
22
-	 * @since 1.0.0
23
-	 *
24
-	 * @var      object|Module_Template
25
-	 */
26
-	protected static $instance = null;
19
+     /**
20
+      * Holds class instance
21
+      *
22
+      * @since 1.0.0
23
+      *
24
+      * @var      object|Module_Template
25
+      */
26
+     protected static $instance = null;
27 27
 
28
-	/**
29
-	 * Initialize the plugin by setting localization, filters, and administration functions.
30
-	 *
31
-	 * @since 1.0.0
32
-	 *
33
-	 * @access private
34
-	 */
35
-	public function __construct() {
36
-		add_filter( 'cron_schedules', array( $this, 'register_schedule' ), 10, 1 );
37
-		add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
38
-		add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 );
39
-		add_action( 'lsx_wetu_accommodation_images_sync', array( $this, 'cron_callback' ), 10, 1 );
40
-		add_filter( 'cmb_meta_boxes', array( $this, 'custom_image_metabox' ), 10, 1 );
41
-	}
28
+     /**
29
+      * Initialize the plugin by setting localization, filters, and administration functions.
30
+      *
31
+      * @since 1.0.0
32
+      *
33
+      * @access private
34
+      */
35
+     public function __construct() {
36
+          add_filter( 'cron_schedules', array( $this, 'register_schedule' ), 10, 1 );
37
+          add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
38
+          add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 );
39
+          add_action( 'lsx_wetu_accommodation_images_sync', array( $this, 'cron_callback' ), 10, 1 );
40
+          add_filter( 'cmb_meta_boxes', array( $this, 'custom_image_metabox' ), 10, 1 );
41
+     }
42 42
 
43
-	/**
44
-	 * Return an instance of this class.
45
-	 *
46
-	 * @since 1.0.0
47
-	 *
48
-	 * @return    object Cron()    A single instance of this class.
49
-	 */
50
-	public static function get_instance() {
51
-		// If the single instance hasn't been set, set it now.
52
-		if ( null === self::$instance ) {
53
-			self::$instance = new self();
54
-		}
55
-		return self::$instance;
56
-	}
43
+     /**
44
+      * Return an instance of this class.
45
+      *
46
+      * @since 1.0.0
47
+      *
48
+      * @return    object Cron()    A single instance of this class.
49
+      */
50
+     public static function get_instance() {
51
+          // If the single instance hasn't been set, set it now.
52
+          if ( null === self::$instance ) {
53
+               self::$instance = new self();
54
+          }
55
+          return self::$instance;
56
+     }
57 57
 
58
-	public function custom_image_metabox( &$meta_boxes ) {
58
+     public function custom_image_metabox( &$meta_boxes ) {
59 59
 
60
-		$fields = array(
61
-			/**
62
-			 * Single Checkbox Field.
63
-			 */
64
-			array(
65
-				'id'    => 'field-checkbox',
66
-				'name' => 'Checkbox field',
67
-				'type' => 'checkbox',
68
-			),
69
-		);
70
-		/**
71
-		 * Metabox instantiation.
72
-		 */
73
-		$meta_boxes[] = array(
74
-			'title' => __( 'WETU Settings', 'lsx-wetu-importer' ),
75
-			'pages' => 'accommodation',
76
-			'fields' => $fields,
77
-		);
78
-		return $meta_boxes;
79
-	}
60
+          $fields = array(
61
+               /**
62
+                * Single Checkbox Field.
63
+                */
64
+               array(
65
+                    'id'    => 'field-checkbox',
66
+                    'name' => 'Checkbox field',
67
+                    'type' => 'checkbox',
68
+               ),
69
+          );
70
+          /**
71
+           * Metabox instantiation.
72
+           */
73
+          $meta_boxes[] = array(
74
+               'title' => __( 'WETU Settings', 'lsx-wetu-importer' ),
75
+               'pages' => 'accommodation',
76
+               'fields' => $fields,
77
+          );
78
+          return $meta_boxes;
79
+     }
80 80
 
81
-	/**
82
-	 * Registers a 5 min schedule for us to use.
83
-	 *
84
-	 * @param  array $schedules
85
-	 * @return array
86
-	 */
87
-	public function register_schedule( $schedules ) {
88
-		$schedules['wetu-5-minutes'] = array(
89
-			'interval' => 5 * MINUTE_IN_SECONDS,
90
-			'display'  => __( 'Every 5 minutes', 'lsx-wetu-importer' ),
91
-		);
92
-		return $schedules;
93
-	}
81
+     /**
82
+      * Registers a 5 min schedule for us to use.
83
+      *
84
+      * @param  array $schedules
85
+      * @return array
86
+      */
87
+     public function register_schedule( $schedules ) {
88
+          $schedules['wetu-5-minutes'] = array(
89
+               'interval' => 5 * MINUTE_IN_SECONDS,
90
+               'display'  => __( 'Every 5 minutes', 'lsx-wetu-importer' ),
91
+          );
92
+          return $schedules;
93
+     }
94 94
 
95
-	/**
96
-	 * Watches for changes in the button triggers.
97
-	 *
98
-	 * @return void
99
-	 */
100
-	public function watch_for_trigger() {
95
+     /**
96
+      * Watches for changes in the button triggers.
97
+      *
98
+      * @return void
99
+      */
100
+     public function watch_for_trigger() {
101 101
 
102
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
103
-			$options = lsx_wetu_get_options();
102
+          if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
103
+               $options = lsx_wetu_get_options();
104 104
 
105
-			// Check what state the option is in.
106
-			$accommodation_cron = 'deactivate';
107
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
108
-				$accommodation_cron = 'activate';
109
-			}
105
+               // Check what state the option is in.
106
+               $accommodation_cron = 'deactivate';
107
+               if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
108
+                    $accommodation_cron = 'activate';
109
+               }
110 110
 
111
-			// Check what state the cron is in.
112
-			$scheduled = false;
113
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
114
-				$scheduled = true;
115
-			}
111
+               // Check what state the cron is in.
112
+               $scheduled = false;
113
+               if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
114
+                    $scheduled = true;
115
+               }
116 116
 
117
-			// If activate and its not running.
118
-			if ( false === $scheduled && 'activate' === $accommodation_cron ) {
119
-				$schedule = 'weekly';
120
-				$this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
121
-			} elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) {
122
-				$this->deactivate();
123
-			}
124
-		}
125
-	}
117
+               // If activate and its not running.
118
+               if ( false === $scheduled && 'activate' === $accommodation_cron ) {
119
+                    $schedule = 'weekly';
120
+                    $this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
121
+               } elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) {
122
+                    $this->deactivate();
123
+               }
124
+          }
125
+     }
126 126
 
127
-	/**
128
-	 * Remove our cron from the shedule.
129
-	 *
130
-	 * @return void
131
-	 */
132
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
133
-		wp_clear_scheduled_hook( $task, array( $task ) );
134
-	}
127
+     /**
128
+      * Remove our cron from the shedule.
129
+      *
130
+      * @return void
131
+      */
132
+     public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
133
+          wp_clear_scheduled_hook( $task, array( $task ) );
134
+     }
135 135
 
136
-	/**
137
-	 * This function will schedule the cron event.
138
-	 *
139
-	 * @param string $task
140
-	 * @param string $schedule
141
-	 * @param string $time
142
-	 * @return void
143
-	 */
144
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) {
145
-		$args = array( $task );
146
-		if ( '' === $time ) {
147
-			$time = time();
148
-		}
136
+     /**
137
+      * This function will schedule the cron event.
138
+      *
139
+      * @param string $task
140
+      * @param string $schedule
141
+      * @param string $time
142
+      * @return void
143
+      */
144
+     public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) {
145
+          $args = array( $task );
146
+          if ( '' === $time ) {
147
+               $time = time();
148
+          }
149 149
 
150
-		if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) {
151
-			$args[] = 'featured_image';
152
-		}
153
-		wp_schedule_event( $time, $schedule, $task, $args );
154
-	}
150
+          if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) {
151
+               $args[] = 'featured_image';
152
+          }
153
+          wp_schedule_event( $time, $schedule, $task, $args );
154
+     }
155 155
 
156
-	/**
157
-	 * This is the function that will be triggered by the cron event.
158
-	 *
159
-	 * @return void
160
-	 */
161
-	public function process( $task = '' ) {
162
-		switch ( $task ) {
163
-			case 'lsx_wetu_accommodation_images_cron':
164
-					$this->register_accommodation_images_sync();
165
-				break;
156
+     /**
157
+      * This is the function that will be triggered by the cron event.
158
+      *
159
+      * @return void
160
+      */
161
+     public function process( $task = '' ) {
162
+          switch ( $task ) {
163
+               case 'lsx_wetu_accommodation_images_cron':
164
+                         $this->register_accommodation_images_sync();
165
+                    break;
166 166
 
167
-			default:
168
-				break;
169
-		}
170
-	}
167
+               default:
168
+                    break;
169
+          }
170
+     }
171 171
 
172
-	/**
173
-	 * This is the function that will be triggered by the cron event.
174
-	 *
175
-	 * @return void
176
-	 */
177
-	public function register_accommodation_images_sync() {
178
-		$time = strtotime( '+5 min' );
179
-		if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) {
180
-			$this->load_items_to_sync( 'accommodation_images' );
181
-			$this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time );
182
-		}
183
-	}
172
+     /**
173
+      * This is the function that will be triggered by the cron event.
174
+      *
175
+      * @return void
176
+      */
177
+     public function register_accommodation_images_sync() {
178
+          $time = strtotime( '+5 min' );
179
+          if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) {
180
+               $this->load_items_to_sync( 'accommodation_images' );
181
+               $this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time );
182
+          }
183
+     }
184 184
 
185
-	/**
186
-	 * This is the function that will be triggered by the cron event.
187
-	 *
188
-	 * @return void
189
-	 */
190
-	public function cron_callback( $task = '', $featured_image = '' ) {
191
-		$has_accommodation = get_option( $task );
192
-		if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) {
193
-			$next_time = array_slice( $has_accommodation, 5 );
194
-			$this_time = array_slice( $has_accommodation, 0, 4 );
185
+     /**
186
+      * This is the function that will be triggered by the cron event.
187
+      *
188
+      * @return void
189
+      */
190
+     public function cron_callback( $task = '', $featured_image = '' ) {
191
+          $has_accommodation = get_option( $task );
192
+          if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) {
193
+               $next_time = array_slice( $has_accommodation, 5 );
194
+               $this_time = array_slice( $has_accommodation, 0, 4 );
195 195
 
196
-			$api_key = $this->get_api_key();
197
-			$url     = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids=';
196
+               $api_key = $this->get_api_key();
197
+               $url     = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids=';
198 198
 
199
-			// Run through the current items.
200
-			foreach ( $this_time as $accommodation ) {
201
-				$wetu_id   = get_post_meta( $accommodation, 'lsx_wetu_id', true );
202
-				$last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true );
199
+               // Run through the current items.
200
+               foreach ( $this_time as $accommodation ) {
201
+                    $wetu_id   = get_post_meta( $accommodation, 'lsx_wetu_id', true );
202
+                    $last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true );
203 203
 
204
-				$accommodation_info = wp_remote_get( $url . $wetu_id );
205
-				if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) {
206
-					$adata = json_decode( $accommodation_info['body'], true );
204
+                    $accommodation_info = wp_remote_get( $url . $wetu_id );
205
+                    if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) {
206
+                         $adata = json_decode( $accommodation_info['body'], true );
207 207
 
208
-					if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) {
209
-						$modified_time = strtotime( $adata[0]['last_modified'] );
210
-						if ( $modified_time > $last_date ) {
211
-							$accommodation_importer = new \LSX_WETU_Importer_Accommodation();
212
-							$accommodation_importer->create_main_gallery( $adata, $accommodation );
213
-							if ( '' !== $featured_image ) {
214
-								$accommodation_importer->set_featured_image( $adata, $accommodation );
215
-							}
216
-							update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date );
217
-						}
218
-					}
219
-				}
220
-			}
208
+                         if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) {
209
+                              $modified_time = strtotime( $adata[0]['last_modified'] );
210
+                              if ( $modified_time > $last_date ) {
211
+                                   $accommodation_importer = new \LSX_WETU_Importer_Accommodation();
212
+                                   $accommodation_importer->create_main_gallery( $adata, $accommodation );
213
+                                   if ( '' !== $featured_image ) {
214
+                                        $accommodation_importer->set_featured_image( $adata, $accommodation );
215
+                                   }
216
+                                   update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date );
217
+                              }
218
+                         }
219
+                    }
220
+               }
221 221
 
222
-			// Save the values for next time.
223
-			if ( ! empty( $next_time ) ) {
224
-				update_option( $task, $next_time );
225
-			} else {
226
-				delete_option( $task );
227
-				$this->deactivate( $task );
228
-			}
229
-		} else {
230
-			$this->deactivate( $task );
231
-			update_option( 'lsx_wetu_nexttime', $task );
232
-		}
233
-	}
222
+               // Save the values for next time.
223
+               if ( ! empty( $next_time ) ) {
224
+                    update_option( $task, $next_time );
225
+               } else {
226
+                    delete_option( $task );
227
+                    $this->deactivate( $task );
228
+               }
229
+          } else {
230
+               $this->deactivate( $task );
231
+               update_option( 'lsx_wetu_nexttime', $task );
232
+          }
233
+     }
234 234
 
235
-	/**
236
-	 * This will grab the accommodation ids and load them up into an option field.
237
-	 *
238
-	 * @param  string $task
239
-	 * @return void
240
-	 */
241
-	public function load_items_to_sync( $task = 'accommodation_images' ) {
242
-		$args = array(
243
-			'post_status'    => 'publish',
244
-			'posts_per_page' => -1,
245
-			'nopagin'        => true,
246
-			'fields'         => 'ids',
247
-		);
248
-		switch ( $task ) {
249
-			case 'accommodation_images':
250
-					$args['post_type'] = 'accommodation';
251
-				break;
235
+     /**
236
+      * This will grab the accommodation ids and load them up into an option field.
237
+      *
238
+      * @param  string $task
239
+      * @return void
240
+      */
241
+     public function load_items_to_sync( $task = 'accommodation_images' ) {
242
+          $args = array(
243
+               'post_status'    => 'publish',
244
+               'posts_per_page' => -1,
245
+               'nopagin'        => true,
246
+               'fields'         => 'ids',
247
+          );
248
+          switch ( $task ) {
249
+               case 'accommodation_images':
250
+                         $args['post_type'] = 'accommodation';
251
+                    break;
252 252
 
253
-			default:
254
-				break;
255
-		}
256
-		$items = new \WP_Query( $args );
257
-		if ( $items->have_posts() ) {
258
-			update_option( 'lsx_wetu_' . $task . '_sync', $items->posts );
259
-		}
260
-	}
253
+               default:
254
+                    break;
255
+          }
256
+          $items = new \WP_Query( $args );
257
+          if ( $items->have_posts() ) {
258
+               update_option( 'lsx_wetu_' . $task . '_sync', $items->posts );
259
+          }
260
+     }
261 261
 
262
-	/**
263
-	 * Gets the API key stored in the options table.
264
-	 *
265
-	 * @return string
266
-	 */
267
-	public function get_api_key() {
268
-		$api_key = false;
269
-		$options = lsx_wetu_get_options();
262
+     /**
263
+      * Gets the API key stored in the options table.
264
+      *
265
+      * @return string
266
+      */
267
+     public function get_api_key() {
268
+          $api_key = false;
269
+          $options = lsx_wetu_get_options();
270 270
 
271
-		if ( ! defined( 'WETU_API_KEY' ) ) {
272
-			if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
273
-				$api_key = $options['api_key'];
274
-			}
275
-		} else {
276
-			$api_key = WETU_API_KEY;
277
-		}
278
-		return $api_key;
279
-	}
271
+          if ( ! defined( 'WETU_API_KEY' ) ) {
272
+               if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
273
+                    $api_key = $options['api_key'];
274
+               }
275
+          } else {
276
+               $api_key = WETU_API_KEY;
277
+          }
278
+          return $api_key;
279
+     }
280 280
 }
281 281
 Cron::get_instance();
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	 * @access private
34 34
 	 */
35 35
 	public function __construct() {
36
-		add_filter( 'cron_schedules', array( $this, 'register_schedule' ), 10, 1 );
37
-		add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
38
-		add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 );
39
-		add_action( 'lsx_wetu_accommodation_images_sync', array( $this, 'cron_callback' ), 10, 1 );
40
-		add_filter( 'cmb_meta_boxes', array( $this, 'custom_image_metabox' ), 10, 1 );
36
+		add_filter('cron_schedules', array($this, 'register_schedule'), 10, 1);
37
+		add_action('lsx_wetu_importer_settings_before', array($this, 'watch_for_trigger'), 200);
38
+		add_action('lsx_wetu_accommodation_images_cron', array($this, 'process'), 10, 1);
39
+		add_action('lsx_wetu_accommodation_images_sync', array($this, 'cron_callback'), 10, 1);
40
+		add_filter('cmb_meta_boxes', array($this, 'custom_image_metabox'), 10, 1);
41 41
 	}
42 42
 
43 43
 	/**
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public static function get_instance() {
51 51
 		// If the single instance hasn't been set, set it now.
52
-		if ( null === self::$instance ) {
52
+		if (null === self::$instance) {
53 53
 			self::$instance = new self();
54 54
 		}
55 55
 		return self::$instance;
56 56
 	}
57 57
 
58
-	public function custom_image_metabox( &$meta_boxes ) {
58
+	public function custom_image_metabox(&$meta_boxes) {
59 59
 
60 60
 		$fields = array(
61 61
 			/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		 * Metabox instantiation.
72 72
 		 */
73 73
 		$meta_boxes[] = array(
74
-			'title' => __( 'WETU Settings', 'lsx-wetu-importer' ),
74
+			'title' => __('WETU Settings', 'lsx-wetu-importer'),
75 75
 			'pages' => 'accommodation',
76 76
 			'fields' => $fields,
77 77
 		);
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 	 * @param  array $schedules
85 85
 	 * @return array
86 86
 	 */
87
-	public function register_schedule( $schedules ) {
87
+	public function register_schedule($schedules) {
88 88
 		$schedules['wetu-5-minutes'] = array(
89 89
 			'interval' => 5 * MINUTE_IN_SECONDS,
90
-			'display'  => __( 'Every 5 minutes', 'lsx-wetu-importer' ),
90
+			'display'  => __('Every 5 minutes', 'lsx-wetu-importer'),
91 91
 		);
92 92
 		return $schedules;
93 93
 	}
@@ -99,26 +99,26 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function watch_for_trigger() {
101 101
 
102
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
102
+		if (isset($_GET['page']) && 'lsx-wetu-importer' === $_GET['page'] && isset($_GET['tab']) && 'settings' === $_GET['tab']) {
103 103
 			$options = lsx_wetu_get_options();
104 104
 
105 105
 			// Check what state the option is in.
106 106
 			$accommodation_cron = 'deactivate';
107
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
107
+			if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) {
108 108
 				$accommodation_cron = 'activate';
109 109
 			}
110 110
 
111 111
 			// Check what state the cron is in.
112 112
 			$scheduled = false;
113
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
113
+			if (wp_next_scheduled('lsx_wetu_accommodation_images_cron')) {
114 114
 				$scheduled = true;
115 115
 			}
116 116
 
117 117
 			// If activate and its not running.
118
-			if ( false === $scheduled && 'activate' === $accommodation_cron ) {
118
+			if (false === $scheduled && 'activate' === $accommodation_cron) {
119 119
 				$schedule = 'weekly';
120
-				$this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
121
-			} elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) {
120
+				$this->schedule('lsx_wetu_accommodation_images_cron', $schedule);
121
+			} elseif (true === $scheduled && 'deactivate' === $accommodation_cron) {
122 122
 				$this->deactivate();
123 123
 			}
124 124
 		}
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return void
131 131
 	 */
132
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
133
-		wp_clear_scheduled_hook( $task, array( $task ) );
132
+	public function deactivate($task = 'lsx_wetu_accommodation_images_cron') {
133
+		wp_clear_scheduled_hook($task, array($task));
134 134
 	}
135 135
 
136 136
 	/**
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 	 * @param string $time
142 142
 	 * @return void
143 143
 	 */
144
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) {
145
-		$args = array( $task );
146
-		if ( '' === $time ) {
144
+	public function schedule($task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm') {
145
+		$args = array($task);
146
+		if ('' === $time) {
147 147
 			$time = time();
148 148
 		}
149 149
 
150
-		if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) {
150
+		if (isset($_GET['accommodation_images_cron_featured']) && '' !== $_GET['accommodation_images_cron_featured']) {
151 151
 			$args[] = 'featured_image';
152 152
 		}
153
-		wp_schedule_event( $time, $schedule, $task, $args );
153
+		wp_schedule_event($time, $schedule, $task, $args);
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return void
160 160
 	 */
161
-	public function process( $task = '' ) {
162
-		switch ( $task ) {
161
+	public function process($task = '') {
162
+		switch ($task) {
163 163
 			case 'lsx_wetu_accommodation_images_cron':
164 164
 					$this->register_accommodation_images_sync();
165 165
 				break;
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 * @return void
176 176
 	 */
177 177
 	public function register_accommodation_images_sync() {
178
-		$time = strtotime( '+5 min' );
179
-		if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) {
180
-			$this->load_items_to_sync( 'accommodation_images' );
181
-			$this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time );
178
+		$time = strtotime('+5 min');
179
+		if (!wp_next_scheduled('lsx_wetu_accommodation_images_sync')) {
180
+			$this->load_items_to_sync('accommodation_images');
181
+			$this->schedule('lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time);
182 182
 		}
183 183
 	}
184 184
 
@@ -187,48 +187,48 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return void
189 189
 	 */
190
-	public function cron_callback( $task = '', $featured_image = '' ) {
191
-		$has_accommodation = get_option( $task );
192
-		if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) {
193
-			$next_time = array_slice( $has_accommodation, 5 );
194
-			$this_time = array_slice( $has_accommodation, 0, 4 );
190
+	public function cron_callback($task = '', $featured_image = '') {
191
+		$has_accommodation = get_option($task);
192
+		if (false !== $has_accommodation && !empty($has_accommodation)) {
193
+			$next_time = array_slice($has_accommodation, 5);
194
+			$this_time = array_slice($has_accommodation, 0, 4);
195 195
 
196 196
 			$api_key = $this->get_api_key();
197
-			$url     = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids=';
197
+			$url     = 'https://wetu.com/API/Pins/'.$api_key.'/Get?all=include&ids=';
198 198
 
199 199
 			// Run through the current items.
200
-			foreach ( $this_time as $accommodation ) {
201
-				$wetu_id   = get_post_meta( $accommodation, 'lsx_wetu_id', true );
202
-				$last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true );
200
+			foreach ($this_time as $accommodation) {
201
+				$wetu_id   = get_post_meta($accommodation, 'lsx_wetu_id', true);
202
+				$last_date = get_post_meta($accommodation, 'lsx_wetu_modified_date', true);
203 203
 
204
-				$accommodation_info = wp_remote_get( $url . $wetu_id );
205
-				if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) {
206
-					$adata = json_decode( $accommodation_info['body'], true );
204
+				$accommodation_info = wp_remote_get($url.$wetu_id);
205
+				if (!empty($accommodation_info) && isset($accommodation_info['response']) && isset($accommodation_info['response']['code']) && 200 === $accommodation_info['response']['code']) {
206
+					$adata = json_decode($accommodation_info['body'], true);
207 207
 
208
-					if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) {
209
-						$modified_time = strtotime( $adata[0]['last_modified'] );
210
-						if ( $modified_time > $last_date ) {
208
+					if (isset($adata[0]) && isset($adata[0]['last_modified']) && '' !== $adata[0]['last_modified']) {
209
+						$modified_time = strtotime($adata[0]['last_modified']);
210
+						if ($modified_time > $last_date) {
211 211
 							$accommodation_importer = new \LSX_WETU_Importer_Accommodation();
212
-							$accommodation_importer->create_main_gallery( $adata, $accommodation );
213
-							if ( '' !== $featured_image ) {
214
-								$accommodation_importer->set_featured_image( $adata, $accommodation );
212
+							$accommodation_importer->create_main_gallery($adata, $accommodation);
213
+							if ('' !== $featured_image) {
214
+								$accommodation_importer->set_featured_image($adata, $accommodation);
215 215
 							}
216
-							update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date );
216
+							update_post_meta($accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date);
217 217
 						}
218 218
 					}
219 219
 				}
220 220
 			}
221 221
 
222 222
 			// Save the values for next time.
223
-			if ( ! empty( $next_time ) ) {
224
-				update_option( $task, $next_time );
225
-			} else {
226
-				delete_option( $task );
227
-				$this->deactivate( $task );
223
+			if (!empty($next_time)) {
224
+				update_option($task, $next_time);
225
+			}else {
226
+				delete_option($task);
227
+				$this->deactivate($task);
228 228
 			}
229
-		} else {
230
-			$this->deactivate( $task );
231
-			update_option( 'lsx_wetu_nexttime', $task );
229
+		}else {
230
+			$this->deactivate($task);
231
+			update_option('lsx_wetu_nexttime', $task);
232 232
 		}
233 233
 	}
234 234
 
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 	 * @param  string $task
239 239
 	 * @return void
240 240
 	 */
241
-	public function load_items_to_sync( $task = 'accommodation_images' ) {
241
+	public function load_items_to_sync($task = 'accommodation_images') {
242 242
 		$args = array(
243 243
 			'post_status'    => 'publish',
244 244
 			'posts_per_page' => -1,
245 245
 			'nopagin'        => true,
246 246
 			'fields'         => 'ids',
247 247
 		);
248
-		switch ( $task ) {
248
+		switch ($task) {
249 249
 			case 'accommodation_images':
250 250
 					$args['post_type'] = 'accommodation';
251 251
 				break;
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 			default:
254 254
 				break;
255 255
 		}
256
-		$items = new \WP_Query( $args );
257
-		if ( $items->have_posts() ) {
258
-			update_option( 'lsx_wetu_' . $task . '_sync', $items->posts );
256
+		$items = new \WP_Query($args);
257
+		if ($items->have_posts()) {
258
+			update_option('lsx_wetu_'.$task.'_sync', $items->posts);
259 259
 		}
260 260
 	}
261 261
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 		$api_key = false;
269 269
 		$options = lsx_wetu_get_options();
270 270
 
271
-		if ( ! defined( 'WETU_API_KEY' ) ) {
272
-			if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
271
+		if (!defined('WETU_API_KEY')) {
272
+			if (isset($options['api_key']) && '' !== $options['api_key']) {
273 273
 				$api_key = $options['api_key'];
274 274
 			}
275
-		} else {
275
+		}else {
276 276
 			$api_key = WETU_API_KEY;
277 277
 		}
278 278
 		return $api_key;
Please login to merge, or discard this patch.