Passed
Push — master ( 47d946...50fd71 )
by Warwick
03:35
created
classes/class-cron.php 2 patches
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -16,242 +16,242 @@
 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
-	}
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
+     }
41 41
 
42
-	/**
43
-	 * Return an instance of this class.
44
-	 *
45
-	 * @since 1.0.0
46
-	 *
47
-	 * @return    object Cron()    A single instance of this class.
48
-	 */
49
-	public static function get_instance() {
50
-		// If the single instance hasn't been set, set it now.
51
-		if ( null === self::$instance ) {
52
-			self::$instance = new self();
53
-		}
54
-		return self::$instance;
55
-	}
42
+     /**
43
+      * Return an instance of this class.
44
+      *
45
+      * @since 1.0.0
46
+      *
47
+      * @return    object Cron()    A single instance of this class.
48
+      */
49
+     public static function get_instance() {
50
+          // If the single instance hasn't been set, set it now.
51
+          if ( null === self::$instance ) {
52
+               self::$instance = new self();
53
+          }
54
+          return self::$instance;
55
+     }
56 56
 
57
-	/**
58
-	 * Registers a 5 min schedule for us to use.
59
-	 *
60
-	 * @param  array $schedules
61
-	 * @return array
62
-	 */
63
-	public function register_schedule( $schedules ) {
64
-		$schedules['wetu-5-minutes'] = array(
65
-			'interval' => 5 * MINUTE_IN_SECONDS,
66
-			'display'  => __( 'Every 5 minutes', 'lsx-wetu-importer' ),
67
-		);
68
-		return $schedules;
69
-	}
57
+     /**
58
+      * Registers a 5 min schedule for us to use.
59
+      *
60
+      * @param  array $schedules
61
+      * @return array
62
+      */
63
+     public function register_schedule( $schedules ) {
64
+          $schedules['wetu-5-minutes'] = array(
65
+               'interval' => 5 * MINUTE_IN_SECONDS,
66
+               'display'  => __( 'Every 5 minutes', 'lsx-wetu-importer' ),
67
+          );
68
+          return $schedules;
69
+     }
70 70
 
71
-	/**
72
-	 * Watches for changes in the button triggers.
73
-	 *
74
-	 * @return void
75
-	 */
76
-	public function watch_for_trigger() {
71
+     /**
72
+      * Watches for changes in the button triggers.
73
+      *
74
+      * @return void
75
+      */
76
+     public function watch_for_trigger() {
77 77
 
78
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
79
-			$options = lsx_wetu_get_options();
78
+          if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
79
+               $options = lsx_wetu_get_options();
80 80
 
81
-			// Check what state the option is in.
82
-			$accommodation_cron = 'deactivate';
83
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
84
-				$accommodation_cron = 'activate';
85
-			}
81
+               // Check what state the option is in.
82
+               $accommodation_cron = 'deactivate';
83
+               if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
84
+                    $accommodation_cron = 'activate';
85
+               }
86 86
 
87
-			// Check what state the cron is in.
88
-			$scheduled = false;
89
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
90
-				$scheduled = true;
91
-			}
87
+               // Check what state the cron is in.
88
+               $scheduled = false;
89
+               if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
90
+                    $scheduled = true;
91
+               }
92 92
 
93
-			// If activate and its not running.
94
-			if ( false === $scheduled && 'activate' === $accommodation_cron ) {
95
-				$schedule = 'weekly';
96
-				$this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
97
-			} elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) {
98
-				$this->deactivate();
99
-			}
100
-		}
101
-	}
93
+               // If activate and its not running.
94
+               if ( false === $scheduled && 'activate' === $accommodation_cron ) {
95
+                    $schedule = 'weekly';
96
+                    $this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
97
+               } elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) {
98
+                    $this->deactivate();
99
+               }
100
+          }
101
+     }
102 102
 
