Passed
Push — add/image-automation ( ddc6bf...57094b )
by Warwick
03:19
created
classes/class-lsx-wetu-importer-settings.php 1 patch
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -14,84 +14,84 @@  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
-		);
68
-		$this->fields   = array_keys( $this->defaults );
69
-		add_action( 'admin_init', array( $this, 'save_options' ) );
70
-	}
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
+          );
68
+          $this->fields   = array_keys( $this->defaults );
69
+          add_action( 'admin_init', array( $this, 'save_options' ) );
70
+     }
71 71
 
72
-	/**
73
-	 * Return an instance of this class.
74
-	 *
75
-	 * @return  object
76
-	 */
77
-	public static function get_instance() {
78
-		// If the single instance hasn't been set, set it now.
79
-		if ( ! isset( self::$instance ) ) {
80
-			self::$instance = new self();
81
-		}
82
-		return self::$instance;
83
-	}
72
+     /**
73
+      * Return an instance of this class.
74
+      *
75
+      * @return  object
76
+      */
77
+     public static function get_instance() {
78
+          // If the single instance hasn't been set, set it now.
79
+          if ( ! isset( self::$instance ) ) {
80
+               self::$instance = new self();
81
+          }
82
+          return self::$instance;
83
+     }
84 84
 
85
-	/**
86
-	 * Display the importer welcome screen
87
-	 */
88
-	public function display_page() {
89
-		$options = lsx_wetu_get_options();
90
-		foreach ( $options as $key => $value ) {
91
-			$value = trim( $value );
92
-		}
93
-		$options = wp_parse_args( $options, $this->defaults );
94
-		?>
85
+     /**
86
+      * Display the importer welcome screen
87
+      */
88
+     public function display_page() {
89
+          $options = lsx_wetu_get_options();
90
+          foreach ( $options as $key => $value ) {
91
+               $value = trim( $value );
92
+          }
93
+          $options = wp_parse_args( $options, $this->defaults );
94
+          ?>
95 95
 		<div class="wrap">
96 96
 			<form method="post" class="">
97 97
 				<?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?>
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 							<td>
107 107
 								<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="
108 108
                                 <?php
109
-								if ( isset( $options['api_key'] ) ) {
110
-									echo esc_attr( $options['api_key'] );
111
-								}
112
-								?>
109
+                                        if ( isset( $options['api_key'] ) ) {
110
+                                             echo esc_attr( $options['api_key'] );
111
+                                        }
112
+                                        ?>
113 113
                                 " name="api_key" />
114 114
 							</td>
115 115
 						</tr>
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 							<td>
127 127
 								<input type="checkbox"
128 128
 								<?php
129
-								if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) {
130
-									echo esc_attr( 'checked="checked"' );
131
-								}
132
-								?>
129
+                                        if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) {
130
+                                             echo esc_attr( 'checked="checked"' );
131
+                                        }
132
+                                        ?>
133 133
 								name="disable_tour_title" />
134 134
 
135 135
 								<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>
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
 							<td>
143 143
 								<input type="checkbox"
144 144
 								<?php
145
-								if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
146
-									echo esc_attr( 'checked="checked"' );
147
-								}
148
-								?>
145
+                                        if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
146
+                                             echo esc_attr( 'checked="checked"' );
147
+                                        }
148
+                                        ?>
149 149
 								name="disable_tour_descriptions" />
150 150
 
151 151
 								<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>
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 							<td>
159 159
 								<input type="checkbox"
160 160
 								<?php
161
-								if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) {
162
-									echo esc_attr( 'checked="checked"' );
163
-								}
164
-								?>
161
+                                        if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) {
162
+                                             echo esc_attr( 'checked="checked"' );
163
+                                        }
164
+                                        ?>
165 165
 								name="disable_tour_tags" />
166 166
 
167 167
 								<small><?php esc_html_e( 'Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer' ); ?></small>
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 							<td>
176 176
 								<input type="checkbox"
177 177
 								<?php
178
-								if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) {
179
-									echo esc_attr( 'checked="checked"' );
180
-								}
181
-								?>
178
+                                        if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) {
179
+                                             echo esc_attr( 'checked="checked"' );
180
+                                        }
181
+                                        ?>
182 182
 								name="enable_tour_ref_column" />