103
-	/**
104
-	 * Remove our cron from the shedule.
105
-	 *
106
-	 * @return void
107
-	 */
108
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
109
-		wp_clear_scheduled_hook( $task, array( $task ) );
110
-	}
103
+     /**
104
+      * Remove our cron from the shedule.
105
+      *
106
+      * @return void
107
+      */
108
+     public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
109
+          wp_clear_scheduled_hook( $task, array( $task ) );
110
+     }
111 111
 
112
-	/**
113
-	 * This function will schedule the cron event.
114
-	 *
115
-	 * @param string $task
116
-	 * @param string $schedule
117
-	 * @param string $time
118
-	 * @return void
119
-	 */
120
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) {
121
-		$args = array( $task );
122
-		if ( '' === $time ) {
123
-			$time = time();
124
-		}
112
+     /**
113
+      * This function will schedule the cron event.
114
+      *
115
+      * @param string $task
116
+      * @param string $schedule
117
+      * @param string $time
118
+      * @return void
119
+      */
120
+     public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) {
121
+          $args = array( $task );
122
+          if ( '' === $time ) {
123
+               $time = time();
124
+          }
125 125
 
126
-		if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) {
127
-			$args[] = 'featured_image';
128
-		}
129
-		wp_schedule_event( $time, $schedule, $task, $args );
130
-	}
126
+          if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) {
127
+               $args[] = 'featured_image';
128
+          }
129
+          wp_schedule_event( $time, $schedule, $task, $args );
130
+     }
131 131
 
132
-	/**
133
-	 * This is the function that will be triggered by the cron event.
134
-	 *
135
-	 * @return void
136
-	 */
137
-	public function process( $task = '' ) {
138
-		switch ( $task ) {
139
-			case 'lsx_wetu_accommodation_images_cron':
140
-					$this->register_accommodation_images_sync();
141
-				break;
132
+     /**
133
+      * This is the function that will be triggered by the cron event.
134
+      *
135
+      * @return void
136
+      */
137
+     public function process( $task = '' ) {
138
+          switch ( $task ) {
139
+               case 'lsx_wetu_accommodation_images_cron':
140
+                         $this->register_accommodation_images_sync();
141
+                    break;
142 142
 
143
-			default:
144
-				break;
145
-		}
146
-	}
143
+               default:
144
+                    break;
145
+          }
146
+     }
147 147
 
148
-	/**
149
-	 * This is the function that will be triggered by the cron event.
150
-	 *
151
-	 * @return void
152
-	 */
153
-	public function register_accommodation_images_sync() {
154
-		$time = strtotime( '+5 min' );
155
-		if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) {
156
-			$this->load_items_to_sync( 'accommodation_images' );
157
-			$this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time );
158
-		}
159
-	}
148
+     /**
149
+      * This is the function that will be triggered by the cron event.
150
+      *
151
+      * @return void
152
+      */
153
+     public function register_accommodation_images_sync() {
154
+          $time = strtotime( '+5 min' );
155
+          if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) {
156
+               $this->load_items_to_sync( 'accommodation_images' );
157
+               $this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time );
158
+          }
159
+     }
160 160
 
161
-	/**
162
-	 * This is the function that will be triggered by the cron event.
163
-	 *
164
-	 * @return void
165
-	 */
166
-	public function cron_callback( $task = '', $featured_image = '' ) {
167
-		$has_accommodation = get_option( $task );
168
-		if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) {
169
-			$next_time = array_slice( $has_accommodation, 10 );
170
-			$this_time = array_slice( $has_accommodation, 0, 9 );
161
+     /**
162
+      * This is the function that will be triggered by the cron event.
163
+      *
164
+      * @return void
165
+      */
166
+     public function cron_callback( $task = '', $featured_image = '' ) {
167
+          $has_accommodation = get_option( $task );
168
+          if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) {
169
+               $next_time = array_slice( $has_accommodation, 10 );
170
+               $this_time = array_slice( $has_accommodation, 0, 9 );
171 171
 
172
-			$api_key = $this->get_api_key();
173
-			$url     = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids=';
172
+               $api_key = $this->get_api_key();
173
+               $url     = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids=';
174 174
 
175
-			// Run through the current items.
176
-			foreach ( $this_time as $accommodation ) {
177
-				$wetu_id   = get_post_meta( $accommodation, 'lsx_wetu_id', true );
178
-				$last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true );
175
+               // Run through the current items.
176
+               foreach ( $this_time as $accommodation ) {
177
+                    $wetu_id   = get_post_meta( $accommodation, 'lsx_wetu_id', true );
178
+                    $last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true );
179 179
 
180
-				$accommodation_info = wp_remote_get( $url . $wetu_id );
181
-				if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) {
182
-					$adata = json_decode( $accommodation_info['body'], true );
180
+                    $accommodation_info = wp_remote_get( $url . $wetu_id );
181
+                    if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) {
182
+                         $adata = json_decode( $accommodation_info['body'], true );
183 183
 
184
-					if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) {
185
-						$modified_time = strtotime( $adata[0]['last_modified'] );
186
-						if ( $modified_time > $last_date ) {
187
-							$accommodation_importer = new \LSX_WETU_Importer_Accommodation();
188
-							$accommodation_importer->create_main_gallery( $adata, $accommodation );
189
-							if ( '' !== $featured_image ) {
190
-								$accommodation_importer->set_featured_image( $adata, $accommodation );
191
-							}
192
-							update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date );
193
-						}
194
-					}
195
-				}
196
-			}
184
+                         if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) {
185
+                              $modified_time = strtotime( $adata[0]['last_modified'] );
186
+                              if ( $modified_time > $last_date ) {
187
+                                   $accommodation_importer = new \LSX_WETU_Importer_Accommodation();
188
+                                   $accommodation_importer->create_main_gallery( $adata, $accommodation );
189
+                                   if ( '' !== $featured_image ) {
190
+                                        $accommodation_importer->set_featured_image( $adata, $accommodation );
191
+                                   }
192
+                                   update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date );
193
+                              }
194
+                         }
195
+                    }
196
+               }
197 197
 
198
-			// Save the values for next time.
199
-			if ( ! empty( $next_time ) ) {
200
-				update_option( $task, $next_time );
201
-			} else {
202
-				delete_option( $task );
203
-				$this->deactivate( $task );
204
-			}
205
-		} else {
206
-			$this->deactivate( $task );
207
-			update_option( 'lsx_wetu_nexttime', $task );
208
-		}
209
-	}
198
+               // Save the values for next time.
199
+               if ( ! empty( $next_time ) ) {
200
+                    update_option( $task, $next_time );
201
+               } else {
202
+                    delete_option( $task );
203
+                    $this->deactivate( $task );
204
+               }
205
+          } else {
206
+               $this->deactivate( $task );
207
+               update_option( 'lsx_wetu_nexttime', $task );
208
+          }
209
+     }
210 210
 
211
-	/**
212
-	 * This will grab the accommodation ids and load them up into an option field.
213
-	 *
214
-	 * @param  string $task
215
-	 * @return void
216
-	 */
217
-	public function load_items_to_sync( $task = 'accommodation_images' ) {
218
-		$args = array(
219
-			'post_status'    => 'publish',
220
-			'posts_per_page' => -1,
221
-			'nopagin'        => true,
222
-			'fields'         => 'ids',
223
-		);
224
-		switch ( $task ) {
225
-			case 'accommodation_images':
226
-					$args['post_type'] = 'accommodation';
227
-				break;
211
+     /**
212
+      * This will grab the accommodation ids and load them up into an option field.
213
+      *
214
+      * @param  string $task
215
+      * @return void
216
+      */
217
+     public function load_items_to_sync( $task = 'accommodation_images' ) {
218
+          $args = array(
219
+               'post_status'    => 'publish',
220
+               'posts_per_page' => -1,
221
+               'nopagin'        => true,
222
+               'fields'         => 'ids',
223
+          );
224
+          switch ( $task ) {
225
+               case 'accommodation_images':
226
+                         $args['post_type'] = 'accommodation';
227
+                    break;
228 228
 
229
-			default:
230
-				break;
231
-		}
232
-		$items = new \WP_Query( $args );
233
-		if ( $items->have_posts() ) {
234
-			update_option( 'lsx_wetu_' . $task . '_sync', $items->posts );
235
-		}
236
-	}
229
+               default:
230
+                    break;
231
+          }
232
+          $items = new \WP_Query( $args );
233
+          if ( $items->have_posts() ) {
234
+               update_option( 'lsx_wetu_' . $task . '_sync', $items->posts );
235
+          }
236
+     }
237 237
 