183 183
 								<small><?php esc_html_e( 'Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer' ); ?></small>
184 184
 							</td>
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 							<td>
192 192
 								<input type="checkbox"
193 193
 								<?php
194
-								if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) {
195
-									echo esc_attr( 'checked="checked"' );
196
-								}
197
-								?>
194
+                                        if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) {
195
+                                             echo esc_attr( 'checked="checked"' );
196
+                                        }
197
+                                        ?>
198 198
 								name="enable_tour_featured_random" />
199 199
 								<small><?php esc_html_e( 'This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer' ); ?></small>
200 200
 							</td>
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
 							<td>
214 214
 								<input type="checkbox"
215 215
 								<?php
216
-								if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) {
217
-									echo esc_attr( 'checked="checked"' );
218
-								}
219
-								?>
216
+                                        if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) {
217
+                                             echo esc_attr( 'checked="checked"' );
218
+                                        }
219
+                                        ?>
220 220
 								name="disable_accommodation_title" />
221 221
 
222 222
 								<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>
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 							<td>
230 230
 								<input type="checkbox"
231 231
 								<?php
232
-								if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
233
-									echo esc_attr( 'checked="checked"' );
234
-								}
235
-								?>
232
+                                        if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
233
+                                             echo esc_attr( 'checked="checked"' );
234
+                                        }
235
+                                        ?>
236 236
 								name="disable_accommodation_descriptions" />
237 237
 								<small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small>
238 238
 							</td>
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 							<td>
245 245
 								<input type="checkbox"
246 246
 								<?php
247
-								if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) {
248
-									echo esc_attr( 'checked="checked"' );
249
-								}
250
-								?>
247
+                                        if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) {
248
+                                             echo esc_attr( 'checked="checked"' );
249
+                                        }
250
+                                        ?>
251 251
 								name="disable_accommodation_filtering" />
252 252
 								<small><?php esc_html_e( 'This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer' ); ?></small>
253 253
 							</td>
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 							<td>
261 261
 								<input type="checkbox"
262 262
 								<?php
263
-								if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
264
-									echo esc_attr( 'checked="checked"' );
265
-								}
266
-								?>
263
+                                        if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
264
+                                             echo esc_attr( 'checked="checked"' );
265
+                                        }
266
+                                        ?>
267 267
 								name="disable_accommodation_excerpts" />
268 268
 								<small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small>
269 269
 							</td>
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 							<td>
283 283
 								<input type="checkbox"
284 284
 								<?php
285
-								if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) {
286
-									echo esc_attr( 'checked="checked"' );
287
-								}
288
-								?>
285
+                                        if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) {
286
+                                             echo esc_attr( 'checked="checked"' );
287
+                                        }
288
+                                        ?>
289 289
 								name="disable_destination_title" />
290 290
 
291 291
 								<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>
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 							<td>
299 299
 								<input type="checkbox"
300 300
 								<?php
301
-								if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
302
-									echo esc_attr( 'checked="checked"' );
303
-								}
304
-								?>
301
+                                        if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
302
+                                             echo esc_attr( 'checked="checked"' );
303
+                                        }
304
+                                        ?>
305 305
 								name="disable_destination_descriptions" />
306 306
 								<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 307
 							</td>
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 							<td>
321 321
 								<input type="checkbox"
322 322
 								<?php
323
-								if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
324
-									echo esc_attr( 'checked="checked"' );
325
-								}
326
-								?>
323
+                                        if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
324
+                                             echo esc_attr( 'checked="checked"' );
325
+                                        }
326
+                                        ?>
327 327
 								name="image_replacing" />
328 328
 								<p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p>
329 329
 							</td>
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 							<td>
336 336
 								<input placeholder="" type="text" value="
337 337
                                 <?php
338
-								if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
339
-									echo esc_attr( $options['image_limit'] );
340
-								}
341
-								?>
338
+                                        if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
339
+                                             echo esc_attr( $options['image_limit'] );
340
+                                        }
341
+                                        ?>
342 342
                                 "
343 343
 								name="image_limit" />