238
-	/**
239
-	 * Gets the API key stored in the options table.
240
-	 *
241
-	 * @return string
242
-	 */
243
-	public function get_api_key() {
244
-		$api_key = false;
245
-		$options = lsx_wetu_get_options();
238
+     /**
239
+      * Gets the API key stored in the options table.
240
+      *
241
+      * @return string
242
+      */
243
+     public function get_api_key() {
244
+          $api_key = false;
245
+          $options = lsx_wetu_get_options();
246 246
 
247
-		if ( ! defined( 'WETU_API_KEY' ) ) {
248
-			if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
249
-				$api_key = $options['api_key'];
250
-			}
251
-		} else {
252
-			$api_key = WETU_API_KEY;
253
-		}
254
-		return $api_key;
255
-	}
247
+          if ( ! defined( 'WETU_API_KEY' ) ) {
248
+               if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
249
+                    $api_key = $options['api_key'];
250
+               }
251
+          } else {
252
+               $api_key = WETU_API_KEY;
253
+          }
254
+          return $api_key;
255
+     }
256 256
 }
257 257
 Cron::get_instance();
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  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 );
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 40
 	}
41 41
 
42 42
 	/**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public static function get_instance() {
50 50
 		// If the single instance hasn't been set, set it now.
51
-		if ( null === self::$instance ) {
51
+		if (null === self::$instance) {
52 52
 			self::$instance = new self();
53 53
 		}
54 54
 		return self::$instance;
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 	 * @param  array $schedules
61 61
 	 * @return array
62 62
 	 */
63
-	public function register_schedule( $schedules ) {
63
+	public function register_schedule($schedules) {
64 64
 		$schedules['wetu-5-minutes'] = array(
65 65
 			'interval' => 5 * MINUTE_IN_SECONDS,
66
-			'display'  => __( 'Every 5 minutes', 'lsx-wetu-importer' ),
66
+			'display'  => __('Every 5 minutes', 'lsx-wetu-importer'),
67 67
 		);
68 68
 		return $schedules;
69 69
 	}
@@ -75,26 +75,26 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function watch_for_trigger() {
77 77
 
78
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
78
+		if (isset($_GET['page']) && 'lsx-wetu-importer' === $_GET['page'] && isset($_GET['tab']) && 'settings' === $_GET['tab']) {
79 79
 			$options = lsx_wetu_get_options();
80 80
 
81 81
 			// Check what state the option is in.
82 82
 			$accommodation_cron = 'deactivate';
83
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
83
+			if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) {
84 84
 				$accommodation_cron = 'activate';
85 85
 			}
86 86
 
87 87
 			// Check what state the cron is in.
88 88
 			$scheduled = false;
89
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
89
+			if (wp_next_scheduled('lsx_wetu_accommodation_images_cron')) {
90 90
 				$scheduled = true;
91 91
 			}
92 92
 
93 93
 			// If activate and its not running.
94
-			if ( false === $scheduled && 'activate' === $accommodation_cron ) {
94
+			if (false === $scheduled && 'activate' === $accommodation_cron) {
95 95
 				$schedule = 'weekly';
96
-				$this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
97
-			} elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) {
96
+				$this->schedule('lsx_wetu_accommodation_images_cron', $schedule);
97
+			} elseif (true === $scheduled && 'deactivate' === $accommodation_cron) {
98 98
 				$this->deactivate();
99 99
 			}
100 100
 		}
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return void
107 107
 	 */
108
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
109
-		wp_clear_scheduled_hook( $task, array( $task ) );
108
+	public function deactivate($task = 'lsx_wetu_accommodation_images_cron') {
109
+		wp_clear_scheduled_hook($task, array($task));
110 110
 	}
111 111
 
112 112
 	/**
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
 	 * @param string $time
118 118
 	 * @return void
119 119
 	 */
120
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) {
121
-		$args = array( $task );
122
-		if ( '' === $time ) {
120
+	public function schedule($task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm') {
121
+		$args = array($task);
122
+		if ('' === $time) {
123 123
 			$time = time();
124 124
 		}
125 125
 
126
-		if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) {
126
+		if (isset($_GET['accommodation_images_cron_featured']) && '' !== $_GET['accommodation_images_cron_featured']) {
127 127
 			$args[] = 'featured_image';
128 128
 		}
129
-		wp_schedule_event( $time, $schedule, $task, $args );
129
+		wp_schedule_event($time, $schedule, $task, $args);
130 130
 	}
131 131
 
132 132
 	/**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return void
136 136
 	 */
137
-	public function process( $task = '' ) {
138
-		switch ( $task ) {
137
+	public function process($task = '') {
138
+		switch ($task) {
139 139
 			case 'lsx_wetu_accommodation_images_cron':
140 140
 					$this->register_accommodation_images_sync();
141 141
 				break;
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	 * @return void
152 152
 	 */
153 153
 	public function register_accommodation_images_sync() {
154
-		$time = strtotime( '+5 min' );
155
-		if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) {
156
-			$this->load_items_to_sync( 'accommodation_images' );
157
-			$this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time );
154
+		$time = strtotime('+5 min');
155
+		if (!wp_next_scheduled('lsx_wetu_accommodation_images_sync')) {
156
+			$this->load_items_to_sync('accommodation_images');
157
+			$this->schedule('lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time);
158 158
 		}
159 159
 	}
160 160
 
@@ -163,48 +163,48 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return void
165 165
 	 */
166
-	public function cron_callback( $task = '', $featured_image = '' ) {
167
-		$has_accommodation = get_option( $task );
168
-		if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) {
169
-			$next_time = array_slice( $has_accommodation, 10 );
170
-			$this_time = array_slice( $has_accommodation, 0, 9 );
166
+	public function cron_callback($task = '', $featured_image = '') {
167
+		$has_accommodation = get_option($task);
168
+		if (false !== $has_accommodation && !empty($has_accommodation)) {
169
+			$next_time = array_slice($has_accommodation, 10);
170
+			$this_time = array_slice($has_accommodation, 0, 9);
171 171
 
172 172
 			$api_key = $this->get_api_key();
173
-			$url     = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids=';
173
+			$url     = 'https://wetu.com/API/Pins/'.$api_key.'/Get?all=include&ids=';
174 174
 
175 175
 			// Run through the current items.
176
-			foreach ( $this_time as $accommodation ) {
177
-				$wetu_id   = get_post_meta( $accommodation, 'lsx_wetu_id', true );
178
-				$last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true );
176
+			foreach ($this_time as $accommodation) {
177
+				$wetu_id   = get_post_meta($accommodation, 'lsx_wetu_id', true);
178
+				$last_date = get_post_meta($accommodation, 'lsx_wetu_modified_date', true);
179 179
 
180
-				$accommodation_info = wp_remote_get( $url . $wetu_id );
181
-				if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) {
182
-					$adata = json_decode( $accommodation_info['body'], true );
180
+				$accommodation_info = wp_remote_get($url.$wetu_id);
181
+				if (!empty($accommodation_info) && isset($accommodation_info['response']) && isset($accommodation_info['response']['code']) && 200 === $accommodation_info['response']['code']) {
182
+					$adata = json_decode($accommodation_info['body'], true);
183 183
 
184
-					if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) {
185
-						$modified_time = strtotime( $adata[0]['last_modified'] );
186
-						if ( $modified_time > $last_date ) {
184
+					if (isset($adata[0]) && isset($adata[0]['last_modified']) && '' !== $adata[0]['last_modified']) {
185
+						$modified_time = strtotime($adata[0]['last_modified']);
186
+						if ($modified_time > $last_date) {
187 187
 							$accommodation_importer = new \LSX_WETU_Importer_Accommodation();
188
-							$accommodation_importer->create_main_gallery( $adata, $accommodation );
189
-							if ( '' !== $featured_image ) {
190
-								$accommodation_importer->set_featured_image( $adata, $accommodation );
188
+							$accommodation_importer->create_main_gallery($adata, $accommodation);
189
+							if ('' !== $featured_image) {
190
+								$accommodation_importer->set_featured_image($adata, $accommodation);
191 191
 							}
192
-							update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date );
192
+							update_post_meta($accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date);
193 193
 						}
194 194
 					}
195 195
 				}
196 196
 			}
197 197
 
198 198
 			// Save the values for next time.
199
-			if ( ! empty( $next_time ) ) {
200
-				update_option( $task, $next_time );
201
-			} else {
202
-				delete_option( $task );
203
-				$this->deactivate( $task );
199
+			if (!empty($next_time)) {
200
+				update_option($task, $next_time);
201
+			}else {
202
+				delete_option($task);
203
+				$this->deactivate($task);
204 204
 			}
205
-		} else {
206
-			$this->deactivate( $task );
207
-			update_option( 'lsx_wetu_nexttime', $task );
205
+		}else {
206
+			$this->deactivate($task);
207
+			update_option('lsx_wetu_nexttime', $task);
208 208
 		}
209 209
 	}
210 210
 
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 	 * @param  string $task
215 215
 	 * @return void
216 216
 	 */
217
-	public function load_items_to_sync( $task = 'accommodation_images' ) {
217
+	public function load_items_to_sync($task = 'accommodation_images') {
218 218
 		$args = array(
219 219
 			'post_status'    => 'publish',
220 220
 			'posts_per_page' => -1,
221 221
 			'nopagin'        => true,
222 222
 			'fields'         => 'ids',
223 223
 		);
224
-		switch ( $task ) {
224
+		switch ($task) {
225 225
 			case 'accommodation_images':
226 226
 					$args['post_type'] = 'accommodation';
227 227
 				break;
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 			default:
230 230
 				break;
231 231
 		}
232
-		$items = new \WP_Query( $args );
233
-		if ( $items->have_posts() ) {
234
-			update_option( 'lsx_wetu_' . $task . '_sync', $items->posts );
232
+		$items = new \WP_Query($args);
233
+		if ($items->have_posts()) {
234
+			update_option('lsx_wetu_'.$task.'_sync', $items->posts);
235 235
 		}
236 236
 	}
237 237
 
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 		$api_key = false;
245 245
 		$options = lsx_wetu_get_options();
246 246
 
247
-		if ( ! defined( 'WETU_API_KEY' ) ) {
248
-			if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
247
+		if (!defined('WETU_API_KEY')) {
248
+			if (isset($options['api_key']) && '' !== $options['api_key']) {
249 249
 				$api_key = $options['api_key'];
250 250
 			}
251
-		} else {
251
+		}else {
252 252
 			$api_key = WETU_API_KEY;
253 253
 		}
254 254
 		return $api_key;
Please login to merge, or discard this patch.
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.