344 344
 							</td>
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 							<td>
352 352
 								<input type="checkbox"
353 353
 								<?php
354
-								if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
355
-									echo esc_attr( 'checked="checked"' );
356
-								}
357
-								?>
354
+                                        if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
355
+                                             echo esc_attr( 'checked="checked"' );
356
+                                        }
357
+                                        ?>
358 358
 								name="image_scaling" />
359 359
 							</td>
360 360
 						</tr>
@@ -365,10 +365,10 @@  discard block
 block discarded – undo
365 365
 							<td>
366 366
 								<input placeholder="800" type="text" value="
367 367
                                 <?php
368
-								if ( isset( $options['width'] ) && '' !== $options['width'] ) {
369
-									echo esc_attr( $options['width'] );
370
-								}
371
-								?>
368
+                                        if ( isset( $options['width'] ) && '' !== $options['width'] ) {
369
+                                             echo esc_attr( $options['width'] );
370
+                                        }
371
+                                        ?>
372 372
                                 "
373 373
 								name="width" />
374 374
 							</td>
@@ -380,10 +380,10 @@  discard block
 block discarded – undo
380 380
 							<td>
381 381
 								<input placeholder="600" type="text" value="
382 382
                                 <?php
383
-								if ( isset( $options['height'] ) && '' !== $options['height'] ) {
384
-									echo esc_attr( $options['height'] );
385
-								}
386
-								?>
383
+                                        if ( isset( $options['height'] ) && '' !== $options['height'] ) {
384
+                                             echo esc_attr( $options['height'] );
385
+                                        }
386
+                                        ?>
387 387
                                 "
388 388
 								name="height" />
389 389
 							</td>
@@ -396,52 +396,52 @@  discard block
 block discarded – undo
396 396
 							<td>
397 397
 								<input type="radio"
398 398
 								<?php
399
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
400
-									echo esc_attr( 'checked="checked"' );
401
-								}
402
-								?>
399
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
400
+                                             echo esc_attr( 'checked="checked"' );
401
+                                        }
402
+                                        ?>
403 403
 								name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br />
404 404
 								<input type="radio"
405 405
 								<?php
406
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
407
-									echo esc_attr( 'checked="checked"' );
408
-								}
409
-								?>
406
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
407
+                                             echo esc_attr( 'checked="checked"' );
408
+                                        }
409
+                                        ?>
410 410
 								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 411
 								<input type="radio"
412 412
 								<?php
413
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
414
-									echo esc_attr( 'checked="checked"' );
415
-								}
416
-								?>
413
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
414
+                                             echo esc_attr( 'checked="checked"' );
415
+                                        }
416
+                                        ?>
417 417
 								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 418
 								<input type="radio"
419 419
 								<?php
420
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
421
-									echo esc_attr( 'checked="checked"' );
422
-								}
423
-								?>
420
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
421
+                                             echo esc_attr( 'checked="checked"' );
422
+                                        }
423
+                                        ?>
424 424
 								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 425
 								<input type="radio"
426 426
 								<?php
427
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
428
-									echo esc_attr( 'checked="checked"' );
429
-								}
430
-								?>
427
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
428
+                                             echo esc_attr( 'checked="checked"' );
429
+                                        }
430
+                                        ?>
431 431
 								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 432
 								<input type="radio"
433 433
 								<?php
434
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
435
-									echo esc_attr( 'checked="checked"' );
436
-								}
437
-								?>
434
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
435
+                                             echo esc_attr( 'checked="checked"' );
436
+                                        }
437
+                                        ?>
438 438
 								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 439
 								<input type="radio"
440 440
 								<?php
441
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
442
-									echo esc_attr( 'checked="checked"' );
443
-								}
444
-								?>
441
+                                        if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
442
+                                             echo esc_attr( 'checked="checked"' );
443
+                                        }
444
+                                        ?>
445 445
 								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 446
 							</td>
447 447
 						</tr>
@@ -459,28 +459,28 @@  discard block
 block discarded – undo
459 459
 							<td>
460 460
 								<select name="cron_schedule" id="cron_schedule"	class="widefat layout">
461 461
 									<?php
462
-									if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) {
463
-										$schedule = $options['cron_schedule'];
464
-									} else {
465
-										$schedule = 'daily';
466
-									}
467
-									$timeslots = array(
468
-										'daily'      => __( 'Daily', 'lsx-wetu-importer' ),
469
-										'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ),
470
-										'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ),
471
-										'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ),
472
-										'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ),
473
-										'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ),
474
-										'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ),
475
-										'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ),
476
-									);
477
-									foreach ( $timeslots as $key => $name ) {
478
-										$selected = ( $schedule == $key ) ? ' selected="selected"' : '';
479
-										?>
462
+                                             if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) {
463
+                                                  $schedule = $options['cron_schedule'];
464
+                                             } else {
465
+                                                  $schedule = 'daily';
466
+                                             }
467
+                                             $timeslots = array(
468
+                                                  'daily'      => __( 'Daily', 'lsx-wetu-importer' ),
469
+                                                  'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ),
470
+                                                  'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ),
471
+                                                  'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ),
472
+                                                  'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ),
473
+                                                  'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ),
474
+                                                  'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ),
475
+                                                  'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ),
476
+                                             );
477
+                                             foreach ( $timeslots as $key => $name ) {
478
+                                                  $selected = ( $schedule == $key ) ? ' selected="selected"' : '';
479
+                                                  ?>
480 480
 										<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 481
 										<?php
482
-									}
483
-									?>
482
+                                             }
483
+                                             ?>
484 484
 								</select>
485 485
 							</td>
486 486
 						</tr>
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 							<td>
492 492
 								<input type="checkbox"
493 493
 								<?php
494
-								if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
495
-									echo esc_attr( 'checked="checked"' );
496
-								}
497
-								?>
494
+                                        if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
495
+                                             echo esc_attr( 'checked="checked"' );
496
+                                        }
497
+                                        ?>
498 498
 								name="accommodation_images_cron" />
499 499
 								<p><?php esc_html_e( 'Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer' ); ?></p>
500 500
 							</td>
@@ -506,25 +506,25 @@  discard block
 block discarded – undo
506 506
 			</form>
507 507
 		</div>
508 508
 		<?php
509
-	}
509
+     }
510 510
 
511
-	/**
512
-	 * Save the options fields
513
-	 *
514
-	 * @return void
515
-	 */
516
-	public function save_options() {
517
-		if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
518
-			return;
519
-		}
520
-		$data_to_save = array();
521
-		foreach ( $this->defaults as $key => $field ) {
522
-			if ( isset( $_POST[ $key ] ) ) {
523
-				$data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] );
524
-			} else {
525
-				$data_to_save[ $key ] = '';
526
-			}
527
-		}
528
-		update_option( 'lsx_wetu_importer_settings', $data_to_save );
529
-	}
511
+     /**
512
+      * Save the options fields
513
+      *
514
+      * @return void
515
+      */
516
+     public function save_options() {
517
+          if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
518
+               return;
519
+          }
520
+          $data_to_save = array();
521
+          foreach ( $this->defaults as $key => $field ) {
522
+               if ( isset( $_POST[ $key ] ) ) {
523
+                    $data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] );
524
+               } else {
525
+                    $data_to_save[ $key ] = '';
526
+               }
527
+          }
528
+          update_option( 'lsx_wetu_importer_settings', $data_to_save );
529
+     }
530 530
 }
Please login to merge, or discard this patch.
classes/class-cron.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -16,102 +16,102 @@
 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_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
37
-	}
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_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
37
+     }
38 38
 
39
-	/**
40
-	 * Return an instance of this class.
41
-	 *
42
-	 * @since 1.0.0
43
-	 *
44
-	 * @return    object Cron()    A single instance of this class.
45
-	 */
46
-	public static function get_instance() {
47
-		// If the single instance hasn't been set, set it now.
48
-		if ( null === self::$instance ) {
49
-			self::$instance = new self();
50
-		}
51
-		return self::$instance;
52
-	}
39
+     /**
40
+      * Return an instance of this class.
41
+      *
42
+      * @since 1.0.0
43
+      *
44
+      * @return    object Cron()    A single instance of this class.
45
+      */
46
+     public static function get_instance() {
47
+          // If the single instance hasn't been set, set it now.
48
+          if ( null === self::$instance ) {
49
+               self::$instance = new self();
50
+          }
51
+          return self::$instance;
52
+     }
53 53
 
54
-	/**
55
-	 * Watches for changes in the button triggers.
56
-	 *
57
-	 * @return void
58
-	 */
59
-	public function watch_for_trigger() {
54
+     /**
55
+      * Watches for changes in the button triggers.
56
+      *
57
+      * @return void
58
+      */
59
+     public function watch_for_trigger() {
60 60
 
61
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
62
-			$options = lsx_wetu_get_options();
61
+          if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
62
+               $options = lsx_wetu_get_options();
63 63
 
64
-			// Check what state the option is in.
65
-			$accommodation_cron = 'deactivate';
66
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
67
-				$accommodation_cron = 'activate';
68
-			}
64
+               // Check what state the option is in.
65
+               $accommodation_cron = 'deactivate';
66
+               if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
67
+                    $accommodation_cron = 'activate';
68
+               }
69 69
 
70
-			// Check what state the cron is in.
71
-			$schedule = false;
72
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
73
-				$schedule = true;
74
-			}
70
+               // Check what state the cron is in.
71
+               $schedule = false;
72
+               if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
73
+                    $schedule = true;
74
+               }
75 75
 
76
-			// If activate and its not running.
77
-			if ( false === $schedule && 'activate' === $accommodation_cron ) {
78
-				$this->schedule();
79
-			} elseif ( true === $schedule && 'deactivate' === $accommodation_cron ) {
80
-				$this->deactivate();
81
-			}
82
-		}
83
-	}
76
+               // If activate and its not running.
77
+               if ( false === $schedule && 'activate' === $accommodation_cron ) {
78
+                    $this->schedule();
79
+               } elseif ( true === $schedule && 'deactivate' === $accommodation_cron ) {
80
+                    $this->deactivate();
81
+               }
82
+          }
83
+     }
84 84
 
85
-	/**
86
-	 * Remove our cron from the shedule.
87
-	 *
88
-	 * @return void
89
-	 */
90
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
91
-		wp_clear_scheduled_hook( $task );
92
-	}
85
+     /**
86
+      * Remove our cron from the shedule.
87
+      *
88
+      * @return void
89
+      */
90
+     public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
91
+          wp_clear_scheduled_hook( $task );
92
+     }
93 93
 
94
-	/**
95
-	 * This function will schedule the cron event.
96
-	 *
97
-	 * @param string $task
98
-	 * @return void
99
-	 */
100
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron' ) {
101
-		add_action( $task, array( $this, 'process' ) );
102
-		add_action( $task, 'lsx_wetu_accommodation_images_callback' );
103
-		add_action( 'lsx_wetu_accommodation_images_cron', 'lsx_wetu_accommodation_images_callback' );
104
-		wp_schedule_event( time(), 'daily', 'lsx_wetu_accommodation_images_cron' );
105
-	}
94
+     /**
95
+      * This function will schedule the cron event.
96
+      *
97
+      * @param string $task
98
+      * @return void
99
+      */
100
+     public function schedule( $task = 'lsx_wetu_accommodation_images_cron' ) {
101
+          add_action( $task, array( $this, 'process' ) );
102
+          add_action( $task, 'lsx_wetu_accommodation_images_callback' );
103
+          add_action( 'lsx_wetu_accommodation_images_cron', 'lsx_wetu_accommodation_images_callback' );
104
+          wp_schedule_event( time(), 'daily', 'lsx_wetu_accommodation_images_cron' );
105
+     }
106 106
 
107
-	/**
108
-	 * This is the function that will be triggered by the cron event.
109
-	 *
110
-	 * @return void
111
-	 */
112
-	public function process() {
113
-		// do your stuff.
114
-	}
107
+     /**
108
+      * This is the function that will be triggered by the cron event.
109
+      *
110
+      * @return void
111
+      */
112
+     public function process() {
113
+          // do your stuff.
114
+     }
115 115
 }
116 116
 Cron::get_instance();
117 117
 
Please login to merge, or discard this patch.