Passed
Push — master ( e65b13...58d22b )
by Warwick
02:08
created
classes/class-lsx-logger.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace lsx;
4 4
 
5
-if ( ! class_exists( '\lsx\LSX_Logger' ) ) {
5
+if (!class_exists('\lsx\LSX_Logger')) {
6 6
 
7 7
 	/**
8 8
 	 * LSX_Logger Main Class
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		 * Constructor.
33 33
 		 */
34 34
 		public function __construct() {
35
-			add_action( 'wp_before_admin_bar_render', array( $this, 'wp_admin_bar_menu' ) );
35
+			add_action('wp_before_admin_bar_render', array($this, 'wp_admin_bar_menu'));
36 36
 		}
37 37
 
38 38
 		/**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		public static function init() {
44 44
 
45 45
 			// If the single instance hasn't been set, set it now.
46
-			if ( ! isset( self::$instance ) ) {
46
+			if (!isset(self::$instance)) {
47 47
 				self::$instance = new self();
48 48
 			}
49 49
 			return self::$instance;
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 		 * @param $message string
58 58
 		 * @return  void
59 59
 		 */
60
-		public function log( $plugin = '', $key = '', $message = '' ) {
61
-			$this->logs[ $plugin ][ $key ] = $message;
60
+		public function log($plugin = '', $key = '', $message = '') {
61
+			$this->logs[$plugin][$key] = $message;
62 62
 		}
63 63
 
64 64
 		/**
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
 		 * @param $plugin string | boolean
68 68
 		 * @return  string
69 69
 		 */
70
-		public function output_log( $plugin = false ) {
70
+		public function output_log($plugin = false) {
71 71
 			$return = '';
72
-			if ( ! empty( $this->logs ) ) {
73
-				foreach ( $this->logs as $plugin_key => $log ) {
72
+			if (!empty($this->logs)) {
73
+				foreach ($this->logs as $plugin_key => $log) {
74 74
 
75 75
 					$return = '<div style="padding: 15px;">';
76
-					if ( false !== $plugin && $plugin_key !== $plugin ) {
76
+					if (false !== $plugin && $plugin_key !== $plugin) {
77 77
 						continue;
78
-					} else if ( false === $plugin ) {
79
-						$return .= '<h4>' . $plugin_key . '</h4>';
78
+					}else if (false === $plugin) {
79
+						$return .= '<h4>'.$plugin_key.'</h4>';
80 80
 					}
81 81
 					$return .= '<ul>';
82
-					$return .= $this->loop_through_logs( $log );
82
+					$return .= $this->loop_through_logs($log);
83 83
 					$return .= '</ul>';
84 84
 					$return .= '</div>';
85 85
 				}
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 		 * @param $log_array array
94 94
 		 * @return  string
95 95
 		 */
96
-		public function loop_through_logs( $log_array = array() ) {
96
+		public function loop_through_logs($log_array = array()) {
97 97
 			$return = '';
98
-			foreach ( $log_array as $key => $message ) {
99
-				$return .= '<li>' . $message . ' <small>(' . $key . ')</small></li>';
98
+			foreach ($log_array as $key => $message) {
99
+				$return .= '<li>'.$message.' <small>('.$key.')</small></li>';
100 100
 			}
101 101
 			return $return;
102 102
 		}
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 		 */
109 109
 		function wp_admin_bar_menu() {
110 110
 			global $wp_admin_bar;
111
-			$wp_admin_bar->add_menu( array(
111
+			$wp_admin_bar->add_menu(array(
112 112
 				'parent' => false,
113 113
 				'id' => 'lsx_logger',
114
-				'title' => __( 'LSX Log' ), // link title
114
+				'title' => __('LSX Log'), // link title
115 115
 				'href' => '',
116 116
 			));
117
-			$wp_admin_bar->add_menu( array(
117
+			$wp_admin_bar->add_menu(array(
118 118
 				'parent' => 'lsx_logger',
119 119
 				'id' => 'lsx_logger_output',
120 120
 				'title' => '', // link title
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-accommodation.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	 * Formats the row for output on the screen.
394 394
 	 *
395 395
 	 * @param boolean $row the current row to format.
396
-	 * @return void
396
+	 * @return string|null
397 397
 	 */
398 398
 	public function format_row( $row = false ) {
399 399
 		if ( false !== $row ) {
@@ -652,6 +652,7 @@  discard block
 block discarded – undo
652 652
 
653 653
 	/**
654 654
 	 * Set the team memberon each item.
655
+	 * @param boolean $team_members
655 656
 	 */
656 657
 	public function set_team_member( $id, $team_members ) {
657 658
 		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
@@ -663,6 +664,7 @@  discard block
 block discarded – undo
663 664
 
664 665
 	/**
665 666
 	 * Set the safari brand
667
+	 * @param boolean $safari_brands
666 668
 	 */
667 669
 	public function set_safari_brands( $id, $safari_brands ) {
668 670
 		foreach ( $safari_brands as $safari_brand ) {
Please login to merge, or discard this patch.
Spacing   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
77 77
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
78 78
 		//} elseif ( false !== $this->api_key ) {
79
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
79
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
80 80
 			$this->url_qs = 'all=include';
81 81
 		//}
82 82
 
83
-		$temp_options = get_option( '_lsx-to_settings', false );
83
+		$temp_options = get_option('_lsx-to_settings', false);
84 84
 
85
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
86
-			$this->options = $temp_options[ $this->plugin_slug ];
85
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
86
+			$this->options = $temp_options[$this->plugin_slug];
87 87
 		}
88 88
 
89
-		$accommodation_options = get_option( 'lsx_wetu_importer_accommodation_settings',false );
89
+		$accommodation_options = get_option('lsx_wetu_importer_accommodation_settings', false);
90 90
 
91
-		if ( false !== $accommodation_options ) {
91
+		if (false !== $accommodation_options) {
92 92
 			$this->accommodation_options = $accommodation_options;
93 93
 		}
94 94
 	}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			</div>
107 107
 
108 108
 			<form method="get" action="" id="posts-filter">
109
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
109
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
110 110
 
111 111
 				<table class="wp-list-table widefat fixed posts">
112 112
 					<?php $this->table_header(); ?>
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 					<tbody id="the-list">
115 115
 						<tr class="post-0 type-tour status-none" id="post-0">
116 116
 							<th class="check-column" scope="row">
117
-								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label>
117
+								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label>
118 118
 							</th>
119 119
 							<td class="post-title page-title column-title">
120 120
 								<strong>
121
-									<?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?>
121
+									<?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?>
122 122
 								</strong>
123 123
 							</td>
124 124
 							<td class="date column-date">
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 
133 133
 				</table>
134 134
 
135
-				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'lsx-wetu-importer' ); ?>" />
136
-					<input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'lsx-wetu-importer' ); ?>" />
135
+				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'lsx-wetu-importer'); ?>" />
136
+					<input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'lsx-wetu-importer'); ?>" />
137 137
 				</p>
138 138
 			</form>
139 139
 
@@ -143,65 +143,65 @@  discard block
 block discarded – undo
143 143
 
144 144
 					<div class="row">
145 145
 						<div class="settings-all" style="width:30%;display:block;float:left;">
146
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
146
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
147 147
 							<ul>
148
-								<li><input class="content select-all" <?php $this->checked( $this->accommodation_options, 'all' ); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e( 'Select All', 'lsx-wetu-importer' ); ?></li>
149
-								<?php if ( ! isset( $this->options['disable_accommodation_descriptions'] ) ) { ?>
150
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'description' ); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
148
+								<li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li>
149
+								<?php if (!isset($this->options['disable_accommodation_descriptions'])) { ?>
150
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
151 151
 								<?php } ?>
152
-								<?php if ( ! isset( $this->options['disable_accommodation_excerpts'] ) ) { ?>
153
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'excerpt' ); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'lsx-wetu-importer' ); ?></li>
152
+								<?php if (!isset($this->options['disable_accommodation_excerpts'])) { ?>
153
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e('Excerpt', 'lsx-wetu-importer'); ?></li>
154 154
 								<?php } ?>
155 155
 
156
-								<?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
157
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'gallery' ); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li>
156
+								<?php if (!isset($this->accommodation_settings['disable_single'])) { ?>
157
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li>
158 158
 								<?php } ?>
159
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'category' ); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'lsx-wetu-importer' ); ?></li>
160
-								<?php if ( class_exists( 'LSX_TO_Maps' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
161
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'location' ); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?></li>
159
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li>
160
+								<?php if (class_exists('LSX_TO_Maps') && !isset($this->accommodation_settings['disable_single'])) { ?>
161
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?></li>
162 162
 								<?php } ?>
163
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'destination' ); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'lsx-wetu-importer' ); ?></li>
164
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rating' ); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'lsx-wetu-importer' ); ?></li>
165
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rooms' ); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'lsx-wetu-importer' ); ?></li>
166
-
167
-								<?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
168
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'checkin' ); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'lsx-wetu-importer' ); ?></li>
169
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'facilities' ); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'lsx-wetu-importer' ); ?></li>
170
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'friendly' ); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'lsx-wetu-importer' ); ?></li>
163
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Connect Destinations', 'lsx-wetu-importer'); ?></li>
164
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e('Rating', 'lsx-wetu-importer'); ?></li>
165
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e('Rooms', 'lsx-wetu-importer'); ?></li>
166
+
167
+								<?php if (!isset($this->accommodation_settings['disable_single'])) { ?>
168
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e('Check In / Check Out', 'lsx-wetu-importer'); ?></li>
169
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e('Facilities', 'lsx-wetu-importer'); ?></li>
170
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e('Friendly', 'lsx-wetu-importer'); ?></li>
171 171
 								<?php } ?>
172 172
 
173
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'special_interests' ); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'lsx-wetu-importer' ); ?></li>
174
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'spoken_languages' ); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'lsx-wetu-importer' ); ?></li>
173
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e('Special Interests', 'lsx-wetu-importer'); ?></li>
174
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e('Spoken Languages', 'lsx-wetu-importer'); ?></li>
175 175
 
176
-								<?php if ( class_exists( 'LSX_TO_Videos' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
177
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'videos' ); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li>
176
+								<?php if (class_exists('LSX_TO_Videos') && !isset($this->accommodation_settings['disable_single'])) { ?>
177
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li>
178 178
 								<?php } ?>
179 179
 							</ul>
180
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
180
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
181 181
 							<ul>
182
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'featured_image' ); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?></li>
183
-								<?php if ( class_exists( 'LSX_Banners' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
184
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'banner_image' ); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?></li>
182
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?></li>
183
+								<?php if (class_exists('LSX_Banners') && !isset($this->accommodation_settings['disable_single'])) { ?>
184
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?></li>
185 185
 								<?php } ?>
186 186
 							</ul>
187 187
 						</div>
188 188
 						<div style="width:30%;display:block;float:left;">
189
-							<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
190
-							<?php $this->team_member_checkboxes( $this->accommodation_options ); ?>
189
+							<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
190
+							<?php $this->team_member_checkboxes($this->accommodation_options); ?>
191 191
 						</div>
192 192
 
193 193
 						<div style="width:30%;display:block;float:left;">
194
-							<h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3>
194
+							<h3><?php esc_html_e('Assign a Safari Brand'); ?></h3>
195 195
 							<?php
196
-								echo wp_kses_post( $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ) );
196
+								echo wp_kses_post($this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options));
197 197
 							?>
198 198
 						</div>
199 199
 
200 200
 						<br clear="both" />
201 201
 					</div>
202 202
 
203
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
204
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
203
+					<h3><?php esc_html_e('Your List'); ?></h3>
204
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
205 205
 					<table class="wp-list-table widefat fixed posts">
206 206
 						<?php $this->table_header(); ?>
207 207
 
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
 
214 214
 					</table>
215 215
 
216
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
216
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
217 217
 				</form>
218 218
 			</div>
219 219
 
220 220
 			<div style="display:none;" class="completed-list-wrapper">
221
-				<h3><?php esc_html_e( 'Completed' ); ?> - <small><?php esc_html_e( 'Import your', 'lsx-wetu-importer' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations' ); ?></a> <?php esc_html_e( 'next', 'lsx-wetu-importer' ); ?></small></h3>
221
+				<h3><?php esc_html_e('Completed'); ?> - <small><?php esc_html_e('Import your', 'lsx-wetu-importer'); ?> <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations'); ?></a> <?php esc_html_e('next', 'lsx-wetu-importer'); ?></small></h3>
222 222
 				<ul>
223 223
 				</ul>
224 224
 			</div>
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 	 * search_form
231 231
 	 */
232 232
 	public function update_options_form() {
233
-		echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'lsx-wetu-importer' ) . '</h3>';
233
+		echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').'</h3>';
234 234
 
235
-		$accommodation = get_transient( 'lsx_ti_accommodation' );
235
+		$accommodation = get_transient('lsx_ti_accommodation');
236 236
 
237 237
 		//if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) {
238 238
 			//$this->update_options();
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
 	 * Save the list of Accommodation into an option
246 246
 	 */
247 247
 	public function update_options() {
248
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
248
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
249 249
 
250
-		$accommodation = json_decode( $data, true );
250
+		$accommodation = json_decode($data, true);
251 251
 
252
-		if ( isset( $accommodation['error'] ) ) {
252
+		if (isset($accommodation['error'])) {
253 253
 			return $accommodation['error'];
254
-		} elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) {
255
-			set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 );
254
+		} elseif (isset($accommodation) && !empty($accommodation)) {
255
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
256 256
 			return true;
257 257
 		}
258 258
 	}
@@ -264,116 +264,116 @@  discard block
 block discarded – undo
264 264
 		$return = false;
265 265
 
266 266
 		// @codingStandardsIgnoreLine
267
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' ) {
267
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') {
268 268
 
269 269
 			$searched_items = false;
270 270
 
271 271
 			// @codingStandardsIgnoreLine
272
-			if ( isset( $_POST['keyword'] ) ) {
272
+			if (isset($_POST['keyword'])) {
273 273
 				// @codingStandardsIgnoreLine
274 274
 				$keyphrases = $_POST['keyword'];
275
-			} else {
276
-				$keyphrases = array( 0 );
275
+			}else {
276
+				$keyphrases = array(0);
277 277
 			}
278 278
 
279
-			if ( ! is_array( $keyphrases ) ) {
280
-				$keyphrases = array( $keyphrases );
279
+			if (!is_array($keyphrases)) {
280
+				$keyphrases = array($keyphrases);
281 281
 			}
282
-			foreach ( $keyphrases as &$keyword ) {
283
-				$keyword = ltrim( rtrim( $keyword ) );
282
+			foreach ($keyphrases as &$keyword) {
283
+				$keyword = ltrim(rtrim($keyword));
284 284
 			}
285 285
 
286 286
 			$post_status = false;
287 287
 
288
-			if ( in_array( 'publish', $keyphrases ) ) {
288
+			if (in_array('publish', $keyphrases)) {
289 289
 				$post_status = 'publish';
290 290
 			}
291
-			if ( in_array( 'pending', $keyphrases ) ) {
291
+			if (in_array('pending', $keyphrases)) {
292 292
 				$post_status = 'pending';
293 293
 			}
294
-			if ( in_array( 'draft', $keyphrases ) ) {
294
+			if (in_array('draft', $keyphrases)) {
295 295
 				$post_status = 'draft';
296 296
 			}
297
-			if ( in_array( 'import', $keyphrases ) ) {
297
+			if (in_array('import', $keyphrases)) {
298 298
 				$post_status = 'import';
299 299
 			}
300 300
 
301 301
 			// If there is a post status use it.
302
-			if ( false !== $post_status ) {
302
+			if (false !== $post_status) {
303 303
 
304 304
 				$accommodation = array();
305 305
 				$current_accommodation = $this->find_current_accommodation();
306
-				if ( ! empty( $current_accommodation ) ) {
307
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
308
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
306
+				if (!empty($current_accommodation)) {
307
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
308
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
309 309
 					}
310 310
 				}
311 311
 
312 312
 				// Run through each accommodation and use it.
313
-				if ( ! empty( $accommodation ) ) {
314
-					foreach ( $accommodation as $row_key => $row ) {
315
-						if ( 'import' === $post_status ) {
316
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
317
-								$current_status = get_post_status( $row['post_id'] );
318
-								if ( 'draft' === $current_status ) {
319
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
313
+				if (!empty($accommodation)) {
314
+					foreach ($accommodation as $row_key => $row) {
315
+						if ('import' === $post_status) {
316
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
317
+								$current_status = get_post_status($row['post_id']);
318
+								if ('draft' === $current_status) {
319
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
320 320
 								}
321
-							} else {
321
+							}else {
322 322
 								continue;
323 323
 							}
324
-						} else {
325
-							if ( 0 === $row['post_id'] ) {
324
+						}else {
325
+							if (0 === $row['post_id']) {
326 326
 								continue;
327
-							} else {
328
-								$current_status = get_post_status( $row['post_id'] );
329
-								if ( $current_status !== $post_status ) {
327
+							}else {
328
+								$current_status = get_post_status($row['post_id']);
329
+								if ($current_status !== $post_status) {
330 330
 									continue;
331 331
 								}
332 332
 							}
333
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
333
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
334 334
 						}
335 335
 					}
336 336
 				}
337
-			} else {
338
-				$key_string_search = implode( '+', $keyphrases );
339
-				$search_data = file_get_contents( $this->url . '/Search/' . $key_string_search );
340
-				$search_data = json_decode( $search_data, true );
337
+			}else {
338
+				$key_string_search = implode('+', $keyphrases);
339
+				$search_data = file_get_contents($this->url.'/Search/'.$key_string_search);
340
+				$search_data = json_decode($search_data, true);
341 341
 
342
-				if ( ! isset( $search_data['error'] ) ) {
343
-					foreach ( $search_data as $sdata ) {
342
+				if (!isset($search_data['error'])) {
343
+					foreach ($search_data as $sdata) {
344 344
 
345
-						if ( 'Destination' === trim( $sdata['type'] ) || 'Activity' === trim( $sdata['type'] ) || 'Restaurant' === trim( $sdata['type'] ) || 'None' === trim( $sdata['type'] ) || 'Site / Attraction' === trim( $sdata['type'] ) || '' === trim( $sdata['type'] ) ) {
345
+						if ('Destination' === trim($sdata['type']) || 'Activity' === trim($sdata['type']) || 'Restaurant' === trim($sdata['type']) || 'None' === trim($sdata['type']) || 'Site / Attraction' === trim($sdata['type']) || '' === trim($sdata['type'])) {
346 346
 							continue;
347 347
 						}
348 348
 
349
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
350
-						if ( false === $temp_id ) {
349
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
350
+						if (false === $temp_id) {
351 351
 							$sdata['post_id'] = 0;
352
-						} else {
352
+						}else {
353 353
 							$sdata['post_id'] = $temp_id;
354 354
 						}
355
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata );
355
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata);
356 356
 					}
357 357
 				}
358 358
 			}
359 359
 
360
-			if ( false !== $searched_items ) {
361
-				ksort( $searched_items );
362
-				$return = implode( $searched_items );
360
+			if (false !== $searched_items) {
361
+				ksort($searched_items);
362
+				$return = implode($searched_items);
363 363
 			}
364 364
 
365
-			print_r( $return );
365
+			print_r($return);
366 366
 		}
367 367
 
368 368
 		die();
369 369
 	}
370 370
 
371
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
371
+	public function prepare_row_attributes($cs_key, $ccs_id) {
372 372
 		$row_item = array(
373 373
 			'id' => $cs_key,
374 374
 			'type' => 'Accommodation',
375
-			'name' => get_the_title( $ccs_id ),
376
-			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
375
+			'name' => get_the_title($ccs_id),
376
+			'last_modified' => date('Y-m-d', strtotime('now')),
377 377
 			'post_id' => $ccs_id,
378 378
 		);
379 379
 		return $row_item;
@@ -385,28 +385,28 @@  discard block
 block discarded – undo
385 385
 	 * @param boolean $row the current row to format.
386 386
 	 * @return void
387 387
 	 */
388
-	public function format_row( $row = false ) {
389
-		if ( false !== $row ) {
388
+	public function format_row($row = false) {
389
+		if (false !== $row) {
390 390
 
391 391
 			$status = 'import';
392
-			if ( 0 !== $row['post_id'] ) {
393
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
392
+			if (0 !== $row['post_id']) {
393
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
394 394
 			}
395 395
 
396 396
 			$row_html = '
397
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
397
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
398 398
 				<th class="check-column" scope="row">
399
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
400
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
399
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
400
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
401 401
 				</th>
402 402
 				<td class="post-title page-title column-title">
403
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
403
+					<strong>' . $row['name'].'</strong> - '.$status.'
404 404
 				</td>
405 405
 				<td class="date column-date">
406
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
406
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
407 407
 				</td>
408 408
 				<td class="ssid column-ssid">
409
-					' . $row['id'] . '
409
+					' . $row['id'].'
410 410
 				</td>
411 411
 			</tr>';
412 412
 			return $row_html;
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 	/**
417 417
 	 * Saves the queue to the option.
418 418
 	 */
419
-	public function remove_from_queue( $id ) {
420
-		if ( ! empty( $this->queued_imports ) ) {
421
-			$key = array_search( $id, $this->queued_imports );
422
-			if ( false !== $key ) {
423
-				unset( $this->queued_imports[ $key ] );
419
+	public function remove_from_queue($id) {
420
+		if (!empty($this->queued_imports)) {
421
+			$key = array_search($id, $this->queued_imports);
422
+			if (false !== $key) {
423
+				unset($this->queued_imports[$key]);
424 424
 
425
-				delete_option( 'lsx_wetu_importer_que' );
426
-				update_option( 'lsx_wetu_importer_que', $this->queued_imports );
425
+				delete_option('lsx_wetu_importer_que');
426
+				update_option('lsx_wetu_importer_que', $this->queued_imports);
427 427
 			}
428 428
 		}
429 429
 	}
@@ -435,55 +435,55 @@  discard block
 block discarded – undo
435 435
 		$return = false;
436 436
 
437 437
 		// @codingStandardsIgnoreLine
438
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' && isset( $_POST['wetu_id'] ) ) {
438
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) {
439 439
 			// @codingStandardsIgnoreLine
440 440
 			$wetu_id = $_POST['wetu_id'];
441 441
 
442 442
 			// @codingStandardsIgnoreLine
443
-			if ( isset( $_POST['post_id'] ) ) {
443
+			if (isset($_POST['post_id'])) {
444 444
 				// @codingStandardsIgnoreLine
445 445
 				$post_id = $_POST['post_id'];
446
-			} else {
446
+			}else {
447 447
 				$post_id = 0;
448 448
 			}
449 449
 
450 450
 			// @codingStandardsIgnoreLine
451
-			if ( isset( $_POST['team_members'] ) ) {
451
+			if (isset($_POST['team_members'])) {
452 452
 				// @codingStandardsIgnoreLine
453 453
 				$team_members = $_POST['team_members'];
454
-			} else {
454
+			}else {
455 455
 				$team_members = false;
456 456
 			}
457 457
 
458 458
 			// @codingStandardsIgnoreLine
459
-			if ( isset( $_POST['safari_brands'] ) ) {
459
+			if (isset($_POST['safari_brands'])) {
460 460
 				// @codingStandardsIgnoreLine
461 461
 				$safari_brands = $_POST['safari_brands'];
462
-			} else {
462
+			}else {
463 463
 				$safari_brands = false;
464 464
 			}
465 465
 
466
-			delete_option( 'lsx_wetu_importer_accommodation_settings' );
466
+			delete_option('lsx_wetu_importer_accommodation_settings');
467 467
 
468 468
 			// @codingStandardsIgnoreLine
469
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
469
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
470 470
 				// @codingStandardsIgnoreLine
471 471
 				$content = $_POST['content'];
472
-				add_option( 'lsx_wetu_importer_accommodation_settings',$content );
473
-			} else {
472
+				add_option('lsx_wetu_importer_accommodation_settings', $content);
473
+			}else {
474 474
 				$content = false;
475 475
 			}
476 476
 
477
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
477
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
478 478
 
479
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
480
-				$adata = json_decode( $jdata['body'], true );
481
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
482
-				$this->format_completed_row( $return );
483
-				$this->remove_from_queue( $return );
479
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
480
+				$adata = json_decode($jdata['body'], true);
481
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
482
+				$this->format_completed_row($return);
483
+				$this->remove_from_queue($return);
484 484
 				$this->cleanup_posts();
485
-			} else {
486
-				$this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer' ) );
485
+			}else {
486
+				$this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer'));
487 487
 			}
488 488
 		}
489 489
 	}
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	/**
492 492
 	 * Connect to wetu
493 493
 	 */
494
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
494
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
495 495
 		$post_name = '';
496 496
 		$data_post_content = '';
497 497
 		$data_post_excerpt = '';
@@ -502,139 +502,139 @@  discard block
 block discarded – undo
502 502
 		$content_used_general_description = false;
503 503
 
504 504
 		// Set the post_content.
505
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
506
-			if ( isset( $data[0]['content']['extended_description'] ) ) {
505
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
506
+			if (isset($data[0]['content']['extended_description'])) {
507 507
 				$data_post_content = $data[0]['content']['extended_description'];
508
-			} elseif ( isset( $data[0]['content']['general_description'] ) ) {
508
+			} elseif (isset($data[0]['content']['general_description'])) {
509 509
 				$data_post_content = $data[0]['content']['general_description'];
510 510
 				$content_used_general_description = true;
511
-			} elseif ( isset( $data[0]['content']['teaser_description'] ) ) {
511
+			} elseif (isset($data[0]['content']['teaser_description'])) {
512 512
 				$data_post_content = $data[0]['content']['teaser_description'];
513 513
 			}
514 514
 
515
-			$post['post_content'] = wp_strip_all_tags( $data_post_content );
515
+			$post['post_content'] = wp_strip_all_tags($data_post_content);
516 516
 		}
517 517
 
518 518
 		// set the post_excerpt.
519
-		if ( ! empty( $importable_content ) && in_array( 'excerpt', $importable_content ) ) {
520
-			if ( isset( $data[0]['content']['teaser_description'] ) ) {
519
+		if (!empty($importable_content) && in_array('excerpt', $importable_content)) {
520
+			if (isset($data[0]['content']['teaser_description'])) {
521 521
 				$data_post_excerpt = $data[0]['content']['teaser_description'];
522
-			} elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) {
522
+			} elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
523 523
 				$data_post_excerpt = $data[0]['content']['general_description'];
524 524
 			}
525 525
 
526 526
 			$post['post_excerpt'] = $data_post_excerpt;
527 527
 		}
528 528
 
529
-		if ( false !== $id && '0' !== $id ) {
529
+		if (false !== $id && '0' !== $id) {
530 530
 			$post['ID'] = $id;
531 531
 
532
-			if ( isset( $data[0]['name'] ) ) {
532
+			if (isset($data[0]['name'])) {
533 533
 				$post['post_title'] = $data[0]['name'];
534 534
 				$post['post_status'] = 'publish';
535
-				$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
535
+				$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
536 536
 			}
537 537
 
538
-			$id = wp_update_post( $post );
539
-			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
540
-			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
541
-		} else {
538
+			$id = wp_update_post($post);
539
+			$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
540
+			update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
541
+		}else {
542 542
 			// Set the name.
543
-			if ( isset( $data[0]['name'] ) ) {
544
-				$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
543
+			if (isset($data[0]['name'])) {
544
+				$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
545 545
 			}
546 546
 
547 547
 			$post['post_name']   = $post_name;
548 548
 			$post['post_title']  = $data[0]['name'];
549 549
 			$post['post_status'] = 'publish';
550
-			$id                  = wp_insert_post( $post );
550
+			$id                  = wp_insert_post($post);
551 551
 
552 552
 			// Save the WETU ID and the Last date it was modified.
553
-			if ( false !== $id ) {
554
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
555
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
553
+			if (false !== $id) {
554
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
555
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
556 556
 			}
557 557
 		}
558 558
 
559 559
 		// Setup some default for use in the import.
560
-		if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) {
561
-			$this->find_attachments( $id );
560
+		if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
561
+			$this->find_attachments($id);
562 562
 		}
563 563
 
564 564
 		// Set the team member if it is there.
565
-		if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
566
-			$this->set_team_member( $id, $team_members );
565
+		if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
566
+			$this->set_team_member($id, $team_members);
567 567
 		}
568 568
 
569 569
 		// Set the safari brand.
570
-		if ( false !== $safari_brands && '' !== $safari_brands ) {
571
-			$this->set_safari_brands( $id, $safari_brands );
570
+		if (false !== $safari_brands && '' !== $safari_brands) {
571
+			$this->set_safari_brands($id, $safari_brands);
572 572
 		}
573 573
 
574
-		if ( class_exists( 'LSX_TO_Maps' ) ) {
575
-			$this->set_map_data( $data, $id, 9 );
574
+		if (class_exists('LSX_TO_Maps')) {
575
+			$this->set_map_data($data, $id, 9);
576 576
 		}
577 577
 
578
-		if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination', $importable_content ) ) {
579
-			$this->connect_destinations( $data, $id );
578
+		if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
579
+			$this->connect_destinations($data, $id);
580 580
 		}
581 581
 
582
-		if ( false !== $importable_content && in_array( 'category', $importable_content ) ) {
583
-			$this->set_taxonomy_style( $data, $id );
582
+		if (false !== $importable_content && in_array('category', $importable_content)) {
583
+			$this->set_taxonomy_style($data, $id);
584 584
 		}
585 585
 
586 586
 		// Set the Room Data.
587
-		if ( false !== $importable_content && in_array( 'rooms', $importable_content ) ) {
588
-			$this->set_room_data( $data, $id );
587
+		if (false !== $importable_content && in_array('rooms', $importable_content)) {
588
+			$this->set_room_data($data, $id);
589 589
 		}
590 590
 
591 591
 		// Set the rating.
592
-		if ( false !== $importable_content && in_array( 'rating', $importable_content ) ) {
593
-			$this->set_rating( $data, $id );
592
+		if (false !== $importable_content && in_array('rating', $importable_content)) {
593
+			$this->set_rating($data, $id);
594 594
 		}
595 595
 
596 596
 		// Set the checkin checkout data.
597
-		if ( false !== $importable_content && in_array( 'checkin', $importable_content ) ) {
598
-			$this->set_checkin_checkout( $data, $id );
597
+		if (false !== $importable_content && in_array('checkin', $importable_content)) {
598
+			$this->set_checkin_checkout($data, $id);
599 599
 		}
600 600
 
601 601
 		// Set the Spoken Languages.
602
-		if ( false !== $importable_content && in_array( 'spoken_languages', $importable_content ) ) {
603
-			$this->set_spoken_languages( $data, $id );
602
+		if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
603
+			$this->set_spoken_languages($data, $id);
604 604
 		}
605 605
 
606 606
 		// Set the friendly options.
607
-		if ( false !== $importable_content && in_array( 'friendly', $importable_content ) ) {
608
-			$this->set_friendly( $data, $id );
607
+		if (false !== $importable_content && in_array('friendly', $importable_content)) {
608
+			$this->set_friendly($data, $id);
609 609
 		}
610 610
 
611 611
 		// Set the special_interests.
612
-		if ( false !== $importable_content && in_array( 'special_interests', $importable_content ) ) {
613
-			$this->set_special_interests( $data, $id );
612
+		if (false !== $importable_content && in_array('special_interests', $importable_content)) {
613
+			$this->set_special_interests($data, $id);
614 614
 		}
615 615
 
616 616
 		// Import the videos.
617
-		if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
618
-			$this->set_video_data( $data, $id );
617
+		if (false !== $importable_content && in_array('videos', $importable_content)) {
618
+			$this->set_video_data($data, $id);
619 619
 		}
620 620
 
621 621
 		// Import the facilities.
622
-		if ( false !== $importable_content && in_array( 'facilities', $importable_content ) ) {
623
-			$this->set_facilities( $data, $id );
622
+		if (false !== $importable_content && in_array('facilities', $importable_content)) {
623
+			$this->set_facilities($data, $id);
624 624
 		}
625 625
 
626 626
 		// Set the featured image.
627
-		if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
628
-			$this->set_featured_image( $data, $id );
627
+		if (false !== $importable_content && in_array('featured_image', $importable_content)) {
628
+			$this->set_featured_image($data, $id);
629 629
 		}
630 630
 
631
-		if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
632
-			$this->set_banner_image( $data, $id );
631
+		if (false !== $importable_content && in_array('banner_image', $importable_content)) {
632
+			$this->set_banner_image($data, $id);
633 633
 		}
634 634
 
635 635
 		// Import the main gallery.
636
-		if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
637
-			$this->create_main_gallery( $data, $id );
636
+		if (false !== $importable_content && in_array('gallery', $importable_content)) {
637
+			$this->create_main_gallery($data, $id);
638 638
 		}
639 639
 
640 640
 		return $id;
@@ -643,55 +643,55 @@  discard block
 block discarded – undo
643 643
 	/**
644 644
 	 * Set the team memberon each item.
645 645
 	 */
646
-	public function set_team_member( $id, $team_members ) {
647
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
646
+	public function set_team_member($id, $team_members) {
647
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
648 648
 
649
-		foreach ( $team_members as $team ) {
650
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
649
+		foreach ($team_members as $team) {
650
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
651 651
 		}
652 652
 	}
653 653
 
654 654
 	/**
655 655
 	 * Set the safari brand
656 656
 	 */
657
-	public function set_safari_brands( $id, $safari_brands ) {
658
-		foreach ( $safari_brands as $safari_brand ) {
659
-			wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand', true );
657
+	public function set_safari_brands($id, $safari_brands) {
658
+		foreach ($safari_brands as $safari_brand) {
659
+			wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);
660 660
 		}
661 661
 	}
662 662
 
663 663
 	/**
664 664
 	 * Connects the destinations post type
665 665
 	 */
666
-	public function connect_destinations( $data, $id ) {
667
-		if ( isset( $data[0]['position'] ) ) {
666
+	public function connect_destinations($data, $id) {
667
+		if (isset($data[0]['position'])) {
668 668
 			$destinations = false;
669 669
 
670
-			if ( isset( $data[0]['position']['country'] ) ) {
670
+			if (isset($data[0]['position']['country'])) {
671 671
 				$destinations['country'] = $data[0]['position']['country'];
672 672
 			}
673 673
 
674
-			if ( isset( $data[0]['position']['destination'] ) ) {
674
+			if (isset($data[0]['position']['destination'])) {
675 675
 				$destinations['destination'] = $data[0]['position']['destination'];
676 676
 			}
677 677
 
678
-			if ( false !== $destinations ) {
679
-				$prev_values = get_post_meta( $id, 'destination_to_accommodation', false );
678
+			if (false !== $destinations) {
679
+				$prev_values = get_post_meta($id, 'destination_to_accommodation', false);
680 680
 
681
-				if ( false === $prev_values || ! is_array( $prev_values ) ) {
681
+				if (false === $prev_values || !is_array($prev_values)) {
682 682
 					$prev_values = array();
683 683
 				}
684 684
 
685
-				delete_post_meta( $id, 'destination_to_accommodation', $prev_values );
686
-				$destinations = array_unique( $destinations );
685
+				delete_post_meta($id, 'destination_to_accommodation', $prev_values);
686
+				$destinations = array_unique($destinations);
687 687
 
688
-				foreach ( $destinations as $key => $value ) {
689
-					$destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' );
690
-					if ( null !== $destination ) {
691
-						if ( ! in_array( $destination->ID, $prev_values ) ) {
692
-							add_post_meta( $id, 'destination_to_accommodation', $destination->ID, false );
693
-							add_post_meta( $destination->ID, 'accommodation_to_destination', $id, false );
694
-							$this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination';
688
+				foreach ($destinations as $key => $value) {
689
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
690
+					if (null !== $destination) {
691
+						if (!in_array($destination->ID, $prev_values)) {
692
+							add_post_meta($id, 'destination_to_accommodation', $destination->ID, false);
693
+							add_post_meta($destination->ID, 'accommodation_to_destination', $id, false);
694
+							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
695 695
 						}
696 696
 					}
697 697
 				}
@@ -702,72 +702,72 @@  discard block
 block discarded – undo
702 702
 	/**
703 703
 	 * Set the Travel Style
704 704
 	 */
705
-	public function set_taxonomy_style( $data, $id ) {
705
+	public function set_taxonomy_style($data, $id) {
706 706
 		$terms = false;
707 707
 
708
-		if ( isset( $data[0]['category'] ) ) {
709
-			$term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' );
710
-			if ( ! $term ) {
711
-				$term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' );
708
+		if (isset($data[0]['category'])) {
709
+			$term = term_exists(trim($data[0]['category']), 'accommodation-type');
710
+			if (!$term) {
711
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
712 712
 
713
-				if ( is_wp_error( $term ) ) {
714
-					echo wp_kses_post( $term->get_error_message() );
713
+				if (is_wp_error($term)) {
714
+					echo wp_kses_post($term->get_error_message());
715 715
 				}
716
-			} else {
717
-				wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
716
+			}else {
717
+				wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
718 718
 			}
719
-		} else {
720
-			wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
719
+		}else {
720
+			wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
721 721
 		}
722 722
 	}
723 723
 
724 724
 	/**
725 725
 	 * Saves the room data
726 726
 	 */
727
-	public function set_room_data( $data, $id ) {
728
-		if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) {
727
+	public function set_room_data($data, $id) {
728
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
729 729
 			$rooms = false;
730 730
 
731
-			foreach ( $data[0]['rooms'] as $room ) {
731
+			foreach ($data[0]['rooms'] as $room) {
732 732
 				$temp_room = array();
733 733
 
734
-				if ( isset( $room['name'] ) ) {
734
+				if (isset($room['name'])) {
735 735
 					$temp_room['title'] = $room['name'];
736 736
 				}
737 737
 
738
-				if ( isset( $room['description'] ) ) {
739
-					$temp_room['description'] = strip_tags( $room['description'] );
738
+				if (isset($room['description'])) {
739
+					$temp_room['description'] = strip_tags($room['description']);
740 740
 				}
741 741
 
742 742
 				$temp_room['price'] = 0;
743 743
 				$temp_room['type']  = 'room';
744 744
 
745
-				if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) {
745
+				if (!empty($room['images']) && is_array($room['images'])) {
746 746
 					$temp_room['gallery'] = array();
747
-					$temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id );
747
+					$temp_room['gallery'][] = $this->attach_image($room['images'][0], $id);
748 748
 				}
749 749
 				$rooms[] = $temp_room;
750 750
 			}
751 751
 
752
-			if ( false !== $id && '0' !== $id ) {
753
-				delete_post_meta( $id, 'units' );
752
+			if (false !== $id && '0' !== $id) {
753
+				delete_post_meta($id, 'units');
754 754
 			}
755 755
 
756
-			foreach ( $rooms as $room ) {
757
-				add_post_meta( $id, 'units', $room, false );
756
+			foreach ($rooms as $room) {
757
+				add_post_meta($id, 'units', $room, false);
758 758
 			}
759 759
 
760
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) {
760
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
761 761
 				$room_count = $data[0]['features']['rooms'];
762
-			} else {
763
-				$room_count = count( $data[0]['rooms'] );
762
+			}else {
763
+				$room_count = count($data[0]['rooms']);
764 764
 			}
765 765
 
766
-			if ( false !== $id && '0' !== $id ) {
767
-				$prev_rooms = get_post_meta( $id, 'number_of_rooms', true );
768
-				update_post_meta( $id, 'number_of_rooms', $room_count, $prev_rooms );
769
-			} else {
770
-				add_post_meta( $id, 'number_of_rooms', $room_count, true );
766
+			if (false !== $id && '0' !== $id) {
767
+				$prev_rooms = get_post_meta($id, 'number_of_rooms', true);
768
+				update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms);
769
+			}else {
770
+				add_post_meta($id, 'number_of_rooms', $room_count, true);
771 771
 			}
772 772
 		}
773 773
 	}
@@ -775,33 +775,33 @@  discard block
 block discarded – undo
775 775
 	/**
776 776
 	 * Set the ratings
777 777
 	 */
778
-	public function set_rating( $data, $id ) {
779
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) {
778
+	public function set_rating($data, $id) {
779
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
780 780
 			$rating_type = $data[0]['features']['star_authority'];
781
-		} else {
781
+		}else {
782 782
 			$rating_type = 'Unspecified2';
783 783
 		}
784 784
 
785
-		$this->save_custom_field( $rating_type, 'rating_type', $id );
785
+		$this->save_custom_field($rating_type, 'rating_type', $id);
786 786
 
787
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) {
788
-			$this->save_custom_field( $data[0]['features']['stars'], 'rating', $id, true );
787
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
788
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);
789 789
 		}
790 790
 	}
791 791
 
792 792
 	/**
793 793
 	 * Set the spoken_languages
794 794
 	 */
795
-	public function set_spoken_languages( $data, $id ) {
796
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) {
795
+	public function set_spoken_languages($data, $id) {
796
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
797 797
 			$languages = false;
798 798
 
799
-			foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) {
800
-				$languages[] = sanitize_title( $spoken_language );
799
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
800
+				$languages[] = sanitize_title($spoken_language);
801 801
 			}
802 802
 
803
-			if ( false !== $languages ) {
804
-				$this->save_custom_field( $languages, 'spoken_languages', $id );
803
+			if (false !== $languages) {
804
+				$this->save_custom_field($languages, 'spoken_languages', $id);
805 805
 			}
806 806
 		}
807 807
 	}
@@ -809,16 +809,16 @@  discard block
 block discarded – undo
809 809
 	/**
810 810
 	 * Set the friendly
811 811
 	 */
812
-	public function set_friendly( $data, $id ) {
813
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) {
812
+	public function set_friendly($data, $id) {
813
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
814 814
 			$friendly_options = false;
815 815
 
816
-			foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) {
817
-				$friendly_options[] = sanitize_title( $visitor_type );
816
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
817
+				$friendly_options[] = sanitize_title($visitor_type);
818 818
 			}
819 819
 
820
-			if ( false !== $friendly_options ) {
821
-				$this->save_custom_field( $friendly_options, 'suggested_visitor_types', $id );
820
+			if (false !== $friendly_options) {
821
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
822 822
 			}
823 823
 		}
824 824
 	}
@@ -826,16 +826,16 @@  discard block
 block discarded – undo
826 826
 	/**
827 827
 	 * Set the special interests
828 828
 	 */
829
-	public function set_special_interests( $data, $id ) {
830
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) {
829
+	public function set_special_interests($data, $id) {
830
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
831 831
 			$interests = false;
832 832
 
833
-			foreach ( $data[0]['features']['special_interests'] as $special_interest ) {
834
-				$interests[] = sanitize_title( $special_interest );
833
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
834
+				$interests[] = sanitize_title($special_interest);
835 835
 			}
836 836
 
837
-			if ( false !== $interests ) {
838
-				$this->save_custom_field( $interests, 'special_interests', $id );
837
+			if (false !== $interests) {
838
+				$this->save_custom_field($interests, 'special_interests', $id);
839 839
 			}
840 840
 		}
841 841
 	}
@@ -843,24 +843,24 @@  discard block
 block discarded – undo
843 843
 	/**
844 844
 	 * Set the Check in and Check out Date
845 845
 	 */
846
-	public function set_checkin_checkout( $data, $id ) {
847
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) {
848
-			$time = str_replace( 'h', ':', $data[0]['features']['check_in_time'] );
849
-			$time = date( 'h:ia', strtotime( $time ) );
850
-			$this->save_custom_field( $time, 'checkin_time', $id );
846
+	public function set_checkin_checkout($data, $id) {
847
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
848
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
849
+			$time = date('h:ia', strtotime($time));
850
+			$this->save_custom_field($time, 'checkin_time', $id);
851 851
 		}
852 852
 
853
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) {
854
-			$time = str_replace( 'h', ':', $data[0]['features']['check_out_time'] );
855
-			$time = date( 'h:ia', strtotime( $time ) );
856
-			$this->save_custom_field( $time, 'checkout_time', $id );
853
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
854
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
855
+			$time = date('h:ia', strtotime($time));
856
+			$this->save_custom_field($time, 'checkout_time', $id);
857 857
 		}
858 858
 	}
859 859
 
860 860
 	/**
861 861
 	 * Set the Facilities
862 862
 	 */
863
-	public function set_facilities( $data, $id ) {
863
+	public function set_facilities($data, $id) {
864 864
 		$parent_facilities = array(
865 865
 			'available_services' => 'Available Services',
866 866
 			'property_facilities' => 'Property Facilities',
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 			'activities_on_site' => 'Activities on Site',
869 869
 		);
870 870
 
871
-		foreach ( $parent_facilities as $key => $label ) {
871
+		foreach ($parent_facilities as $key => $label) {
872 872
 			$terms = false;
873 873
 
874
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) {
875
-				$parent_id = $this->set_term( $id, $label, 'facility' );
874
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
875
+				$parent_id = $this->set_term($id, $label, 'facility');
876 876
 			}
877 877
 
878
-			foreach ( $data[0]['features'][ $key ] as $child_facility ) {
879
-				$this->set_term( $id, $child_facility, 'facility', $parent_id );
878
+			foreach ($data[0]['features'][$key] as $child_facility) {
879
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
880 880
 			}
881 881
 		}
882 882
 	}
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-banner-integration.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -232,6 +232,9 @@
 block discarded – undo
232 232
 		}
233 233
 	}
234 234
 
235
+	/**
236
+	 * @param string $url
237
+	 */
235 238
 	public function attach_external_image2( $url = null, $post_data = array() ) {
236 239
 		if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); }
237 240
 
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @access private
27 27
 	 */
28 28
 	public function __construct() {
29
-		add_action( 'wp_ajax_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) );
30
-		add_action( 'wp_ajax_nopriv_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) );
29
+		add_action('wp_ajax_lsx_import_sync_banners', array($this, 'sync_new_banner'));
30
+		add_action('wp_ajax_nopriv_lsx_import_sync_banners', array($this, 'sync_new_banner'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 	public function display_page() {
37 37
 		?>
38 38
 		<div class="wrap">
39
-			<h2><?php esc_html_e( 'Download new banners straight from WETU','lsx-wetu-importer' ); ?></h2>
39
+			<h2><?php esc_html_e('Download new banners straight from WETU', 'lsx-wetu-importer'); ?></h2>
40 40
 
41 41
 			<form method="get" action="" id="banners-filter">
42
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
42
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
43 43
 
44 44
 			   <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
45
-					<img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
45
+					<img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
46 46
 				</div>
47 47
 
48 48
 				<table class="wp-list-table widefat fixed posts">
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 					<?php
61 61
 						$accommodation_args = array(
62 62
 							'post_type' => 'accommodation',
63
-							'post_status' => array( 'publish','pending','draft','future','private' ),
63
+							'post_status' => array('publish', 'pending', 'draft', 'future', 'private'),
64 64
 							'nopagin' => 'true',
65 65
 							'posts_per_page' => '1000',
66 66
 							'meta_query' => array(
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 								),
81 81
 							),
82 82
 						);
83
-						$accommodation = new WP_Query( $accommodation_args );
83
+						$accommodation = new WP_Query($accommodation_args);
84 84
 					?>
85 85
 
86 86
 					<tbody id="the-list">
87 87
 						<?php
88
-							if ( $accommodation->have_posts() ) {
89
-								while ( $accommodation->have_posts() ) {
88
+							if ($accommodation->have_posts()) {
89
+								while ($accommodation->have_posts()) {
90 90
 									$accommodation->the_post();
91 91
 									?>
92 92
 									<tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>">
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 									$min_width = '1920';
96 96
 									$min_height = '500';
97 97
 
98
-									$img_group = get_post_meta( get_the_ID(),'image_group',true );
98
+									$img_group = get_post_meta(get_the_ID(), 'image_group', true);
99 99
 
100 100
 									$thumbnails_html = false;
101 101
 
102
-									if ( false !== $img_group ) {
103
-										foreach ( $img_group['banner_image'] as $banner_image ) {
104
-											$large = wp_get_attachment_image_src( $banner_image,'full' );
102
+									if (false !== $img_group) {
103
+										foreach ($img_group['banner_image'] as $banner_image) {
104
+											$large = wp_get_attachment_image_src($banner_image, 'full');
105 105
 											$real_width = $large[1];
106 106
 											$real_height = $large[2];
107 107
 
108 108
 											$status = 'optimized';
109
-											if ( $real_width < intval( $real_width ) ) {
109
+											if ($real_width < intval($real_width)) {
110 110
 												$status = 'width not enough.';
111 111
 												}
112 112
 
113
-											$thumbnail = wp_get_attachment_image_src( $banner_image,'thumbnail' );
113
+											$thumbnail = wp_get_attachment_image_src($banner_image, 'thumbnail');
114 114
 											$thumbnails_html[] = '
115 115
 													<div style="display:block;float:left;">
116
-														<img src="' . $thumbnail[0] . '" />
117
-														<p style="text-align:center;">' . $real_width . 'px by ' . $real_height . 'px</p>
116
+														<img src="' . $thumbnail[0].'" />
117
+														<p style="text-align:center;">' . $real_width.'px by '.$real_height.'px</p>
118 118
 													</div>';
119 119
 											}
120 120
 										}
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 										<input type="checkbox" data-identifier="<?php the_ID(); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
125 125
 										</th>
126 126
 
127
-										<td class="post-title page-title column-title"><?php echo '<a href="' . esc_url( admin_url( '/post.php?post=' . get_the_ID() . '&action=edit' ) ) . '" target="_blank">';
127
+										<td class="post-title page-title column-title"><?php echo '<a href="'.esc_url(admin_url('/post.php?post='.get_the_ID().'&action=edit')).'" target="_blank">';
128 128
 										the_title();
129 129
 										echo '</a>'; ?></td>
130 130
 
131 131
 										<td colspan="2" class="thumbnails column-thumbnails">
132 132
 										<?php
133
-											if ( false !== $thumbnails_html ) {
134
-												echo wp_kses_post( implode( '', $thumbnails_html ) );
135
-											} else {
133
+											if (false !== $thumbnails_html) {
134
+												echo wp_kses_post(implode('', $thumbnails_html));
135
+											}else {
136 136
 												echo '<p>There was an error retrieving your images.</p>';
137 137
 											}
138 138
 										?>
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 				</table>
158 158
 
159
-				<p><input class="button button-primary download" type="button" value="<?php esc_html_e( 'Download new Banners','lsx-wetu-importer' ); ?>" />
159
+				<p><input class="button button-primary download" type="button" value="<?php esc_html_e('Download new Banners', 'lsx-wetu-importer'); ?>" />
160 160
 				</p>
161 161
 			</form>
162 162
 		</div>
@@ -168,33 +168,33 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function sync_new_banner() {
170 170
 		// @codingStandardsIgnoreLine
171
-		if ( isset( $_POST['action'] ) && 'lsx_import_sync_banners' === $_POST['action'] && isset( $_POST['post_id'] ) ) {
171
+		if (isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])) {
172 172
 			// @codingStandardsIgnoreLine
173
-			$banners = get_post_meta( $_POST['post_id'],'image_group',true );
173
+			$banners = get_post_meta($_POST['post_id'], 'image_group', true);
174 174
 			// @codingStandardsIgnoreLine
175
-			$this->wetu_id = get_post_meta( $_POST['post_id'],'lsx_wetu_id',true );
175
+			$this->wetu_id = get_post_meta($_POST['post_id'], 'lsx_wetu_id', true);
176 176
 
177 177
 			$new_banner_array = false;
178 178
 			$array_index = 0;
179 179
 
180
-			foreach ( $banners['banner_image'] as $banner_image ) {
181
-				$image_id = $this->attach_external_image2( $this->format_wetu_url( $banner_image ) );
182
-				if ( null !== $image_id && '' !== $image_id ) {
183
-					$new_banner_array['banner_image'][ 'cmb-field-' . $array_index ] = $image_id;
180
+			foreach ($banners['banner_image'] as $banner_image) {
181
+				$image_id = $this->attach_external_image2($this->format_wetu_url($banner_image));
182
+				if (null !== $image_id && '' !== $image_id) {
183
+					$new_banner_array['banner_image']['cmb-field-'.$array_index] = $image_id;
184 184
 					$array_index++;
185 185
 				}
186 186
 			}
187 187
 
188
-			if ( false !== $new_banner_array ) {
188
+			if (false !== $new_banner_array) {
189 189
 				// @codingStandardsIgnoreLine
190
-				delete_post_meta( $_POST['post_id'],'image_group' );
190
+				delete_post_meta($_POST['post_id'], 'image_group');
191 191
 				// @codingStandardsIgnoreLine
192
-				add_post_meta( $_POST['post_id'],'image_group',$new_banner_array,true );
192
+				add_post_meta($_POST['post_id'], 'image_group', $new_banner_array, true);
193 193
 				echo true;
194
-			} else {
194
+			}else {
195 195
 				echo false;
196 196
 			}
197
-		} else {
197
+		}else {
198 198
 			echo false;
199 199
 		}
200 200
 
@@ -204,71 +204,71 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * formats the url
206 206
 	 */
207
-	public function format_wetu_url( $post_id ) {
208
-		return 'https://wetu.com/ImageHandler/c1920x800/' . $this->wetu_id . '/' . $this->format_filename( $post_id );
207
+	public function format_wetu_url($post_id) {
208
+		return 'https://wetu.com/ImageHandler/c1920x800/'.$this->wetu_id.'/'.$this->format_filename($post_id);
209 209
 	}
210 210
 
211 211
 	/**
212 212
 	 * formats the filename
213 213
 	 */
214
-	public function format_filename( $post_id ) {
215
-		$base = str_replace( '_',' ',get_the_title( $post_id ) );
216
-		$base = rawurlencode( $base );
217
-		$type = get_post_mime_type( $post_id );
214
+	public function format_filename($post_id) {
215
+		$base = str_replace('_', ' ', get_the_title($post_id));
216
+		$base = rawurlencode($base);
217
+		$type = get_post_mime_type($post_id);
218 218
 
219
-		switch ( $type ) {
219
+		switch ($type) {
220 220
 			case 'image/jpeg':
221
-				return $base . '.jpg';
221
+				return $base.'.jpg';
222 222
 			break;
223 223
 			case 'image/png':
224
-				return $base . '.png';
224
+				return $base.'.png';
225 225
 			break;
226 226
 			case 'image/gif':
227
-				return $base . '.gif';
227
+				return $base.'.gif';
228 228
 			break;
229 229
 			default:
230 230
 				return false;
231 231
 		}
232 232
 	}
233 233
 
234
-	public function attach_external_image2( $url = null, $post_data = array() ) {
235
-		if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); }
234
+	public function attach_external_image2($url = null, $post_data = array()) {
235
+		if (!$url) { return new WP_Error('missing', 'Need a valid URL'); }
236 236
 
237
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
238
-		require_once( ABSPATH . 'wp-admin/includes/media.php' );
239
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
237
+		require_once(ABSPATH.'wp-admin/includes/file.php');
238
+		require_once(ABSPATH.'wp-admin/includes/media.php');
239
+		require_once(ABSPATH.'wp-admin/includes/image.php');
240 240
 
241 241
 		//var_dump($tmp);
242
-		$tmp = tempnam( '/tmp', 'FOO' );
243
-		print_r( $url );
244
-		$image = file_get_contents( $url );
245
-		print_r( $image );
246
-		file_put_contents( $tmp, $image );
247
-		chmod( $tmp,'777' );
248
-
249
-		preg_match( '/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches );    // fix file filename for query strings
250
-		$url_filename = basename( $matches[0] );
251
-		$url_filename = str_replace( '%20','_',$url_filename );
242
+		$tmp = tempnam('/tmp', 'FOO');
243
+		print_r($url);
244
+		$image = file_get_contents($url);
245
+		print_r($image);
246
+		file_put_contents($tmp, $image);
247
+		chmod($tmp, '777');
248
+
249
+		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings
250
+		$url_filename = basename($matches[0]);
251
+		$url_filename = str_replace('%20', '_', $url_filename);
252 252
 		// extract filename from url for title
253
-		$url_type = wp_check_filetype( $url_filename );                                           // determine file type (ext and mime/type)
253
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
254 254
 
255 255
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
256
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
256
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
257 257
 
258
-		if ( ! empty( $filename ) && ' ' != $filename ) {
259
-			$file_array['name'] = $filename . '.' . $url_type['ext'];                           // user given filename for title, add original URL extension
260
-		} else {
261
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
258
+		if (!empty($filename) && ' ' != $filename) {
259
+			$file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension
260
+		}else {
261
+			$file_array['name'] = $url_filename; // just use original URL filename
262 262
 		}
263 263
 
264 264
 		// set additional wp_posts columns
265
-		if ( empty( $post_data['post_title'] ) ) {
266
-			$url_filename = str_replace( '%20',' ',$url_filename );
267
-			$post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] );         // just use the original filename (no extension)
265
+		if (empty($post_data['post_title'])) {
266
+			$url_filename = str_replace('%20', ' ', $url_filename);
267
+			$post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension)
268 268
 		}
269 269
 
270 270
 		// make sure gets tied to parent
271
-		if ( empty( $post_data['post_parent'] ) ) {
271
+		if (empty($post_data['post_parent'])) {
272 272
 			// @codingStandardsIgnoreLine
273 273
 			$post_data['post_parent'] = $_POST['post_id'];
274 274
 		}
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 
278 278
 		// do the validation and storage stuff
279 279
 		// @codingStandardsIgnoreLine
280
-		$att_id = media_handle_sideload( $file_array, $_POST['post_id'], null, $post_data );             // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
280
+		$att_id = media_handle_sideload($file_array, $_POST['post_id'], null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
281 281
 
282 282
 		// If error storing permanently, unlink
283
-		if ( is_wp_error( $att_id ) ) {
284
-			unlink( $file_array['tmp_name'] );   // clean up
283
+		if (is_wp_error($att_id)) {
284
+			unlink($file_array['tmp_name']); // clean up
285 285
 			return false; // output wp_error
286 286
 			//return $att_id; // output wp_error
287 287
 		}
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-connect-accommodation.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -214,6 +214,7 @@
 block discarded – undo
214 214
 
215 215
 	/**
216 216
 	 * format the array
217
+	 * @param string $key
217 218
 	 */
218 219
 	public function format_array( $array, $key ) {
219 220
 		$new_array = array();
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	 * @access private
36 36
 	 */
37 37
 	public function __construct() {
38
-		$temp_options = get_option( '_lsx-to_settings',false );
38
+		$temp_options = get_option('_lsx-to_settings', false);
39 39
 
40
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
41
-			$this->options = $temp_options[ $this->plugin_slug ];
40
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
41
+			$this->options = $temp_options[$this->plugin_slug];
42 42
 		}
43 43
 
44
-		$this->url = 'http://wetu.com/API/Pins/' . $this->options['api_key'] . '/List';
44
+		$this->url = 'http://wetu.com/API/Pins/'.$this->options['api_key'].'/List';
45 45
 
46
-		add_action( 'lsx_tour_importer_admin_tab_' . $this->tab_slug, array( $this, 'display_page' ) );
47
-		add_action( 'wp_ajax_lsx_import_connect_accommodation',array( $this, 'process_connection' ) );
48
-		add_action( 'wp_ajax_nopriv_lsx_import_connect_accommodation',array( $this, 'process_connection' ) );
46
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
47
+		add_action('wp_ajax_lsx_import_connect_accommodation', array($this, 'process_connection'));
48
+		add_action('wp_ajax_nopriv_lsx_import_connect_accommodation', array($this, 'process_connection'));
49 49
 	}
50 50
 
51 51
 	/**
@@ -55,45 +55,45 @@  discard block
 block discarded – undo
55 55
 		global $post;
56 56
 		?>
57 57
 		<div class="wrap">
58
-			<h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e( 'Connect your Accommodation','lsx-wetu-importer' ); ?></h3>
58
+			<h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e('Connect your Accommodation', 'lsx-wetu-importer'); ?></h3>
59 59
 
60 60
 			<form method="get" action="" id="connect-accommodation-filter">
61
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
61
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
62 62
 
63
-				<p><?php esc_html_e( 'Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.','lsx-wetu-importer' ); ?></p>
63
+				<p><?php esc_html_e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'lsx-wetu-importer'); ?></p>
64 64
 
65 65
 				<div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
66
-					<img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
66
+					<img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
67 67
 				</div>
68 68
 
69 69
 				<?php
70 70
 					$loose_accommodation = $this->find_current_accommodation();
71 71
 				?>
72
-				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect','lsx-wetu-importer' ); ?>" /></p>
72
+				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'lsx-wetu-importer'); ?>" /></p>
73 73
 				<table class="wp-list-table widefat fixed posts">
74 74
 					<?php $this->table_header(); ?>
75 75
 
76 76
 					<tbody>
77
-						<?php if ( false !== $loose_accommodation ) {
77
+						<?php if (false !== $loose_accommodation) {
78 78
 
79 79
 							$loose_args = array(
80 80
 								'post_type' => 'accommodation',
81
-								'post_status' => array( 'publish','pending' ),
81
+								'post_status' => array('publish', 'pending'),
82 82
 								'nopagin' => true,
83 83
 								'post__in' => $loose_accommodation,
84 84
 							);
85
-							$loose_accommodation_query = new WP_Query( $loose_args );
86
-							$accommodation = get_transient( 'lsx_ti_accommodation' );
85
+							$loose_accommodation_query = new WP_Query($loose_args);
86
+							$accommodation = get_transient('lsx_ti_accommodation');
87 87
 							$identifier = '';
88 88
 
89
-							if ( $loose_accommodation_query->have_posts() && false !== $accommodation ) {
90
-								while ( $loose_accommodation_query->have_posts() ) {
89
+							if ($loose_accommodation_query->have_posts() && false !== $accommodation) {
90
+								while ($loose_accommodation_query->have_posts()) {
91 91
 									$loose_accommodation_query->the_post();
92 92
 
93
-									foreach ( $accommodation as $row_key => $row ) {
94
-										if ( stripos( ltrim( rtrim( $row->name ) ), $post->post_title ) !== false ) {
93
+									foreach ($accommodation as $row_key => $row) {
94
+										if (stripos(ltrim(rtrim($row->name)), $post->post_title) !== false) {
95 95
 											$identifier = $row->id;
96
-										} else {
96
+										}else {
97 97
 											continue;
98 98
 										}
99 99
 									}
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 									<tr class="post-<?php the_ID(); ?> type-accommodation status-none" id="post-<?php the_ID(); ?>">
102 102
 										<th class="check-column" scope="row">
103 103
 											<label for="cb-select-<?php the_ID(); ?>" class="screen-reader-text"><?php the_title(); ?></label>
104
-											<input type="checkbox" data-identifier="<?php echo esc_attr( $identifier ); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
104
+											<input type="checkbox" data-identifier="<?php echo esc_attr($identifier); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
105 105
 										</th>
106 106
 										<td class="post-title page-title column-title">
107
-											<strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url( admin_url( '/post.php?post=' . $post->ID . '&action=edit' ) ); ?>" target="_blank"><?php echo esc_html( $post->post_status ); ?></a>
107
+											<strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url(admin_url('/post.php?post='.$post->ID.'&action=edit')); ?>" target="_blank"><?php echo esc_html($post->post_status); ?></a>
108 108
 										</td>
109 109
 										<td class="excerpt column-excerpt">
110 110
 											<?php
111
-												echo wp_kses_post( strip_tags( get_the_excerpt() ) );
111
+												echo wp_kses_post(strip_tags(get_the_excerpt()));
112 112
 											?>
113 113
 										</td>
114 114
 									</tr>
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 
122 122
 				</table>
123 123
 
124
-				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect','lsx-wetu-importer' ); ?>" /></p>
124
+				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'lsx-wetu-importer'); ?>" /></p>
125 125
 
126 126
 			</form>
127 127
 
128 128
 			<div style="display:none;" class="completed-list-wrapper">
129
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
129
+				<h3><?php esc_html_e('Completed'); ?></h3>
130 130
 				<ul>
131 131
 				</ul>
132 132
 			</div>
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			FROM {$wpdb->posts}
183 183
 			WHERE post_type = 'accommodation'
184 184
 			LIMIT 0,500
185
-		",ARRAY_A);
185
+		", ARRAY_A);
186 186
 
187 187
 		$current_accommodation = $wpdb->get_results("
188 188
 			SELECT key1.post_id
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 			AND key2.post_type = 'accommodation'
196 196
 
197 197
 			LIMIT 0,500
198
-		",ARRAY_A);
198
+		", ARRAY_A);
199 199
 
200
-		if ( null !== $all_accommodation && ! empty( $all_accommodation ) ) {
200
+		if (null !== $all_accommodation && !empty($all_accommodation)) {
201 201
 			//remove the extra accommodation
202
-			if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
203
-				$all_accommodation = array_diff( $this->format_array( $all_accommodation,'ID' ), $this->format_array( $current_accommodation,'post_id' ) );
204
-			} elseif ( null !== $current_accommodation && empty( $current_accommodation ) ) {
205
-				$all_accommodation = $this->format_array( $current_accommodation,'post_id' );
202
+			if (null !== $current_accommodation && !empty($current_accommodation)) {
203
+				$all_accommodation = array_diff($this->format_array($all_accommodation, 'ID'), $this->format_array($current_accommodation, 'post_id'));
204
+			} elseif (null !== $current_accommodation && empty($current_accommodation)) {
205
+				$all_accommodation = $this->format_array($current_accommodation, 'post_id');
206 206
 			}
207 207
 
208 208
 			$return = $all_accommodation;
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 	/**
215 215
 	 * format the array
216 216
 	 */
217
-	public function format_array( $array, $key ) {
217
+	public function format_array($array, $key) {
218 218
 		$new_array = array();
219 219
 
220
-		foreach ( $array as $value ) {
221
-			$new_array[] = $value[ $key ];
220
+		foreach ($array as $value) {
221
+			$new_array[] = $value[$key];
222 222
 		}
223 223
 
224 224
 		return $new_array;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		$return = false;
232 232
 
233 233
 		// @codingStandardsIgnoreLine
234
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['post_id'] ) && isset( $_POST['wetu_id'] ) ) {
234
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])) {
235 235
 			$post_id = false;
236 236
 			$matching_id = false;
237 237
 
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 			// @codingStandardsIgnoreLine
241 241
 			$matching_id = $_POST['wetu_id'];
242 242
 
243
-			add_post_meta( $post_id,'lsx_wetu_id',$matching_id );
244
-			$return = '<li class="post-' . $post_id . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $post_id ) . '">' . get_the_title( $post_id ) . '</a></li>';
243
+			add_post_meta($post_id, 'lsx_wetu_id', $matching_id);
244
+			$return = '<li class="post-'.$post_id.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a></li>';
245 245
 		}
246 246
 
247
-		print_r( $return );
247
+		print_r($return);
248 248
 		die();
249 249
 	}
250 250
 
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-destination.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -685,6 +685,7 @@  discard block
 block discarded – undo
685 685
 
686 686
 	/**
687 687
 	 * Set the team memberon each item.
688
+	 * @param boolean $team_members
688 689
 	 */
689 690
 	public function set_team_member( $id, $team_members ) {
690 691
 		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
@@ -696,6 +697,7 @@  discard block
 block discarded – undo
696 697
 
697 698
 	/**
698 699
 	 * Saves the room data
700
+	 * @param string $meta_key
699 701
 	 */
700 702
 	public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) {
701 703
 		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
Please login to merge, or discard this patch.
Spacing   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables() {
72 72
 		parent::set_variables();
73
-		$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
73
+		$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
74 74
 		$this->url_qs = 'all=include';
75
-		$temp_options = get_option( '_lsx-to_settings', false );
75
+		$temp_options = get_option('_lsx-to_settings', false);
76 76
 
77
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
78
-			$this->options = $temp_options[ $this->plugin_slug ];
77
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
78
+			$this->options = $temp_options[$this->plugin_slug];
79 79
 		}
80 80
 
81
-		$destination_options = get_option( 'lsx_wetu_importer_destination_settings', false );
81
+		$destination_options = get_option('lsx_wetu_importer_destination_settings', false);
82 82
 
83
-		if ( false !== $destination_options ) {
83
+		if (false !== $destination_options) {
84 84
 			$this->destination_options = $destination_options;
85 85
 		}
86 86
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			</div>
97 97
 
98 98
 			<form method="get" action="" id="posts-filter">
99
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/>
99
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/>
100 100
 
101 101
 				<table class="wp-list-table widefat fixed posts">
102 102
 					<?php $this->table_header(); ?>
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 					<tr class="post-0 type-tour status-none" id="post-0">
106 106
 						<th class="check-column" scope="row">
107 107
 							<label for="cb-select-0"
108
-								   class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label>
108
+								   class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label>
109 109
 						</th>
110 110
 						<td class="post-title page-title column-title">
111 111
 							<strong>
112
-								<?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?>
112
+								<?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?>
113 113
 							</strong>
114 114
 						</td>
115 115
 						<td class="date column-date">
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				</table>
125 125
 
126 126
 				<p><input class="button button-primary add" type="button"
127
-						  value="<?php esc_html_e( 'Add to List', 'lsx-wetu-importer' ); ?>"/>
127
+						  value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>"/>
128 128
 					<input class="button button-primary clear" type="button"
129
-						   value="<?php esc_html_e( 'Clear', 'lsx-wetu-importer' ); ?>"/>
129
+						   value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>"/>
130 130
 				</p>
131 131
 			</form>
132 132
 
@@ -136,118 +136,118 @@  discard block
 block discarded – undo
136 136
 
137 137
 					<div class="row">
138 138
 						<div class="settings-all" style="width:30%;display:block;float:left;">
139
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
139
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
140 140
 							<ul>
141 141
 								<li>
142
-									<input class="content select-all" <?php $this->checked( $this->destination_options, 'all' ); ?>
142
+									<input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?>
143 143
 										   type="checkbox" name="content[]"
144
-										   value="all"/> <?php esc_html_e( 'Select All', 'lsx-wetu-importer' ); ?></li>
145
-								<?php if ( isset( $this->options ) && isset( $this->options['disable_destination_descriptions'] ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?>
144
+										   value="all"/> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li>
145
+								<?php if (isset($this->options) && isset($this->options['disable_destination_descriptions']) && 'on' !== $this->options['disable_destination_descriptions']) { ?>
146 146
 								<li>
147
-									<input class="content" <?php $this->checked( $this->destination_options, 'description' ); ?>
147
+									<input class="content" <?php $this->checked($this->destination_options, 'description'); ?>
148 148
 										   type="checkbox" name="content[]"
149
-										   value="description"/> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
149
+										   value="description"/> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
150 150
 								<?php } ?>
151 151
 
152 152
 								<li>
153
-									<input class="content" <?php $this->checked( $this->destination_options, 'gallery' ); ?>
153
+									<input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?>
154 154
 										   type="checkbox" name="content[]"
155
-										   value="gallery"/> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li>
156
-								<?php if ( class_exists( 'LSX_TO_Maps' ) ) { ?>
155
+										   value="gallery"/> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li>
156
+								<?php if (class_exists('LSX_TO_Maps')) { ?>
157 157
 									<li>
158
-										<input class="content" <?php $this->checked( $this->destination_options, 'location' ); ?>
158
+										<input class="content" <?php $this->checked($this->destination_options, 'location'); ?>
159 159
 											   type="checkbox" name="content[]"
160
-											   value="location"/> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?></li>
160
+											   value="location"/> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?></li>
161 161
 								<?php } ?>
162 162
 
163
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
163
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
164 164
 									<li>
165
-										<input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?>
165
+										<input class="content" <?php $this->checked($this->destination_options, 'videos'); ?>
166 166
 											   type="checkbox" name="content[]"
167
-											   value="videos"/> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li>
167
+											   value="videos"/> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li>
168 168
 								<?php } ?>
169 169
 
170 170
 							</ul>
171
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
171
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
172 172
 							<ul>
173 173
 								<li>
174
-									<input class="content" <?php $this->checked( $this->destination_options, 'country' ); ?>
174
+									<input class="content" <?php $this->checked($this->destination_options, 'country'); ?>
175 175
 										   type="checkbox" name="content[]"
176
-										   value="country"/> <?php esc_html_e( 'Set Country', 'lsx-wetu-importer' ); ?></li>
176
+										   value="country"/> <?php esc_html_e('Set Country', 'lsx-wetu-importer'); ?></li>
177 177
 								<li>
178
-									<input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?>
178
+									<input class="content" <?php $this->checked($this->destination_options, 'continent'); ?>
179 179
 										   type="checkbox" name="content[]"
180
-										   value="continent"/> <?php esc_html_e( 'Set Continent', 'lsx-wetu-importer' ); ?></li>
180
+										   value="continent"/> <?php esc_html_e('Set Continent', 'lsx-wetu-importer'); ?></li>
181 181
 
182 182
 								<li>
183
-									<input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?>
183
+									<input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?>
184 184
 										   type="checkbox" name="content[]"
185
-										   value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?>
185
+										   value="featured_image"/> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?>
186 186
 								</li>
187
-								<?php if ( class_exists( 'LSX_Banners' ) ) { ?>
187
+								<?php if (class_exists('LSX_Banners')) { ?>
188 188
 									<li>
189
-										<input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?>
189
+										<input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?>
190 190
 											   type="checkbox" name="content[]"
191
-											   value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?>
191
+											   value="banner_image"/> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?>
192 192
 									</li>
193 193
 									<li>
194
-										<input class="content" <?php $this->checked( $this->destination_options, 'unique_banner_image' ); ?>
194
+										<input class="content" <?php $this->checked($this->destination_options, 'unique_banner_image'); ?>
195 195
 											   type="checkbox" name="content[]"
196
-											   value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'lsx-wetu-importer' ); ?>
196
+											   value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'lsx-wetu-importer'); ?>
197 197
 									</li>
198 198
 								<?php } ?>
199 199
 
200 200
 								<li>
201
-									<input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?>
201
+									<input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?>
202 202
 										   type="checkbox" name="content[]"
203
-										   value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'lsx-wetu-importer' ); ?></li>
203
+										   value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'lsx-wetu-importer'); ?></li>
204 204
 							</ul>
205 205
 						</div>
206 206
 						<div class="settings-all" style="width:30%;display:block;float:left;">
207
-							<h3><?php esc_html_e( 'Travel Information' ); ?></h3>
207
+							<h3><?php esc_html_e('Travel Information'); ?></h3>
208 208
 							<ul>
209 209
 								<li>
210
-									<input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?>
210
+									<input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?>
211 211
 										   type="checkbox" name="content[]"
212
-										   value="electricity"/> <?php esc_html_e( 'Electricity', 'lsx-wetu-importer' ); ?></li>
212
+										   value="electricity"/> <?php esc_html_e('Electricity', 'lsx-wetu-importer'); ?></li>
213 213
 								<li>
214
-									<input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?>
214
+									<input class="content" <?php $this->checked($this->destination_options, 'banking'); ?>
215 215
 										   type="checkbox" name="content[]"
216
-										   value="banking"/> <?php esc_html_e( 'Banking', 'lsx-wetu-importer' ); ?></li>
216
+										   value="banking"/> <?php esc_html_e('Banking', 'lsx-wetu-importer'); ?></li>
217 217
 								<li>
218
-									<input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?>
218
+									<input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?>
219 219
 										   type="checkbox" name="content[]"
220
-										   value="cuisine"/> <?php esc_html_e( 'Cuisine', 'lsx-wetu-importer' ); ?></li>
220
+										   value="cuisine"/> <?php esc_html_e('Cuisine', 'lsx-wetu-importer'); ?></li>
221 221
 								<li>
222
-									<input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?>
222
+									<input class="content" <?php $this->checked($this->destination_options, 'climate'); ?>
223 223
 										   type="checkbox" name="content[]"
224
-										   value="climate"/> <?php esc_html_e( 'Climate', 'lsx-wetu-importer' ); ?></li>
224
+										   value="climate"/> <?php esc_html_e('Climate', 'lsx-wetu-importer'); ?></li>
225 225
 								<li>
226
-									<input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?>
226
+									<input class="content" <?php $this->checked($this->destination_options, 'transport'); ?>
227 227
 										   type="checkbox" name="content[]"
228
-										   value="transport"/> <?php esc_html_e( 'Transport', 'lsx-wetu-importer' ); ?></li>
229
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?>
228
+										   value="transport"/> <?php esc_html_e('Transport', 'lsx-wetu-importer'); ?></li>
229
+								<li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?>
230 230
 										   type="checkbox" name="content[]"
231
-										   value="dress"/> <?php esc_html_e( 'Dress', 'lsx-wetu-importer' ); ?></li>
232
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?>
231
+										   value="dress"/> <?php esc_html_e('Dress', 'lsx-wetu-importer'); ?></li>
232
+								<li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?>
233 233
 										   type="checkbox" name="content[]"
234
-										   value="health"/> <?php esc_html_e( 'Health', 'lsx-wetu-importer' ); ?></li>
235
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?>
234
+										   value="health"/> <?php esc_html_e('Health', 'lsx-wetu-importer'); ?></li>
235
+								<li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?>
236 236
 										   type="checkbox" name="content[]"
237
-										   value="safety"/> <?php esc_html_e( 'Safety', 'lsx-wetu-importer' ); ?></li>
238
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?>
237
+										   value="safety"/> <?php esc_html_e('Safety', 'lsx-wetu-importer'); ?></li>
238
+								<li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?>
239 239
 										   type="checkbox" name="content[]"
240
-										   value="visa"/> <?php esc_html_e( 'Visa', 'lsx-wetu-importer' ); ?></li>
241
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?>
240
+										   value="visa"/> <?php esc_html_e('Visa', 'lsx-wetu-importer'); ?></li>
241
+								<li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?>
242 242
 										   type="checkbox" name="content[]"
243
-										   value="additional_info"/> <?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></li>
243
+										   value="additional_info"/> <?php esc_html_e('General', 'lsx-wetu-importer'); ?></li>
244 244
 							</ul>
245 245
 						</div>
246 246
 
247
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
247
+						<?php if (class_exists('LSX_TO_Team')) { ?>
248 248
 							<div style="width:30%;display:block;float:left;">
249
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
250
-								<?php $this->team_member_checkboxes( $this->destination_options ); ?>
249
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
250
+								<?php $this->team_member_checkboxes($this->destination_options); ?>
251 251
 							</div>
252 252
 						<?php } ?>
253 253
 
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 					</div>
256 256
 
257 257
 
258
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
258
+					<h3><?php esc_html_e('Your List'); ?></h3>
259 259
 					<p><input class="button button-primary" type="submit"
260
-							  value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p>
260
+							  value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p>
261 261
 					<table class="wp-list-table widefat fixed posts">
262 262
 						<?php $this->table_header(); ?>
263 263
 
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
 					</table>
271 271
 
272 272
 					<p><input class="button button-primary" type="submit"
273
-							  value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p>
273
+							  value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p>
274 274
 				</form>
275 275
 			</div>
276 276
 
277 277
 			<div style="display:none;" class="completed-list-wrapper">
278
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
278
+				<h3><?php esc_html_e('Completed'); ?></h3>
279 279
 				<ul>
280 280
 				</ul>
281 281
 			</div>
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	/**
287 287
 	 * Grab all the current destination posts via the lsx_wetu_id field.
288 288
 	 */
289
-	public function find_current_destination( $post_type = 'destination' ) {
289
+	public function find_current_destination($post_type = 'destination') {
290 290
 		global $wpdb;
291 291
 		$return = array();
292 292
 
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 		");
306 306
 		// @codingStandardsIgnoreEnd
307 307
 
308
-		if ( null !== $current_destination && ! empty( $current_destination ) ) {
309
-			foreach ( $current_destination as $accom ) {
310
-				$return[ $accom->meta_value ] = $accom;
308
+		if (null !== $current_destination && !empty($current_destination)) {
309
+			foreach ($current_destination as $accom) {
310
+				$return[$accom->meta_value] = $accom;
311 311
 			}
312 312
 		}
313 313
 
@@ -321,119 +321,119 @@  discard block
 block discarded – undo
321 321
 		$return = false;
322 322
 
323 323
 		// @codingStandardsIgnoreLine
324
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' ) {
324
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') {
325 325
 
326 326
 			$searched_items = false;
327 327
 
328 328
 			// @codingStandardsIgnoreLine
329
-			if ( isset( $_POST['keyword'] ) ) {
329
+			if (isset($_POST['keyword'])) {
330 330
 				// @codingStandardsIgnoreLine
331 331
 				$keyphrases = $_POST['keyword'];
332
-			} else {
333
-				$keyphrases = array( 0 );
332
+			}else {
333
+				$keyphrases = array(0);
334 334
 			}
335 335
 
336
-			if ( ! is_array( $keyphrases ) ) {
337
-				$keyphrases = array( $keyphrases );
336
+			if (!is_array($keyphrases)) {
337
+				$keyphrases = array($keyphrases);
338 338
 			}
339
-			foreach ( $keyphrases as &$keyword ) {
340
-				$keyword = ltrim( rtrim( $keyword ) );
339
+			foreach ($keyphrases as &$keyword) {
340
+				$keyword = ltrim(rtrim($keyword));
341 341
 			}
342 342
 
343 343
 			$post_status = false;
344 344
 
345
-			if ( in_array( 'publish', $keyphrases ) ) {
345
+			if (in_array('publish', $keyphrases)) {
346 346
 				$post_status = 'publish';
347 347
 			}
348
-			if ( in_array( 'pending', $keyphrases ) ) {
348
+			if (in_array('pending', $keyphrases)) {
349 349
 				$post_status = 'pending';
350 350
 			}
351
-			if ( in_array( 'draft', $keyphrases ) ) {
351
+			if (in_array('draft', $keyphrases)) {
352 352
 				$post_status = 'draft';
353 353
 			}
354
-			if ( in_array( 'import', $keyphrases ) ) {
354
+			if (in_array('import', $keyphrases)) {
355 355
 				$post_status = 'import';
356 356
 			}
357 357
 
358 358
 			// If there is a post status use it.
359
-			if ( false !== $post_status ) {
359
+			if (false !== $post_status) {
360 360
 
361 361
 				$accommodation = array();
362
-				$current_accommodation = $this->find_current_accommodation( 'destination' );
363
-				if ( ! empty( $current_accommodation ) ) {
364
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
365
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
362
+				$current_accommodation = $this->find_current_accommodation('destination');
363
+				if (!empty($current_accommodation)) {
364
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
365
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
366 366
 					}
367 367
 				}
368 368
 
369 369
 				// Run through each accommodation and use it.
370
-				if ( ! empty( $accommodation ) ) {
371
-					foreach ( $accommodation as $row_key => $row ) {
372
-						if ( 'import' === $post_status ) {
373
-
374
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
375
-								$current_status = get_post_status( $row['post_id'] );
376
-								if ( 'draft' === $current_status ) {
377
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
370
+				if (!empty($accommodation)) {
371
+					foreach ($accommodation as $row_key => $row) {
372
+						if ('import' === $post_status) {
373
+
374
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
375
+								$current_status = get_post_status($row['post_id']);
376
+								if ('draft' === $current_status) {
377
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
378 378
 								}
379
-							} else {
379
+							}else {
380 380
 								continue;
381 381
 							}
382
-						} else {
383
-							if ( 0 === $row['post_id'] ) {
382
+						}else {
383
+							if (0 === $row['post_id']) {
384 384
 								continue;
385
-							} else {
386
-								$current_status = get_post_status( $row['post_id'] );
385
+							}else {
386
+								$current_status = get_post_status($row['post_id']);
387 387
 
388
-								if ( $current_status !== $post_status ) {
388
+								if ($current_status !== $post_status) {
389 389
 									continue;
390 390
 								}
391 391
 							}
392
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
392
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
393 393
 						}
394 394
 					}
395 395
 				}
396
-			} else {
396
+			}else {
397 397
 
398
-				$key_string_search = implode( '+', $keyphrases );
399
-				$search_data = file_get_contents( $this->url . '/Search/' . $key_string_search . '/?all=include' );
400
-				$search_data = json_decode( $search_data, true );
398
+				$key_string_search = implode('+', $keyphrases);
399
+				$search_data = file_get_contents($this->url.'/Search/'.$key_string_search.'/?all=include');
400
+				$search_data = json_decode($search_data, true);
401 401
 
402
-				if ( ! isset( $search_data['error'] ) ) {
403
-					foreach ( $search_data as $sdata ) {
402
+				if (!isset($search_data['error'])) {
403
+					foreach ($search_data as $sdata) {
404 404
 
405
-						if ( 'Destination' !== trim( $sdata['type'] ) ) {
405
+						if ('Destination' !== trim($sdata['type'])) {
406 406
 							continue;
407 407
 						}
408 408
 
409
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
410
-						if ( false === $temp_id ) {
409
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
410
+						if (false === $temp_id) {
411 411
 							$sdata['post_id'] = 0;
412
-						} else {
412
+						}else {
413 413
 							$sdata['post_id'] = $temp_id;
414 414
 						}
415
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata );
415
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata);
416 416
 					}
417 417
 				}
418 418
 			}
419 419
 
420
-			if ( false !== $searched_items ) {
421
-				ksort( $searched_items );
422
-				$return = implode( $searched_items );
420
+			if (false !== $searched_items) {
421
+				ksort($searched_items);
422
+				$return = implode($searched_items);
423 423
 			}
424 424
 
425
-			print_r( $return );
425
+			print_r($return);
426 426
 		}
427 427
 
428 428
 		die();
429 429
 	}
430 430
 
431
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
431
+	public function prepare_row_attributes($cs_key, $ccs_id) {
432 432
 		$row_item = array(
433 433
 			'id' => $cs_key,
434 434
 			'type' => 'Destination',
435
-			'name' => get_the_title( $ccs_id ),
436
-			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
435
+			'name' => get_the_title($ccs_id),
436
+			'last_modified' => date('Y-m-d', strtotime('now')),
437 437
 			'post_id' => $ccs_id,
438 438
 		);
439 439
 		return $row_item;
@@ -442,28 +442,28 @@  discard block
 block discarded – undo
442 442
 	/**
443 443
 	 * Formats the row for output on the screen.
444 444
 	 */
445
-	public function format_row( $row = false ) {
446
-		if ( false !== $row ) {
445
+	public function format_row($row = false) {
446
+		if (false !== $row) {
447 447
 
448 448
 			$status = 'import';
449
-			if ( 0 !== $row['post_id'] ) {
450
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
449
+			if (0 !== $row['post_id']) {
450
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
451 451
 			}
452 452
 
453 453
 			$row_html = '
454
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
454
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
455 455
 				<th class="check-column" scope="row">
456
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
457
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
456
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
457
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
458 458
 				</th>
459 459
 				<td class="post-title page-title column-title">
460
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
460
+					<strong>' . $row['name'].'</strong> - '.$status.'
461 461
 				</td>
462 462
 				<td class="date column-date">
463
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
463
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
464 464
 				</td>
465 465
 				<td class="ssid column-ssid">
466
-					' . $row['id'] . '
466
+					' . $row['id'].'
467 467
 				</td>
468 468
 			</tr>';
469 469
 			return $row_html;
@@ -476,50 +476,50 @@  discard block
 block discarded – undo
476 476
 	public function process_ajax_import() {
477 477
 		$return = false;
478 478
 
479
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
480
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' && isset( $_POST['wetu_id'] ) ) {
479
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
480
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) {
481 481
 
482
-			$wetu_id = wp_unslash( $_POST['wetu_id'] );
482
+			$wetu_id = wp_unslash($_POST['wetu_id']);
483 483
 
484 484
 			// @codingStandardsIgnoreLine
485
-			if ( isset( $_POST['post_id'] ) ) {
485
+			if (isset($_POST['post_id'])) {
486 486
 				// @codingStandardsIgnoreLine
487 487
 				$post_id = $_POST['post_id'];
488
-				$this->current_post = get_post( $post_id );
489
-			} else {
488
+				$this->current_post = get_post($post_id);
489
+			}else {
490 490
 				$post_id = 0;
491 491
 			}
492 492
 
493 493
 			// @codingStandardsIgnoreLine
494
-			if ( isset( $_POST['team_members'] ) ) {
494
+			if (isset($_POST['team_members'])) {
495 495
 				// @codingStandardsIgnoreLine
496 496
 				$team_members = $_POST['team_members'];
497
-			} else {
497
+			}else {
498 498
 				$team_members = false;
499 499
 			}
500 500
 
501 501
 			$safari_brands = false;
502 502
 
503
-			delete_option( 'lsx_wetu_importer_destination_settings' );
503
+			delete_option('lsx_wetu_importer_destination_settings');
504 504
 
505 505
 			// @codingStandardsIgnoreLine
506
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
506
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
507 507
 				// @codingStandardsIgnoreLine
508 508
 				$content = $_POST['content'];
509
-				add_option( 'lsx_wetu_importer_destination_settings', $content );
510
-			} else {
509
+				add_option('lsx_wetu_importer_destination_settings', $content);
510
+			}else {
511 511
 				$content = false;
512 512
 			}
513 513
 
514
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
514
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
515 515
 
516
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
517
-				$adata = json_decode( $jdata, true );
518
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
519
-				$this->remove_from_queue( $return );
520
-				$this->format_completed_row( $return );
521
-			} else {
522
-				$this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer' ) );
516
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
517
+				$adata = json_decode($jdata, true);
518
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
519
+				$this->remove_from_queue($return);
520
+				$this->format_completed_row($return);
521
+			}else {
522
+				$this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer'));
523 523
 			}
524 524
 		}
525 525
 	}
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 	/**
528 528
 	 * Saves the queue to the option.
529 529
 	 */
530
-	public function remove_from_queue( $id ) {
531
-		if ( ! empty( $this->queued_imports ) ) {
532
-			$key = array_search( $id, $this->queued_imports );
533
-			if ( false !== $key ) {
534
-				unset( $this->queued_imports[ $key ] );
530
+	public function remove_from_queue($id) {
531
+		if (!empty($this->queued_imports)) {
532
+			$key = array_search($id, $this->queued_imports);
533
+			if (false !== $key) {
534
+				unset($this->queued_imports[$key]);
535 535
 
536
-				delete_option( 'lsx_wetu_importer_que' );
537
-				update_option( 'lsx_wetu_importer_que', $this->queued_imports );
536
+				delete_option('lsx_wetu_importer_que');
537
+				update_option('lsx_wetu_importer_que', $this->queued_imports);
538 538
 			}
539 539
 		}
540 540
 	}
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 	/**
543 543
 	 * Connect to wetu
544 544
 	 */
545
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
546
-		if ( 'Destination' === trim( $data[0]['type'] ) ) {
545
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
546
+		if ('Destination' === trim($data[0]['type'])) {
547 547
 			$post_name = '';
548 548
 			$data_post_content = '';
549 549
 			$data_post_excerpt = '';
@@ -552,132 +552,132 @@  discard block
 block discarded – undo
552 552
 				'post_type' => 'destination',
553 553
 			);
554 554
 
555
-			if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) {
556
-				$parent = $this->check_for_parent( $data );
557
-				if ( false !== $parent ) {
555
+			if (!empty($importable_content) && in_array('country', $importable_content)) {
556
+				$parent = $this->check_for_parent($data);
557
+				if (false !== $parent) {
558 558
 					$post['post_parent'] = $parent;
559 559
 				}
560 560
 			}
561 561
 
562 562
 			// Set the post_content.
563
-			if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
564
-				if ( isset( $data[0]['content']['general_description'] ) ) {
563
+			if (!empty($importable_content) && in_array('description', $importable_content)) {
564
+				if (isset($data[0]['content']['general_description'])) {
565 565
 
566
-					if ( in_array( 'strip_tags', $importable_content ) ) {
567
-						$post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] );
568
-					} else {
566
+					if (in_array('strip_tags', $importable_content)) {
567
+						$post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']);
568
+					}else {
569 569
 						$post['post_content'] = $data[0]['content']['general_description'];
570 570
 					}
571 571
 				}
572 572
 			}
573 573
 
574
-			if ( false !== $id && '0' !== $id ) {
574
+			if (false !== $id && '0' !== $id) {
575 575
 				$post['ID'] = $id;
576 576
 
577
-				if ( isset( $data[0]['name'] ) ) {
577
+				if (isset($data[0]['name'])) {
578 578
 					$post['post_title'] = $data[0]['name'];
579 579
 					$post['post_status'] = 'publish';
580
-					$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
580
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
581 581
 				}
582 582
 
583
-				$id = wp_update_post( $post );
584
-				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
585
-				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
586
-			} else {
583
+				$id = wp_update_post($post);
584
+				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
585
+				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
586
+			}else {
587 587
 				// Set the name.
588
-				if ( isset( $data[0]['name'] ) ) {
589
-					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
588
+				if (isset($data[0]['name'])) {
589
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
590 590
 				}
591 591
 
592 592
 				$post['post_name'] = $post_name;
593 593
 				$post['post_title'] = $data[0]['name'];
594 594
 				$post['post_status'] = 'publish';
595
-				$id = wp_insert_post( $post );
595
+				$id = wp_insert_post($post);
596 596
 
597 597
 				// Save the WETU ID and the Last date it was modified.
598
-				if ( false !== $id ) {
599
-					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
600
-					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
598
+				if (false !== $id) {
599
+					add_post_meta($id, 'lsx_wetu_id', $wetu_id);
600
+					add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
601 601
 				}
602 602
 			}
603 603
 
604
-			$this->find_attachments( $id );
604
+			$this->find_attachments($id);
605 605
 
606 606
 			// Set the team member if it is there.
607
-			if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
608
-				$this->set_team_member( $id, $team_members );
607
+			if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
608
+				$this->set_team_member($id, $team_members);
609 609
 			}
610 610
 
611
-			if ( class_exists( 'LSX_TO_Maps' ) ) {
612
-				$this->set_map_data( $data, $id, 9 );
611
+			if (class_exists('LSX_TO_Maps')) {
612
+				$this->set_map_data($data, $id, 9);
613 613
 			}
614 614
 
615 615
 			// Set the Room Data.
616
-			if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
617
-				$this->set_video_data( $data, $id );
616
+			if (false !== $importable_content && in_array('videos', $importable_content)) {
617
+				$this->set_video_data($data, $id);
618 618
 			}
619 619
 
620 620
 			// Set the Electricity.
621
-			if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) {
622
-				$this->set_travel_info( $data, $id, 'electricity', $importable_content );
621
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
622
+				$this->set_travel_info($data, $id, 'electricity', $importable_content);
623 623
 			}
624 624
 			// Set the cuisine.
625
-			if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) {
626
-				$this->set_travel_info( $data, $id, 'cuisine', $importable_content );
625
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
626
+				$this->set_travel_info($data, $id, 'cuisine', $importable_content);
627 627
 			}
628 628
 			// Set the banking.
629
-			if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) {
630
-				$this->set_travel_info( $data, $id, 'banking', $importable_content );
629
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
630
+				$this->set_travel_info($data, $id, 'banking', $importable_content);
631 631
 			}
632 632
 			// Set the transport.
633
-			if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) {
634
-				$this->set_travel_info( $data, $id, 'transport', $importable_content );
633
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
634
+				$this->set_travel_info($data, $id, 'transport', $importable_content);
635 635
 			}
636 636
 			// Set the dress.
637
-			if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) {
638
-				$this->set_travel_info( $data, $id, 'dress', $importable_content );
637
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
638
+				$this->set_travel_info($data, $id, 'dress', $importable_content);
639 639
 			}
640 640
 			// Set the climate.
641
-			if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) {
642
-				$this->set_travel_info( $data, $id, 'climate', $importable_content );
641
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
642
+				$this->set_travel_info($data, $id, 'climate', $importable_content);
643 643
 			}
644 644
 			// Set the Health.
645
-			if ( false !== $importable_content && in_array( 'health', $importable_content ) ) {
646
-				$this->set_travel_info( $data, $id, 'health', $importable_content );
645
+			if (false !== $importable_content && in_array('health', $importable_content)) {
646
+				$this->set_travel_info($data, $id, 'health', $importable_content);
647 647
 			}
648 648
 			// Set the Safety.
649
-			if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) {
650
-				$this->set_travel_info( $data, $id, 'safety', $importable_content );
649
+			if (false !== $importable_content && in_array('safety', $importable_content)) {
650
+				$this->set_travel_info($data, $id, 'safety', $importable_content);
651 651
 			}
652 652
 			// Set the Visa.
653
-			if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) {
654
-				$this->set_travel_info( $data, $id, 'visa', $importable_content );
653
+			if (false !== $importable_content && in_array('visa', $importable_content)) {
654
+				$this->set_travel_info($data, $id, 'visa', $importable_content);
655 655
 			}
656 656
 			// Set the General.
657
-			if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) {
658
-				$this->set_travel_info( $data, $id, 'additional_info', $importable_content );
657
+			if (false !== $importable_content && in_array('additional_info', $importable_content)) {
658
+				$this->set_travel_info($data, $id, 'additional_info', $importable_content);
659 659
 			}
660 660
 
661 661
 			// Setup some default for use in the import.
662
-			if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) {
663
-				$this->find_attachments( $id );
662
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
663
+				$this->find_attachments($id);
664 664
 
665 665
 				// Set the featured image.
666
-				if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
667
-					$this->set_featured_image( $data, $id );
666
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
667
+					$this->set_featured_image($data, $id);
668 668
 				}
669
-				if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
670
-					$this->set_banner_image( $data, $id, $importable_content );
669
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
670
+					$this->set_banner_image($data, $id, $importable_content);
671 671
 				}
672 672
 				// Import the main gallery.
673
-				if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
674
-					$this->create_main_gallery( $data, $id );
673
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
674
+					$this->create_main_gallery($data, $id);
675 675
 				}
676 676
 			}
677 677
 
678 678
 			// Set the continent.
679
-			if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) {
680
-				$this->set_continent( $data, $id );
679
+			if (false !== $importable_content && in_array('continent', $importable_content)) {
680
+				$this->set_continent($data, $id);
681 681
 			}
682 682
 		}
683 683
 
@@ -687,48 +687,48 @@  discard block
 block discarded – undo
687 687
 	/**
688 688
 	 * Set the team memberon each item.
689 689
 	 */
690
-	public function set_team_member( $id, $team_members ) {
691
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
690
+	public function set_team_member($id, $team_members) {
691
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
692 692
 
693
-		foreach ( $team_members as $team ) {
694
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
693
+		foreach ($team_members as $team) {
694
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
695 695
 		}
696 696
 	}
697 697
 
698 698
 	/**
699 699
 	 * Saves the room data
700 700
 	 */
701
-	public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) {
702
-		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
703
-			$content = $data[0]['travel_information'][ $meta_key ];
701
+	public function set_travel_info($data, $id, $meta_key, $importable = array('none')) {
702
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
703
+			$content = $data[0]['travel_information'][$meta_key];
704 704
 
705
-			if ( in_array( 'strip_tags', $importable ) ) {
706
-				$content = strip_tags( $content );
705
+			if (in_array('strip_tags', $importable)) {
706
+				$content = strip_tags($content);
707 707
 			}
708 708
 
709
-			$this->save_custom_field( $content, $meta_key, $id );
709
+			$this->save_custom_field($content, $meta_key, $id);
710 710
 		}
711 711
 	}
712 712
 
713 713
 	/**
714 714
 	 * Set the Travel Style
715 715
 	 */
716
-	public function set_continent( $data, $id ) {
716
+	public function set_continent($data, $id) {
717 717
 
718
-		if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) {
718
+		if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) {
719 719
 			//get the continent code.
720
-			$continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) );
720
+			$continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false)));
721 721
 
722
-			if ( '' !== $continent_code ) {
723
-				$term = term_exists( trim( $continent_code ), 'continent' );
724
-				if ( ! $term ) {
725
-					$term = wp_insert_term( trim( $continent_code ), 'continent' );
722
+			if ('' !== $continent_code) {
723
+				$term = term_exists(trim($continent_code), 'continent');
724
+				if (!$term) {
725
+					$term = wp_insert_term(trim($continent_code), 'continent');
726 726
 
727
-					if ( is_wp_error( $term ) ) {
728
-						echo wp_kses_post( $term->get_error_message() );
727
+					if (is_wp_error($term)) {
728
+						echo wp_kses_post($term->get_error_message());
729 729
 					}
730
-				} else {
731
-					wp_set_object_terms( $id, sanitize_title( $continent_code ), 'continent', true );
730
+				}else {
731
+					wp_set_object_terms($id, sanitize_title($continent_code), 'continent', true);
732 732
 				}
733 733
 			}
734 734
 		}
@@ -738,14 +738,14 @@  discard block
 block discarded – undo
738 738
 	 * Save the list of Accommodation into an option
739 739
 	 */
740 740
 	public function update_options() {
741
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
741
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
742 742
 
743
-		$accommodation = json_decode( $data, true );
743
+		$accommodation = json_decode($data, true);
744 744
 
745
-		if ( isset( $accommodation['error'] ) ) {
745
+		if (isset($accommodation['error'])) {
746 746
 			return $accommodation['error'];
747
-		} elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) {
748
-			set_transient( 'lsx_ti_accommodation', $accommodation,60 * 60 * 2 );
747
+		} elseif (isset($accommodation) && !empty($accommodation)) {
748
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
749 749
 			return true;
750 750
 		}
751 751
 	}
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
 	 * search_form
755 755
 	 */
756 756
 	public function update_options_form() {
757
-		echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'lsx-wetu-importer' ) . '</h3>';
757
+		echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').'</h3>';
758 758
 
759
-		$accommodation = get_transient( 'lsx_ti_accommodation' );
759
+		$accommodation = get_transient('lsx_ti_accommodation');
760 760
 
761
-		if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) {
761
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
762 762
 			$this->update_options();
763 763
 		}
764 764
 
@@ -768,12 +768,12 @@  discard block
 block discarded – undo
768 768
 	/**
769 769
 	 * Save the list of Accommodation into an option
770 770
 	 */
771
-	public function check_for_parent( $data = array() ) {
771
+	public function check_for_parent($data = array()) {
772 772
 		global $wpdb;
773 773
 
774
-		if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) {
775
-			$result = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array( $data[0]['position']['country_content_entity_id'] ) ) );
776
-			if ( ! empty( $result ) && '' !== $result && false !== $result ) {
774
+		if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) {
775
+			$result = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array($data[0]['position']['country_content_entity_id'])));
776
+			if (!empty($result) && '' !== $result && false !== $result) {
777 777
 				return $result;
778 778
 			}
779 779
 		}
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-tours.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -924,7 +924,6 @@  discard block
 block discarded – undo
924 924
 	 * Takes the WETU tags and sets the Travel Styles.
925 925
 	 *
926 926
 	 * @param string $id
927
-	 * @param array $travel_styles
928 927
 	 * @return void
929 928
 	 */
930 929
 	public function set_travel_styles( $id, $data ) {
@@ -997,6 +996,7 @@  discard block
 block discarded – undo
997 996
 	 *
998 997
 	 * @param $day array
999 998
 	 * @param $id string
999
+	 * @param integer $leg_counter
1000 1000
 	 * @return boolean / string
1001 1001
 	 */
1002 1002
 	public function set_destination( $day, $id, $leg_counter ) {
Please login to merge, or discard this patch.
Spacing   +388 added lines, -388 removed lines patch added patch discarded remove patch
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function set_variables() {
99 99
 		parent::set_variables();
100
-		if ( false !== $this->api_key ) {
101
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
100
+		if (false !== $this->api_key) {
101
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
102 102
 			$this->url_qs = '';
103 103
 		}
104
-		$tour_options = get_option( 'lsx_wetu_importer_tour_settings',false );
105
-		if ( false !== $tour_options ) {
104
+		$tour_options = get_option('lsx_wetu_importer_tour_settings', false);
105
+		if (false !== $tour_options) {
106 106
 			$this->tour_options = $tour_options;
107 107
 		}
108 108
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 
128 128
 			<form method="get" action="" id="posts-filter">
129
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
129
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
130 130
 
131 131
 				<table class="wp-list-table widefat fixed posts">
132 132
 					<?php $this->table_header(); ?>
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 					<tbody id="the-list">
135 135
 						<tr class="post-0 type-tour status-none" id="post-0">
136 136
 							<th class="check-column" scope="row">
137
-								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter','lsx-wetu-importer' ); ?></label>
137
+								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label>
138 138
 							</th>
139 139
 							<td class="date column-date column-ref" colspan="4">
140 140
 								<strong>
141
-									<?php esc_html_e( 'Search for tours using the search form above','lsx-wetu-importer' ); ?>
141
+									<?php esc_html_e('Search for tours using the search form above', 'lsx-wetu-importer'); ?>
142 142
 								</strong>
143 143
 							</td>
144 144
 						</tr>
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 
149 149
 				</table>
150 150
 
151
-				<p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','lsx-wetu-importer' ); ?>" />
152
-					<input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','lsx-wetu-importer' ); ?>" />
151
+				<p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>" />
152
+					<input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>" />
153 153
 				</p>
154 154
 			</form>
155 155
 
@@ -159,51 +159,51 @@  discard block
 block discarded – undo
159 159
 
160 160
 					<div class="row">
161 161
 						<div class="settings-all" style="width:30%;display:block;float:left;">
162
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
162
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
163 163
 							<ul>
164
-								<li><input class="content select-all" <?php $this->checked( $this->tour_options,'all' ); ?> type="checkbox"name="content[]"  value="all" /> <?php esc_html_e( 'Select All','lsx-wetu-importer' ); ?></li>
164
+								<li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li>
165 165
 
166
-								<?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_descriptions'] ) ) { ?>
167
-									<li><input class="content" <?php $this->checked( $this->tour_options,'description' ); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li>
166
+								<?php if (isset($this->options) && !isset($this->options['disable_tour_descriptions'])) { ?>
167
+									<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
168 168
 								<?php } ?>
169 169
 
170
-								<li><input class="content" <?php $this->checked( $this->tour_options,'price' ); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price','lsx-wetu-importer' ); ?></li>
171
-								<li><input class="content" <?php $this->checked( $this->tour_options,'duration' ); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration','lsx-wetu-importer' ); ?></li>
172
-								<li><input class="content" <?php $this->checked( $this->tour_options,'group_size' ); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e( 'Group Size','lsx-wetu-importer' ); ?></li>
173
-								<li><input class="content" <?php $this->checked( $this->tour_options,'category' ); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category','lsx-wetu-importer' ); ?></li>
174
-								<li><input class="content" <?php $this->checked( $this->tour_options,'tags' ); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e( 'Tags','lsx-wetu-importer' ); ?></li>
170
+								<li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'lsx-wetu-importer'); ?></li>
171
+								<li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'lsx-wetu-importer'); ?></li>
172
+								<li><input class="content" <?php $this->checked($this->tour_options, 'group_size'); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e('Group Size', 'lsx-wetu-importer'); ?></li>
173
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li>
174
+								<li><input class="content" <?php $this->checked($this->tour_options, 'tags'); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e('Tags', 'lsx-wetu-importer'); ?></li>
175 175
 
176
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itineraries' ); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days','lsx-wetu-importer' ); ?></li>
176
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'lsx-wetu-importer'); ?></li>
177 177
 							</ul>
178 178
 						</div>
179 179
 						<div class="settings-all" style="width:30%;display:block;float:left;">
180
-							<h3><?php esc_html_e( 'Itinerary Info' ); ?></h3>
180
+							<h3><?php esc_html_e('Itinerary Info'); ?></h3>
181 181
 							<ul>
182
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_description' ); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li>
183
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_included' ); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included','lsx-wetu-importer' ); ?></li>
184
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_excluded' ); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded','lsx-wetu-importer' ); ?></li>
182
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
183
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'lsx-wetu-importer'); ?></li>
184
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'lsx-wetu-importer'); ?></li>
185 185
 							</ul>
186 186
 
187
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
187
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
188 188
 							<ul>
189
-								<li><input class="content" <?php $this->checked( $this->tour_options,'accommodation' ); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation','lsx-wetu-importer' ); ?></li>
190
-								<li><input class="content" <?php $this->checked( $this->tour_options,'destination' ); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations','lsx-wetu-importer' ); ?></li>
191
-								<li><input class="content" <?php $this->checked( $this->tour_options,'featured_image' ); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Featured Image','lsx-wetu-importer' ); ?></li>
192
-								<li><input class="content" <?php $this->checked( $this->tour_options,'banner_image' ); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Banner Image','lsx-wetu-importer' ); ?></li>
189
+								<li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'lsx-wetu-importer'); ?></li>
190
+								<li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'lsx-wetu-importer'); ?></li>
191
+								<li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Featured Image', 'lsx-wetu-importer'); ?></li>
192
+								<li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Banner Image', 'lsx-wetu-importer'); ?></li>
193 193
 							</ul>
194 194
 						</div>
195
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
195
+						<?php if (class_exists('LSX_TO_Team')) { ?>
196 196
 							<div style="width:30%;display:block;float:left;">
197
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
198
-								<?php $this->team_member_checkboxes( $this->tour_options ); ?>
197
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
198
+								<?php $this->team_member_checkboxes($this->tour_options); ?>
199 199
 							</div>
200 200
 						<?php } ?>
201 201
 
202 202
 						<br clear="both" />
203 203
 					</div>
204 204
 
205
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
206
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','lsx-wetu-importer' ); ?>" /></p>
205
+					<h3><?php esc_html_e('Your List'); ?></h3>
206
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
207 207
 					<table class="wp-list-table widefat fixed posts">
208 208
 						<?php $this->table_header(); ?>
209 209
 
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 
216 216
 					</table>
217 217
 
218
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','lsx-wetu-importer' ); ?>" /></p>
218
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
219 219
 				</form>
220 220
 			</div>
221 221
 
222 222
 			<div style="display:none;" class="completed-list-wrapper">
223
-				<h3><?php esc_html_e( 'Completed', 'lsx-wetu-importer' ); ?> - <small><?php esc_html_e( 'Import your', 'lsx-wetu-importer' ); ?> <a href="<?php echo esc_attr( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=accommodation"><?php esc_html_e( 'accommodation' ); ?></a> <?php esc_html_e( 'next','lsx-wetu-importer' ); ?></small></h3>
223
+				<h3><?php esc_html_e('Completed', 'lsx-wetu-importer'); ?> - <small><?php esc_html_e('Import your', 'lsx-wetu-importer'); ?> <a href="<?php echo esc_attr(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=accommodation"><?php esc_html_e('accommodation'); ?></a> <?php esc_html_e('next', 'lsx-wetu-importer'); ?></small></h3>
224 224
 				<ul>
225 225
 				</ul>
226 226
 			</div>
@@ -234,23 +234,23 @@  discard block
 block discarded – undo
234 234
 	 * @return void
235 235
 	 */
236 236
 	public function update_options_form() {
237
-		$form_options = get_option( 'lsx_ti_tours_api_options' );
238
-		if ( false === $form_options ) {
239
-			$form_options = array( 'sample' );
237
+		$form_options = get_option('lsx_ti_tours_api_options');
238
+		if (false === $form_options) {
239
+			$form_options = array('sample');
240 240
 		}
241 241
 		?>
242 242
 		<form method="get" class="tour-refresh-form">
243
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" />
243
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" />
244 244
 			<input type="hidden" name="tab" value="tour" />
245 245
 			<input type="hidden" name="refresh_tours" value="true" />
246 246
 			<input class="content" type="hidden" name="own" value="true" />
247 247
 
248 248
 			<select name="type" id="wpseo-readability-filter">
249
-				<option <?php if ( in_array( 'allitineraries', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?> value="allitineraries"><?php esc_html_e( 'All Itineraries','lsx-wetu-importer' ); ?></option>
250
-				<option <?php if ( in_array( 'sample', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="bad"><?php esc_html_e( 'Sample','lsx-wetu-importer' ); ?></option>
251
-				<option <?php if ( in_array( 'personal', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="ok"><?php esc_html_e( 'Personal','lsx-wetu-importer' ); ?></option>
249
+				<option <?php if (in_array('allitineraries', $form_options)) { echo esc_attr('selected="selected"'); } ?> value="allitineraries"><?php esc_html_e('All Itineraries', 'lsx-wetu-importer'); ?></option>
250
+				<option <?php if (in_array('sample', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="bad"><?php esc_html_e('Sample', 'lsx-wetu-importer'); ?></option>
251
+				<option <?php if (in_array('personal', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="ok"><?php esc_html_e('Personal', 'lsx-wetu-importer'); ?></option>
252 252
 			</select>
253
-			<input class="button submit" type="submit" value="<?php esc_attr_e( 'Refresh', 'lsx-wetu-importer' ); ?>" />
253
+			<input class="button submit" type="submit" value="<?php esc_attr_e('Refresh', 'lsx-wetu-importer'); ?>" />
254 254
 		</form>
255 255
 		<?php
256 256
 	}
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 			LIMIT 0,500
276 276
 		");
277 277
 
278
-		if ( null !== $current_tours && ! empty( $current_tours ) ) {
279
-			foreach ( $current_tours as $tour ) {
280
-				$return[ $tour->meta_value ] = $tour;
278
+		if (null !== $current_tours && !empty($current_tours)) {
279
+			foreach ($current_tours as $tour) {
280
+				$return[$tour->meta_value] = $tour;
281 281
 			}
282 282
 		}
283 283
 
@@ -289,45 +289,45 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function process_ajax_search() {
291 291
 		$return = false;
292
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
292
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
293 293
 
294
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) {
295
-			$tours = get_transient( 'lsx_ti_tours' );
294
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
295
+			$tours = get_transient('lsx_ti_tours');
296 296
 
297
-			if ( false !== $tours ) {
297
+			if (false !== $tours) {
298 298
 				$searched_items = false;
299
-				if ( isset( $_POST['keyword'] ) ) {
300
-					$keyphrases = wp_unslash( $_POST['keyword'] );
301
-				} else {
302
-					$keyphrases = array( 0 );
299
+				if (isset($_POST['keyword'])) {
300
+					$keyphrases = wp_unslash($_POST['keyword']);
301
+				}else {
302
+					$keyphrases = array(0);
303 303
 				}
304 304
 
305
-				if ( ! is_array( $keyphrases ) ) {
306
-					$keyphrases = array( $keyphrases );
305
+				if (!is_array($keyphrases)) {
306
+					$keyphrases = array($keyphrases);
307 307
 				}
308
-				foreach ( $keyphrases as &$keyword ) {
309
-					$keyword = ltrim( rtrim( $keyword ) );
308
+				foreach ($keyphrases as &$keyword) {
309
+					$keyword = ltrim(rtrim($keyword));
310 310
 				}
311 311
 
312 312
 				$post_status = false;
313
-				if ( in_array( 'publish',$keyphrases ) ) {
313
+				if (in_array('publish', $keyphrases)) {
314 314
 					$post_status = 'publish';
315 315
 				}
316
-				if ( in_array( 'pending',$keyphrases ) ) {
316
+				if (in_array('pending', $keyphrases)) {
317 317
 					$post_status = 'pending';
318 318
 				}
319
-				if ( in_array( 'draft',$keyphrases ) ) {
319
+				if (in_array('draft', $keyphrases)) {
320 320
 					$post_status = 'draft';
321 321
 				}
322
-				if ( in_array( 'import',$keyphrases ) ) {
322
+				if (in_array('import', $keyphrases)) {
323 323
 					$post_status = 'import';
324 324
 				}
325 325
 
326
-				if ( ! empty( $tours ) ) {
326
+				if (!empty($tours)) {
327 327
 					$current_tours = $this->find_current_tours();
328 328
 
329
-					foreach ( $tours as $row_key => $row ) {
330
-						if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) {
329
+					foreach ($tours as $row_key => $row) {
330
+						if (isset($row['is_disabled']) && true === $row['is_disabled']) {
331 331
 							continue;
332 332
 						}
333 333
 
@@ -338,60 +338,60 @@  discard block
 block discarded – undo
338 338
 						//If this is a current tour, add its ID to the row.
339 339
 						$row['post_id'] = 0;
340 340
 
341
-						if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) {
342
-							$row['post_id'] = $current_tours[ $row['identifier'] ]->post_id;
341
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
342
+							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
343 343
 						}
344 344
 
345 345
 						//If we are searching for
346
-						if ( false !== $post_status ) {
347
-							if ( 'import' === $post_status ) {
346
+						if (false !== $post_status) {
347
+							if ('import' === $post_status) {
348 348
 
349
-								if ( 0 !== $row['post_id'] ) {
349
+								if (0 !== $row['post_id']) {
350 350
 									continue;
351
-								} else {
352
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
351
+								}else {
352
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
353 353
 								}
354
-							} else {
355
-								if ( 0 === $row['post_id'] ) {
354
+							}else {
355
+								if (0 === $row['post_id']) {
356 356
 									continue;
357
-								} else {
358
-									$current_status = get_post_status( $row['post_id'] );
357
+								}else {
358
+									$current_status = get_post_status($row['post_id']);
359 359
 
360
-									if ( $current_status !== $post_status ) {
360
+									if ($current_status !== $post_status) {
361 361
 										continue;
362 362
 									}
363 363
 								}
364 364
 
365
-								$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
365
+								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
366 366
 							}
367
-						} else {
367
+						}else {
368 368
 							// Search through each keyword.
369
-							foreach ( $keyphrases as $keyphrase ) {
369
+							foreach ($keyphrases as $keyphrase) {
370 370
 
371 371
 								// Make sure the keyphrase is turned into an array.
372
-								$keywords = explode( ' ',$keyphrase );
373
-								if ( ! is_array( $keywords ) ) {
374
-									$keywords = array( $keywords );
372
+								$keywords = explode(' ', $keyphrase);
373
+								if (!is_array($keywords)) {
374
+									$keywords = array($keywords);
375 375
 								}
376 376
 
377
-								if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) {
378
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
379
-								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) {
380
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
381
-								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) {
382
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
377
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
378
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
379
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['reference_number'])), $keywords) !== false) {
380
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
381
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['identifier_key'])), $keywords) !== false) {
382
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
383 383
 								}
384 384
 							}
385 385
 						}
386 386
 					}
387 387
 				}
388 388
 
389
-				if ( false !== $searched_items ) {
390
-					ksort( $searched_items );
391
-					$return = implode( $searched_items );
389
+				if (false !== $searched_items) {
390
+					ksort($searched_items);
391
+					$return = implode($searched_items);
392 392
 				}
393 393
 			}
394
-			print_r( $return );
394
+			print_r($return);
395 395
 			die();
396 396
 		}
397 397
 	}
@@ -399,31 +399,31 @@  discard block
 block discarded – undo
399 399
 	/**
400 400
 	 * Formats the row for output on the screen.
401 401
 	 */
402
-	public function format_row( $row = false ) {
403
-		if ( false !== $row ) {
402
+	public function format_row($row = false) {
403
+		if (false !== $row) {
404 404
 			$status = 'import';
405 405
 
406
-			if ( 0 !== $row['post_id'] ) {
407
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
406
+			if (0 !== $row['post_id']) {
407
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
408 408
 			}
409 409
 
410 410
 			$row_html = '
411
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
411
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
412 412
 				<th class="check-column" scope="row">
413
-					<label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['name'] . '</label>
414
-					<input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '">
413
+					<label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['name'].'</label>
414
+					<input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'">
415 415
 				</th>			
416 416
 				<td class="post-title page-title column-title">
417
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
417
+					<strong>' . $row['name'].'</strong> - '.$status.'
418 418
 				</td>
419 419
 				<td class="date column-date">
420
-					' . $row['reference_number'] . '
420
+					' . $row['reference_number'].'
421 421
 				</td>				
422 422
 				<td class="date column-date">
423
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
423
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
424 424
 				</td>
425 425
 				<td class="ssid column-ssid">
426
-					' . $row['identifier'] . '
426
+					' . $row['identifier'].'
427 427
 				</td>
428 428
 			</tr>';
429 429
 			return $row_html;
@@ -433,45 +433,45 @@  discard block
 block discarded – undo
433 433
 	/**
434 434
 	 * Connect to wetu
435 435
 	 */
436
-	public function process_ajax_import( $force = false ) {
436
+	public function process_ajax_import($force = false) {
437 437
 		$return = false;
438 438
 
439 439
 		// @codingStandardsIgnoreLine
440
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) {
440
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
441 441
 
442 442
 			// @codingStandardsIgnoreLine
443 443
 			$wetu_id = $_POST['wetu_id'];
444 444
 
445 445
 			// @codingStandardsIgnoreLine
446
-			if ( isset( $_POST['post_id'] ) ) {
446
+			if (isset($_POST['post_id'])) {
447 447
 				// @codingStandardsIgnoreLine
448 448
 				$post_id = $_POST['post_id'];
449
-			} else {
449
+			}else {
450 450
 				$post_id = 0;
451 451
 			}
452 452
 
453
-			delete_option( 'lsx_wetu_importer_tour_settings' );
453
+			delete_option('lsx_wetu_importer_tour_settings');
454 454
 
455 455
 			// @codingStandardsIgnoreLine
456
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
456
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
457 457
 				// @codingStandardsIgnoreLine
458 458
 				$content = $_POST['content'];
459
-				add_option( 'lsx_wetu_importer_tour_settings',$content );
460
-			} else {
459
+				add_option('lsx_wetu_importer_tour_settings', $content);
460
+			}else {
461 461
 				$content = false;
462 462
 			}
463
-			$jdata = wp_remote_get( 'https://wetu.com/API/Itinerary/V8/Get?id=' . $wetu_id );
463
+			$jdata = wp_remote_get('https://wetu.com/API/Itinerary/V8/Get?id='.$wetu_id);
464 464
 
465
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
466
-				$jdata = json_decode( $jdata['body'], true );
467
-				$return = $this->import_row( $jdata, $wetu_id, $post_id, $content );
468
-				$this->format_completed_row( $return );
465
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
466
+				$jdata = json_decode($jdata['body'], true);
467
+				$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
468
+				$this->format_completed_row($return);
469 469
 				$this->save_queue();
470 470
 				$this->cleanup_posts();
471
-				$this->attach_destination_images( $content );
472
-				$this->clean_attached_destinations( $return );
473
-			} else {
474
-				$this->format_error( esc_html__( 'There was a problem importing your tour, please contact support.', 'lsx-wetu-importer' ) );
471
+				$this->attach_destination_images($content);
472
+				$this->clean_attached_destinations($return);
473
+			}else {
474
+				$this->format_error(esc_html__('There was a problem importing your tour, please contact support.', 'lsx-wetu-importer'));
475 475
 			}
476 476
 		}
477 477
 	}
@@ -482,13 +482,13 @@  discard block
 block discarded – undo
482 482
 	 * @param $id string
483 483
 	 * @return void
484 484
 	 */
485
-	public function clean_attached_destinations( $id ) {
486
-		$current_connections = get_post_meta( $id, 'destination_to_tour', false );
487
-		delete_post_meta( $id,'destination_to_tour' );
488
-		$current_connections = array_unique( $current_connections );
485
+	public function clean_attached_destinations($id) {
486
+		$current_connections = get_post_meta($id, 'destination_to_tour', false);
487
+		delete_post_meta($id, 'destination_to_tour');
488
+		$current_connections = array_unique($current_connections);
489 489
 
490
-		foreach ( $current_connections as $connection ) {
491
-			add_post_meta( $id, 'destination_to_tour',$connection, false );
490
+		foreach ($current_connections as $connection) {
491
+			add_post_meta($id, 'destination_to_tour', $connection, false);
492 492
 		}
493 493
 	}
494 494
 
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
 	 * @param $data array
499 499
 	 * @param $wetu_id string
500 500
 	 */
501
-	public function import_row( $data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false ) {
501
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false) {
502 502
 		$post_name = '';
503 503
 		$data_post_content = '';
504 504
 		$data_post_excerpt = '';
505 505
 
506
-		$current_post = get_post( $id );
506
+		$current_post = get_post($id);
507 507
 
508 508
 		$post = array(
509 509
 			'post_type' => 'tour',
@@ -511,70 +511,70 @@  discard block
 block discarded – undo
511 511
 
512 512
 		$content_used_general_description = false;
513 513
 
514
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
514
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
515 515
 			$data_post_content = $current_post->post_content;
516
-			if ( isset( $data['summary'] ) && ! empty( $data['summary'] ) ) {
516
+			if (isset($data['summary']) && !empty($data['summary'])) {
517 517
 				$data_post_content = $data['summary'];
518 518
 			}
519 519
 			$post['post_content'] = $data_post_content;
520 520
 		}
521 521
 
522 522
 		// Create or update the post.
523
-		if ( false !== $id && '0' !== $id ) {
523
+		if (false !== $id && '0' !== $id) {
524 524
 			$post['ID'] = $id;
525 525
 			$post['post_status'] = 'publish';
526
-			$id = wp_update_post( $post );
527
-			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
528
-			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data['last_modified'] ), $prev_date );
526
+			$id = wp_update_post($post);
527
+			$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
528
+			update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date);
529 529
 
530
-		} else {
530
+		}else {
531 531
 			// Set the name.
532
-			if ( isset( $data['name'] ) ) {
533
-				$post_name = wp_unique_post_slug( sanitize_title( $data['name'] ), $id, 'draft', 'tour', 0 );
532
+			if (isset($data['name'])) {
533
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
534 534
 			}
535 535
 
536
-			if ( ! isset( $post['post_content'] ) ) {
536
+			if (!isset($post['post_content'])) {
537 537
 				$post['post_content'] = ' ';
538 538
 			}
539 539
 
540 540
 			$post['post_name']   = $post_name;
541 541
 			$post['post_title']  = $data['name'];
542 542
 			$post['post_status'] = 'publish';
543
-			$id = wp_insert_post( $post );
543
+			$id = wp_insert_post($post);
544 544
 
545 545
 			// Save the WETU ID and the Last date it was modified.
546
-			if ( false !== $id ) {
547
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
548
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data['last_modified'] ) );
546
+			if (false !== $id) {
547
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
548
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
549 549
 			}
550 550
 		}
551 551
 
552 552
 		// Set the price.
553
-		if ( false !== $importable_content && in_array( 'price', $importable_content ) ) {
554
-			$this->set_price( $data, $id );
553
+		if (false !== $importable_content && in_array('price', $importable_content)) {
554
+			$this->set_price($data, $id);
555 555
 		}
556 556
 
557 557
 		// Set the Duration.
558
-		if ( false !== $importable_content && in_array( 'duration', $importable_content ) ) {
559
-			$this->set_duration( $data, $id );
558
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
559
+			$this->set_duration($data, $id);
560 560
 		}
561 561
 
562 562
 		// Set the Group Size.
563
-		if ( false !== $importable_content && in_array( 'group_size', $importable_content ) ) {
564
-			$this->set_group_size( $data, $id );
563
+		if (false !== $importable_content && in_array('group_size', $importable_content)) {
564
+			$this->set_group_size($data, $id);
565 565
 		}
566 566
 
567 567
 		// Set the Group Size.
568
-		if ( false !== $importable_content && in_array( 'tags', $importable_content ) ) {
569
-			$this->set_travel_styles( $id, $data );
568
+		if (false !== $importable_content && in_array('tags', $importable_content)) {
569
+			$this->set_travel_styles($id, $data);
570 570
 		}
571 571
 
572
-		if ( false !== $importable_content && in_array( 'itineraries', $importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) {
573
-			$this->process_itineraries( $data, $id, $importable_content );
572
+		if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
573
+			$this->process_itineraries($data, $id, $importable_content);
574 574
 		}
575 575
 
576
-		if ( in_array( 'map', $importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) {
577
-			$this->set_map_data( $data, $id );
576
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
577
+			$this->set_map_data($data, $id);
578 578
 		}
579 579
 
580 580
 		return $id;
@@ -583,195 +583,195 @@  discard block
 block discarded – undo
583 583
 	/**
584 584
 	 * A loop which runs through each leg on the tour.
585 585
 	 */
586
-	public function process_itineraries( $data, $id, $importable_content ) {
586
+	public function process_itineraries($data, $id, $importable_content) {
587 587
 		$day_counter = 1;
588 588
 		$leg_counter = 0;
589 589
 
590
-		delete_post_meta( $id, 'itinerary' );
590
+		delete_post_meta($id, 'itinerary');
591 591
 
592
-		if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
593
-			delete_post_meta( $id, 'accommodation_to_tour' );
592
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
593
+			delete_post_meta($id, 'accommodation_to_tour');
594 594
 		}
595
-		if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
596
-			delete_post_meta( $id, 'departs_from' );
597
-			delete_post_meta( $id, 'ends_in' );
595
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
596
+			delete_post_meta($id, 'departs_from');
597
+			delete_post_meta($id, 'ends_in');
598 598
 		}
599 599
 
600 600
 		$departs_from = false;
601 601
 		$ends_in = false;
602 602
 
603
-		foreach ( $data['legs'] as $leg ) {
603
+		foreach ($data['legs'] as $leg) {
604 604
 			// Itinerary Accommodation.
605 605
 			$current_accommodation = false;
606
-			if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
607
-				$current_accommodation = $this->set_accommodation( $leg, $id );
606
+			if (false !== $importable_content && in_array('accommodation', $importable_content)) {
607
+				$current_accommodation = $this->set_accommodation($leg, $id);
608 608
 			}
609 609
 
610 610
 			// Itinerary Destination.
611 611
 			$current_destination = false;
612
-			if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
613
-				$current_destination = $this->set_destination( $leg, $id, $leg_counter );
612
+			if (false !== $importable_content && in_array('destination', $importable_content)) {
613
+				$current_destination = $this->set_destination($leg, $id, $leg_counter);
614 614
 			}
615 615
 
616 616
 			// If the Nights are the same mount of days in the array,  then it isnt "By Destination".
617
-			if ( ( (1 <= (int) $leg['nights'] && isset( $leg['periods'] ) ) ) || 0 === $leg['itinerary_leg_id'] ) {
618
-				foreach ( $leg['periods'] as $day ) {
617
+			if (((1 <= (int) $leg['nights'] && isset($leg['periods']))) || 0 === $leg['itinerary_leg_id']) {
618
+				foreach ($leg['periods'] as $day) {
619 619
 					$current_day = array();
620
-					$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter;
620
+					$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter;
621 621
 
622 622
 					//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
623 623
 
624 624
 					// Description.
625
-					if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $day['notes'] ) ) {
625
+					if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
626 626
 						$current_day['description'] = $day['notes'];
627
-					} else {
627
+					}else {
628 628
 						$current_day['description'] = '';
629 629
 					}
630 630
 
631 631
 					// Itinerary Gallery.
632
-					if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $day['images'] ) ) {
632
+					if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
633 633
 						$current_day['featured_image'] = '';
634
-					} else {
634
+					}else {
635 635
 						$current_day['featured_image'] = '';
636 636
 					}
637 637
 
638 638
 					// Accommodation.
639
-					if ( false !== $current_accommodation ) {
640
-						$current_day['accommodation_to_tour'] = array( $current_accommodation );
641
-					} else {
639
+					if (false !== $current_accommodation) {
640
+						$current_day['accommodation_to_tour'] = array($current_accommodation);
641
+					}else {
642 642
 						$current_day['accommodation_to_tour'] = array();
643 643
 					}
644 644
 
645 645
 					// Destination.
646
-					if ( false !== $current_destination ) {
647
-						$current_day['destination_to_tour'] = array( $current_destination );
648
-					} else {
646
+					if (false !== $current_destination) {
647
+						$current_day['destination_to_tour'] = array($current_destination);
648
+					}else {
649 649
 						$current_day['destination_to_tour'] = array();
650 650
 					}
651 651
 
652 652
 					// Included.
653
-					if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) {
653
+					if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
654 654
 						$current_day['included'] = $day['included'];
655
-					} else {
655
+					}else {
656 656
 						$current_day['included'] = '';
657 657
 					}
658 658
 
659 659
 					// Excluded.
660
-					if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) {
660
+					if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
661 661
 						$current_day['excluded'] = $day['excluded'];
662
-					} else {
662
+					}else {
663 663
 						$current_day['excluded'] = '';
664 664
 					}
665 665
 
666
-					$this->set_itinerary_day( $current_day,$id );
666
+					$this->set_itinerary_day($current_day, $id);
667 667
 					$day_counter++;
668 668
 				}
669
-			} else {
669
+			}else {
670 670
 				// This is for the by destination.
671 671
 
672 672
 				$current_day = array();
673 673
 				$next_day_count = $day_counter + (int) $leg['nights'];
674 674
 				$day_count_label = $next_day_count - 1;
675 675
 
676
-				$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter;
676
+				$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter;
677 677
 
678
-				if ( 0 !== (int) $leg['nights'] ) {
679
-					$current_day['title'] .= ' - ' . $day_count_label;
678
+				if (0 !== (int) $leg['nights']) {
679
+					$current_day['title'] .= ' - '.$day_count_label;
680 680
 				}
681 681
 
682 682
 				// Description.
683
-				if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $leg['notes'] ) ) {
683
+				if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) {
684 684
 					$current_day['description'] = $leg['notes'];
685
-				} else {
685
+				}else {
686 686
 					$current_day['description'] = '';
687 687
 				}
688 688
 
689 689
 				// Itinerary Gallery.
690
-				if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $leg['images'] ) ) {
690
+				if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) {
691 691
 					$current_day['featured_image'] = '';
692
-				} else {
692
+				}else {
693 693
 					$current_day['featured_image'] = '';
694 694
 				}
695 695
 
696 696
 				// Accommodation.
697
-				if ( false !== $current_accommodation ) {
698
-					$current_day['accommodation_to_tour'] = array( $current_accommodation );
699
-				} else {
697
+				if (false !== $current_accommodation) {
698
+					$current_day['accommodation_to_tour'] = array($current_accommodation);
699
+				}else {
700 700
 					$current_day['accommodation_to_tour'] = array();
701 701
 				}
702 702
 
703 703
 				// Destination.
704
-				if ( false !== $current_destination ) {
705
-					$current_day['destination_to_tour'] = array( $current_destination );
706
-				} else {
704
+				if (false !== $current_destination) {
705
+					$current_day['destination_to_tour'] = array($current_destination);
706
+				}else {
707 707
 					$current_day['destination_to_tour'] = array();
708 708
 				}
709 709
 
710 710
 				//Included
711
-				if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) {
711
+				if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) {
712 712
 					$current_day['included'] = $leg['included'];
713
-				} else {
713
+				}else {
714 714
 					$current_day['included'] = '';
715 715
 				}
716 716
 
717 717
 				//Excluded
718
-				if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) {
718
+				if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) {
719 719
 					$current_day['excluded'] = $leg['excluded'];
720
-				} else {
720
+				}else {
721 721
 					$current_day['excluded'] = '';
722 722
 				}
723 723
 
724
-				$this->set_itinerary_day( $current_day,$id );
724
+				$this->set_itinerary_day($current_day, $id);
725 725
 				$day_counter = $next_day_count;
726 726
 			}
727 727
 
728 728
 			// If we are in the first leg,  and the destination was attached then save it as the departure field.
729
-			if ( 0 === $leg_counter && false !== $current_destination ) {
729
+			if (0 === $leg_counter && false !== $current_destination) {
730 730
 				$departs_from = $current_destination;
731 731
 			}
732 732
 
733 733
 			// If its the last leg then save it as the ends in.
734
-			if ( $leg_counter === (count( $data['legs'] ) -2) && false !== $current_destination ) {
734
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
735 735
 				$ends_in = $current_destination;
736 736
 			}
737 737
 
738 738
 			$leg_counter++;
739 739
 		}
740 740
 
741
-		if ( false !== $departs_from ) {
742
-			add_post_meta( $id, 'departs_from', $departs_from, true );
741
+		if (false !== $departs_from) {
742
+			add_post_meta($id, 'departs_from', $departs_from, true);
743 743
 		}
744
-		if ( false !== $ends_in ) {
745
-			add_post_meta( $id, 'ends_in', $ends_in, true );
744
+		if (false !== $ends_in) {
745
+			add_post_meta($id, 'ends_in', $ends_in, true);
746 746
 		}
747 747
 	}
748 748
 
749 749
 	/**
750 750
 	 * Run through your routes and save the points as a KML file.
751 751
 	 */
752
-	public function set_map_data( $data, $id, $zoom = 9 ) {
753
-		if ( ! empty( $data['routes'] ) ) {
754
-			delete_post_meta( $id,'wetu_map_points' );
752
+	public function set_map_data($data, $id, $zoom = 9) {
753
+		if (!empty($data['routes'])) {
754
+			delete_post_meta($id, 'wetu_map_points');
755 755
 
756 756
 			$points = array();
757 757
 
758
-			foreach ( $data['routes'] as $route ) {
758
+			foreach ($data['routes'] as $route) {
759 759
 
760
-				if ( isset( $route['points'] ) && '' !== $route['points'] ) {
760
+				if (isset($route['points']) && '' !== $route['points']) {
761 761
 
762
-					$temp_points = explode( ';',$route['points'] );
763
-					$point_counter = count( $temp_points );
762
+					$temp_points = explode(';', $route['points']);
763
+					$point_counter = count($temp_points);
764 764
 
765
-					for ( $x = 0; $x <= $point_counter; $x++ ) {
765
+					for ($x = 0; $x <= $point_counter; $x++) {
766 766
 						$y = $x + 1;
767
-						$points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ];
767
+						$points[] = $temp_points[$x].','.$temp_points[$y];
768 768
 						$x++;
769 769
 					}
770 770
 				}
771 771
 			}
772 772
 
773
-			if ( ! empty( $points ) ) {
774
-				$this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true );
773
+			if (!empty($points)) {
774
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
775 775
 			}
776 776
 		}
777 777
 
@@ -782,49 +782,49 @@  discard block
 block discarded – undo
782 782
 	/**
783 783
 	 * Set the Itinerary Day
784 784
 	 */
785
-	public function set_itinerary_day( $day, $id ) {
786
-		$this->save_custom_field( $day,'itinerary',$id,false,false );
785
+	public function set_itinerary_day($day, $id) {
786
+		$this->save_custom_field($day, 'itinerary', $id, false, false);
787 787
 	}
788 788
 
789 789
 	/**
790 790
 	 * Set the price
791 791
 	 */
792
-	public function set_price( $data, $id ) {
792
+	public function set_price($data, $id) {
793 793
 		//Price
794
-		if ( isset( $data['price'] ) && '' !== $data['price'] ) {
795
-			$price = preg_replace( '/[^0-9,.]/', '', $data['price'] );
796
-			$this->save_custom_field( $price,'price',$id );
794
+		if (isset($data['price']) && '' !== $data['price']) {
795
+			$price = preg_replace('/[^0-9,.]/', '', $data['price']);
796
+			$this->save_custom_field($price, 'price', $id);
797 797
 		}
798 798
 
799 799
 		//Price includes
800
-		if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) {
801
-			$this->save_custom_field( $data['price_includes'],'included',$id );
800
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
801
+			$this->save_custom_field($data['price_includes'], 'included', $id);
802 802
 		}
803 803
 
804 804
 		//Price Excludes
805
-		if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) {
806
-			$this->save_custom_field( $data['price_excludes'],'not_included',$id );
805
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
806
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
807 807
 		}
808 808
 	}
809 809
 
810 810
 	/**
811 811
 	 * Set the duration
812 812
 	 */
813
-	public function set_duration( $data, $id ) {
814
-		if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) {
813
+	public function set_duration($data, $id) {
814
+		if (isset($data['days']) && !empty($data['days'])) {
815 815
 			$price = $data['days'];
816
-			$price = preg_replace( '/[^0-9,.]/', '', $price );
817
-			$this->save_custom_field( $price,'duration',$id );
816
+			$price = preg_replace('/[^0-9,.]/', '', $price);
817
+			$this->save_custom_field($price, 'duration', $id);
818 818
 		}
819 819
 	}
820 820
 
821 821
 	/**
822 822
 	 * Set the group size
823 823
 	 */
824
-	public function set_group_size( $data, $id ) {
825
-		if ( isset( $data['group_size'] ) && ! empty( $data['group_size'] ) ) {
824
+	public function set_group_size($data, $id) {
825
+		if (isset($data['group_size']) && !empty($data['group_size'])) {
826 826
 			$group_size = $data['group_size'];
827
-			$this->save_custom_field( $group_size,'group_size',$id );
827
+			$this->save_custom_field($group_size, 'group_size', $id);
828 828
 		}
829 829
 	}
830 830
 
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
 	 * @param array $travel_styles
836 836
 	 * @return void
837 837
 	 */
838
-	public function set_travel_styles( $id, $data ) {
839
-		if ( isset( $data['tags'] ) ) {
840
-			foreach ( $data['tags'] as $tag ) {
841
-				$this->set_term( $id, $tag, 'travel-style' );
838
+	public function set_travel_styles($id, $data) {
839
+		if (isset($data['tags'])) {
840
+			foreach ($data['tags'] as $tag) {
841
+				$this->set_term($id, $tag, 'travel-style');
842 842
 			}
843 843
 		}
844 844
 	}
@@ -846,27 +846,27 @@  discard block
 block discarded – undo
846 846
 	/**
847 847
 	 * Connects the Accommodation if its available
848 848
 	 */
849
-	public function set_accommodation( $day, $id ) {
849
+	public function set_accommodation($day, $id) {
850 850
 		$ac_id = false;
851 851
 		$this->current_accommodation = $this->find_current_accommodation();
852 852
 
853
-		if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) {
854
-			if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) {
855
-				$ac_id = $this->current_accommodation[ $day['content_entity_id'] ];
856
-			} else {
853
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
854
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
855
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
856
+			}else {
857 857
 				$ac_id = wp_insert_post(array(
858 858
 					'post_type' => 'accommodation',
859 859
 					'post_status' => 'draft',
860 860
 					'post_title' => $day['content_entity_id'],
861 861
 				));
862 862
 
863
-				$this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id );
863
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
864 864
 			}
865 865
 
866
-			if ( '' !== $ac_id && false !== $ac_id ) {
867
-				$this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false );
868
-				$this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false );
869
-				$this->queue_item( $ac_id );
866
+			if ('' !== $ac_id && false !== $ac_id) {
867
+				$this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
868
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
869
+				$this->queue_item($ac_id);
870 870
 			}
871 871
 		}
872 872
 		return $ac_id;
@@ -878,14 +878,14 @@  discard block
 block discarded – undo
878 878
 	 * @param $post_type string
879 879
 	 * @return boolean / array
880 880
 	 */
881
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
881
+	public function find_current_accommodation($post_type = 'accommodation') {
882 882
 		global $wpdb;
883
-		$accommodation = parent::find_current_accommodation( $post_type );
883
+		$accommodation = parent::find_current_accommodation($post_type);
884 884
 		$return = false;
885 885
 
886
-		if ( ! empty( $accommodation ) ) {
887
-			foreach ( $accommodation as $key => $acc ) {
888
-				$return[ $acc->meta_value ] = $acc->post_id;
886
+		if (!empty($accommodation)) {
887
+			foreach ($accommodation as $key => $acc) {
888
+				$return[$acc->meta_value] = $acc->post_id;
889 889
 			}
890 890
 		}
891 891
 
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 	 * @return boolean / array
898 898
 	 */
899 899
 	public function find_current_destinations() {
900
-		return $this->find_current_accommodation( 'destination' );
900
+		return $this->find_current_accommodation('destination');
901 901
 	}
902 902
 
903 903
 	/**
@@ -907,44 +907,44 @@  discard block
 block discarded – undo
907 907
 	 * @param $id string
908 908
 	 * @return boolean / string
909 909
 	 */
910
-	public function set_destination( $day, $id, $leg_counter ) {
910
+	public function set_destination($day, $id, $leg_counter) {
911 911
 		$dest_id    = false;
912 912
 		$country_id = false;
913 913
 
914 914
 		$this->current_destinations = $this->find_current_destinations();
915 915
 
916
-		if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) {
917
-			if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'], $this->current_destinations ) ) {
918
-				$dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ];
916
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
917
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
918
+				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
919 919
 
920 920
 				//TODO Check for attachments here.
921
-				$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
921
+				$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
922 922
 
923 923
 				//Check if there is a country asigned.
924
-				$potential_id = wp_get_post_parent_id( $dest_id );
925
-				$country_wetu_id = get_post_meta( $potential_id, 'lsx_wetu_id', true );
924
+				$potential_id = wp_get_post_parent_id($dest_id);
925
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
926 926
 
927
-				if ( false !== $country_wetu_id ) {
928
-					$country_id = $this->set_country( $country_wetu_id, $id );
927
+				if (false !== $country_wetu_id) {
928
+					$country_id = $this->set_country($country_wetu_id, $id);
929 929
 				}
930
-			} else {
931
-				$destination_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] );
930
+			}else {
931
+				$destination_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']);
932 932
 
933
-				if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
933
+				if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
934 934
 
935
-					$destination_data = json_decode( $destination_json['body'], true );
935
+					$destination_data = json_decode($destination_json['body'], true);
936 936
 
937
-					if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) {
937
+					if (!empty($destination_data) && !isset($destination_data['error'])) {
938 938
 						$destination_title = $day['destination_content_entity_id'];
939 939
 
940
-						if ( isset( $destination_data[0]['name'] ) ) {
940
+						if (isset($destination_data[0]['name'])) {
941 941
 							$destination_title = $destination_data[0]['name'];
942 942
 						}
943 943
 
944
-						if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] )
945
-							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) {
944
+						if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
945
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
946 946
 
947
-							$country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id );
947
+							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
948 948
 							// Save the destination so we can grab the tour featured image and banner from them.
949 949
 						}
950 950
 
@@ -954,40 +954,40 @@  discard block
 block discarded – undo
954 954
 							'post_title' => $destination_title,
955 955
 						);
956 956
 
957
-						if ( false !== $country_id ) {
957
+						if (false !== $country_id) {
958 958
 							$dest_post['post_parent'] = $country_id;
959 959
 						}
960
-						$dest_id = wp_insert_post( $dest_post );
960
+						$dest_id = wp_insert_post($dest_post);
961 961
 
962 962
 						// Make sure we register the.
963
-						$this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id;
963
+						$this->current_destinations[$day['destination_content_entity_id']] = $dest_id;
964 964
 
965 965
 						// If there are images attached then use the destination.
966
-						if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) {
967
-							$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
966
+						if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) {
967
+							$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
968 968
 						}
969 969
 
970
-						$this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id );
970
+						$this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id);
971 971
 					}
972 972
 				}
973 973
 			}
974 974
 
975
-			if ( '' !== $dest_id && false !== $dest_id ) {
976
-				$this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false );
977
-				$this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false );
975
+			if ('' !== $dest_id && false !== $dest_id) {
976
+				$this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false);
977
+				$this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false);
978 978
 
979 979
 				//Save the item to display in the queue
980
-				$this->queue_item( $dest_id );
980
+				$this->queue_item($dest_id);
981 981
 
982 982
 				//Save the item to clean up the amount of connections.
983
-				$this->cleanup_posts[ $dest_id ] = 'tour_to_destination';
983
+				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
984 984
 
985 985
 				//Add this relation info so we can make sure certain items are set as countries.
986
-				if ( 0 !== $country_id && false !== $country_id ) {
987
-					$this->relation_meta[ $dest_id ] = $country_id;
988
-					$this->relation_meta[ $country_id ] = 0;
989
-				} else {
990
-					$this->relation_meta[ $dest_id ] = 0;
986
+				if (0 !== $country_id && false !== $country_id) {
987
+					$this->relation_meta[$dest_id] = $country_id;
988
+					$this->relation_meta[$country_id] = 0;
989
+				}else {
990
+					$this->relation_meta[$dest_id] = 0;
991 991
 				}
992 992
 			}
993 993
 		}
@@ -1003,25 +1003,25 @@  discard block
 block discarded – undo
1003 1003
 	 *
1004 1004
 	 * @return string
1005 1005
 	 */
1006
-	public function set_country( $country_wetu_id, $id ) {
1006
+	public function set_country($country_wetu_id, $id) {
1007 1007
 		$country_id = false;
1008 1008
 		$this->current_destinations = $this->find_current_destinations();
1009 1009
 
1010
-		if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) {
1011
-			$country_id = $this->current_destinations[ $country_wetu_id ];
1012
-			$this->destination_images[ $id ][] = array( $country_id, $country_wetu_id );
1013
-		} else {
1014
-			$country_json = file_get_contents( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id );
1010
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
1011
+			$country_id = $this->current_destinations[$country_wetu_id];
1012
+			$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1013
+		}else {
1014
+			$country_json = file_get_contents('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id);
1015 1015
 
1016
-			if ( $country_json ) {
1017
-				$country_data = json_decode( $country_json, true );
1016
+			if ($country_json) {
1017
+				$country_data = json_decode($country_json, true);
1018 1018
 
1019
-				if ( ! empty( $country_data ) && ! isset( $country_data['error'] ) ) {
1019
+				if (!empty($country_data) && !isset($country_data['error'])) {
1020 1020
 
1021 1021
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
1022 1022
 					$country_title = $country_wetu_id;
1023 1023
 
1024
-					if ( isset( $country_data[0]['name'] ) ) {
1024
+					if (isset($country_data[0]['name'])) {
1025 1025
 						$country_title = $country_data[0]['name'];
1026 1026
 					}
1027 1027
 
@@ -1032,24 +1032,24 @@  discard block
 block discarded – undo
1032 1032
 					));
1033 1033
 
1034 1034
 					//add the country to the current destination stack
1035
-					$this->current_destinations[ $country_wetu_id ] = $country_id;
1035
+					$this->current_destinations[$country_wetu_id] = $country_id;
1036 1036
 
1037 1037
 					// Check if there are images and save fore use later.
1038
-					if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) {
1039
-						$this->destination_images[ $id ][] = array( $country_id,$country_wetu_id );
1038
+					if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) {
1039
+						$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1040 1040
 					}
1041 1041
 
1042 1042
 					//Save the wetu field
1043
-					$this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id );
1043
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1044 1044
 				}
1045 1045
 			}
1046 1046
 		}
1047 1047
 
1048
-		if ( '' !== $country_id && false !== $country_id ) {
1049
-			$this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false );
1050
-			$this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false );
1051
-			$this->queue_item( $country_id );
1052
-			$this->cleanup_posts[ $country_id ] = 'tour_to_destination';
1048
+		if ('' !== $country_id && false !== $country_id) {
1049
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1050
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1051
+			$this->queue_item($country_id);
1052
+			$this->cleanup_posts[$country_id] = 'tour_to_destination';
1053 1053
 
1054 1054
 			return $country_id;
1055 1055
 		}
@@ -1064,44 +1064,44 @@  discard block
 block discarded – undo
1064 1064
 	 *
1065 1065
 	 * @return string
1066 1066
 	 */
1067
-	public function attach_destination_images( $importable_content = array() ) {
1068
-		if ( false !== $this->destination_images ) {
1069
-			$this->shuffle_assoc( $this->destination_images );
1067
+	public function attach_destination_images($importable_content = array()) {
1068
+		if (false !== $this->destination_images) {
1069
+			$this->shuffle_assoc($this->destination_images);
1070 1070
 
1071
-			foreach ( $this->destination_images as $tour => $destinations ) {
1071
+			foreach ($this->destination_images as $tour => $destinations) {
1072 1072
 				//$this->shuffle_assoc( $destinations );
1073 1073
 
1074 1074
 				$image_set = false;
1075 1075
 				$forced = false;
1076 1076
 
1077
-				foreach ( $destinations as $destination ) {
1078
-					if ( false === $image_set && false === $forced ) {
1079
-						$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1077
+				foreach ($destinations as $destination) {
1078
+					if (false === $image_set && false === $forced) {
1079
+						$url = 'https://wetu.com/API/Pins/'.$this->api_key;
1080 1080
 						$url_qs = '';
1081 1081
 
1082
-						$jdata = file_get_contents( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] );
1082
+						$jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]);
1083 1083
 
1084
-						if ( $jdata ) {
1085
-							$adata = json_decode( $jdata, true );
1084
+						if ($jdata) {
1085
+							$adata = json_decode($jdata, true);
1086 1086
 
1087
-							if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) {
1088
-								$this->find_attachments( $destination[0] );
1087
+							if (!empty($adata) && !empty($adata[0]['content']['images'])) {
1088
+								$this->find_attachments($destination[0]);
1089 1089
 
1090 1090
 								//Set the featured image
1091
-								if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
1092
-									$image_set = $this->set_featured_image( $adata, $tour );
1093
-									if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1094
-										$image_set = $this->set_banner_image( $adata, $tour );
1091
+								if (false !== $importable_content && in_array('featured_image', $importable_content)) {
1092
+									$image_set = $this->set_featured_image($adata, $tour);
1093
+									if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1094
+										$image_set = $this->set_banner_image($adata, $tour);
1095 1095
 										$forced = true;
1096 1096
 									}
1097 1097
 									continue;
1098 1098
 								}
1099
-								if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1100
-									$image_set = $this->set_banner_image( $adata, $tour );
1099
+								if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1100
+									$image_set = $this->set_banner_image($adata, $tour);
1101 1101
 								}
1102 1102
 							}
1103 1103
 						}
1104
-					} else {
1104
+					}else {
1105 1105
 						continue;
1106 1106
 					}
1107 1107
 				}
@@ -1112,28 +1112,28 @@  discard block
 block discarded – undo
1112 1112
 	/**
1113 1113
 	 * Creates the main gallery data
1114 1114
 	 */
1115
-	public function set_featured_image( $data, $id ) {
1115
+	public function set_featured_image($data, $id) {
1116 1116
 		$image_set = false;
1117 1117
 		$counter = 0;
1118 1118
 
1119
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1120
-			foreach ( $data[0]['content']['images'] as $v ) {
1119
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1120
+			foreach ($data[0]['content']['images'] as $v) {
1121 1121
 				/*print_r('<pre>');
1122 1122
 				print_r( $v );
1123 1123
 				print_r('</pre>');*/
1124 1124
 
1125
-				if ( true === $image_set ) {
1125
+				if (true === $image_set) {
1126 1126
 					$counter++;
1127 1127
 					continue;
1128 1128
 				}
1129 1129
 
1130
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1131
-					$temp_featured_image = $this->attach_image( $v , $id );
1130
+				if (!$this->check_if_image_is_used($v)) {
1131
+					$temp_featured_image = $this->attach_image($v, $id);
1132 1132
 
1133
-					if ( false !== $temp_featured_image ) {
1133
+					if (false !== $temp_featured_image) {
1134 1134
 						$this->featured_image = $temp_featured_image;
1135
-						delete_post_meta( $id, '_thumbnail_id' );
1136
-						add_post_meta( $id, '_thumbnail_id', $this->featured_image, true );
1135
+						delete_post_meta($id, '_thumbnail_id');
1136
+						add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
1137 1137
 						$image_set = true;
1138 1138
 					}
1139 1139
 				}
@@ -1147,40 +1147,40 @@  discard block
 block discarded – undo
1147 1147
 	/**
1148 1148
 	 * Sets a banner image
1149 1149
 	 */
1150
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
1150
+	public function set_banner_image($data, $id, $content = array('none')) {
1151 1151
 		$image_set = false;
1152 1152
 		$counter = 0;
1153 1153
 
1154
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1154
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1155 1155
 
1156
-			foreach ( $data[0]['content']['images'] as $v ) {
1156
+			foreach ($data[0]['content']['images'] as $v) {
1157 1157
 				/*print_r('<pre>');
1158 1158
 				print_r( $v );
1159 1159
 				print_r('</pre>');*/
1160 1160
 
1161
-				if ( true === $image_set || 0 === $counter ) {
1161
+				if (true === $image_set || 0 === $counter) {
1162 1162
 					$counter++;
1163 1163
 					continue;
1164 1164
 				}
1165 1165
 
1166
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1167
-					$temp_banner = $this->attach_image( $v, $id, array(
1166
+				if (!$this->check_if_image_is_used($v)) {
1167
+					$temp_banner = $this->attach_image($v, $id, array(
1168 1168
 						'width' => '1920',
1169 1169
 						'height' => '600',
1170 1170
 						'cropping' => 'c',
1171
-					) );
1171
+					));
1172 1172
 
1173
-					if ( false !== $temp_banner ) {
1173
+					if (false !== $temp_banner) {
1174 1174
 						$this->banner_image = $temp_banner;
1175 1175
 
1176
-						delete_post_meta( $id,'image_group' );
1176
+						delete_post_meta($id, 'image_group');
1177 1177
 
1178 1178
 						$new_banner = array(
1179 1179
 							'banner_image' => array(
1180 1180
 								'cmb-field-0' => $this->banner_image,
1181 1181
 							),
1182 1182
 						);
1183
-						add_post_meta( $id,'image_group',$new_banner,true );
1183
+						add_post_meta($id, 'image_group', $new_banner, true);
1184 1184
 						$image_set = true;
1185 1185
 					}
1186 1186
 				}
@@ -1194,18 +1194,18 @@  discard block
 block discarded – undo
1194 1194
 	/**
1195 1195
 	 * Grabs all of the current used featured images on the site.
1196 1196
 	 */
1197
-	public function check_if_image_is_used( $v ) {
1197
+	public function check_if_image_is_used($v) {
1198 1198
 		global $wpdb;
1199 1199
 
1200
-		$temp_fragment = explode( '/', $v['url_fragment'] );
1201
-		$url_filename = $temp_fragment[ count( $temp_fragment ) -1 ];
1202
-		$url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $url_filename );
1203
-		$url_filename = trim( $url_filename );
1204
-		$url_filename = str_replace( ' ', '_', $url_filename );
1200
+		$temp_fragment = explode('/', $v['url_fragment']);
1201
+		$url_filename = $temp_fragment[count($temp_fragment) - 1];
1202
+		$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1203
+		$url_filename = trim($url_filename);
1204
+		$url_filename = str_replace(' ', '_', $url_filename);
1205 1205
 
1206
-		if ( in_array( $url_filename, $this->found_attachments ) ) {
1206
+		if (in_array($url_filename, $this->found_attachments)) {
1207 1207
 			//check to see if there is a featured image set with this ID.
1208
-			$found_id = array_search( $url_filename, $this->found_attachments );
1208
+			$found_id = array_search($url_filename, $this->found_attachments);
1209 1209
 
1210 1210
 			$querystring = "
1211 1211
 				SELECT      post_id
@@ -1214,22 +1214,22 @@  discard block
 block discarded – undo
1214 1214
 				AND 		meta_key = '_thumbnail_id'
1215 1215
 			";
1216 1216
 			// @codingStandardsIgnoreLine
1217
-			$results = $wpdb->get_results( $querystring );
1217
+			$results = $wpdb->get_results($querystring);
1218 1218
 
1219
-			if ( ! empty( $results ) ) {
1219
+			if (!empty($results)) {
1220 1220
 				return true;
1221
-			} else {
1221
+			}else {
1222 1222
 				return false;
1223 1223
 			}
1224
-		} else {
1224
+		}else {
1225 1225
 			$querystring = "
1226 1226
 				SELECT      ID
1227 1227
 				FROM        {$wpdb->posts}
1228 1228
 				WHERE       post_name = '{$url_filename}'
1229 1229
 			";
1230 1230
 			// @codingStandardsIgnoreLine
1231
-			$results = $wpdb->get_results( $querystring );
1232
-			if ( ! empty( $results ) ) {
1231
+			$results = $wpdb->get_results($querystring);
1232
+			if (!empty($results)) {
1233 1233
 				$querystring = "
1234 1234
 					SELECT      post_id
1235 1235
 					FROM        {$wpdb->postmeta}
@@ -1237,13 +1237,13 @@  discard block
 block discarded – undo
1237 1237
 					AND 		meta_key = '_thumbnail_id'
1238 1238
 				";
1239 1239
 				// @codingStandardsIgnoreLine
1240
-				$results = $wpdb->get_results( $querystring );
1241
-				if ( ! empty( $results ) ) {
1240
+				$results = $wpdb->get_results($querystring);
1241
+				if (!empty($results)) {
1242 1242
 					return true;
1243
-				} else {
1243
+				}else {
1244 1244
 					return false;
1245 1245
 				}
1246
-			} else {
1246
+			}else {
1247 1247
 				return false;
1248 1248
 			}
1249 1249
 		}
@@ -1254,10 +1254,10 @@  discard block
 block discarded – undo
1254 1254
 	 *
1255 1255
 	 * @param   $id     int
1256 1256
 	 */
1257
-	public function queue_item( $id ) {
1258
-		if ( is_array( $this->import_queue ) && ! in_array( $id,$this->import_queue ) ) {
1257
+	public function queue_item($id) {
1258
+		if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) {
1259 1259
 			$this->import_queue[] = $id;
1260
-		} else {
1260
+		}else {
1261 1261
 			$this->import_queue[] = $id;
1262 1262
 		}
1263 1263
 	}
@@ -1266,18 +1266,18 @@  discard block
 block discarded – undo
1266 1266
 	 * Saves the queue to the option.
1267 1267
 	 */
1268 1268
 	public function save_queue() {
1269
-		if ( ! empty( $this->import_queue ) ) {
1270
-			if ( ! empty( $this->queued_imports ) ) {
1271
-				$saved_imports = array_merge( $this->queued_imports,$this->import_queue );
1272
-			} else {
1269
+		if (!empty($this->import_queue)) {
1270
+			if (!empty($this->queued_imports)) {
1271
+				$saved_imports = array_merge($this->queued_imports, $this->import_queue);
1272
+			}else {
1273 1273
 				$saved_imports = $this->import_queue;
1274 1274
 			}
1275 1275
 
1276
-			delete_option( 'lsx_wetu_importer_que' );
1276
+			delete_option('lsx_wetu_importer_que');
1277 1277
 
1278
-			if ( ! empty( $saved_imports ) ) {
1279
-				$saved_imports = array_unique( $saved_imports );
1280
-				update_option( 'lsx_wetu_importer_que',$saved_imports );
1278
+			if (!empty($saved_imports)) {
1279
+				$saved_imports = array_unique($saved_imports);
1280
+				update_option('lsx_wetu_importer_que', $saved_imports);
1281 1281
 			}
1282 1282
 		}
1283 1283
 	}
@@ -1290,13 +1290,13 @@  discard block
 block discarded – undo
1290 1290
 		<thead>
1291 1291
 		<tr>
1292 1292
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
1293
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1293
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1294 1294
 				<input type="checkbox" id="cb-select-all-1">
1295 1295
 			</th>
1296
-			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1297
-			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>
1298
-			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1299
-			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1296
+			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1297
+			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>
1298
+			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1299
+			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1300 1300
 		</tr>
1301 1301
 		</thead>
1302 1302
 		<?php
@@ -1310,13 +1310,13 @@  discard block
 block discarded – undo
1310 1310
 		<tfoot>
1311 1311
 		<tr>
1312 1312
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
1313
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1313
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1314 1314
 				<input type="checkbox" id="cb-select-all-1">
1315 1315
 			</th>
1316
-			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1317
-			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>			
1318
-			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1319
-			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1316
+			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1317
+			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>			
1318
+			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1319
+			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1320 1320
 		</tr>
1321 1321
 		</tfoot>
1322 1322
 		<?php
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer.php 2 patches
Doc Comments   +9 added lines, -1 removed lines patch added patch discarded remove patch
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	 * @param boolean $name
799 799
 	 * @param boolean $taxonomy
800 800
 	 * @param boolean $parent
801
-	 * @return void
801
+	 * @return boolean
802 802
 	 */
803 803
 	public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) {
804 804
 		$term = term_exists( $name, $taxonomy );
@@ -1103,6 +1103,10 @@  discard block
 block discarded – undo
1103 1103
 		return 	false;
1104 1104
 	}
1105 1105
 
1106
+	/**
1107
+	 * @param string $url
1108
+	 * @param string $thumb
1109
+	 */
1106 1110
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1107 1111
 		if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); }
1108 1112
 
@@ -1210,6 +1214,7 @@  discard block
 block discarded – undo
1210 1214
 
1211 1215
 	/**
1212 1216
 	 * Does a multine search
1217
+	 * @param string $haystack
1213 1218
 	 */
1214 1219
 	public function multineedle_stripos( $haystack, $needles, $offset = 0 ) {
1215 1220
 		$found = false;
@@ -1293,6 +1298,9 @@  discard block
 block discarded – undo
1293 1298
 		}
1294 1299
 	}
1295 1300
 
1301
+	/**
1302
+	 * @param string $array
1303
+	 */
1296 1304
 	public function shuffle_assoc( &$array ) {
1297 1305
 		$new = array();
1298 1306
 		$keys = array_keys( $array );
Please login to merge, or discard this patch.
Spacing   +342 added lines, -342 removed lines patch added patch discarded remove patch
@@ -197,34 +197,34 @@  discard block
 block discarded – undo
197 197
 	 * @access private
198 198
 	 */
199 199
 	public function __construct() {
200
-		add_action( 'admin_init', array( $this, 'compatible_version_check' ) );
201
-		require_once LSX_WETU_IMPORTER_PATH . 'includes/helpers.php';
200
+		add_action('admin_init', array($this, 'compatible_version_check'));
201
+		require_once LSX_WETU_IMPORTER_PATH.'includes/helpers.php';
202 202
 
203 203
 		// Don't run anything else in the plugin, if we're on an incompatible PHP version.
204
-		if ( ! self::compatible_version() ) {
204
+		if (!self::compatible_version()) {
205 205
 			return;
206 206
 		}
207 207
 
208 208
 		$this->set_variables();
209 209
 
210
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
211
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 11 );
212
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ), 20 );
210
+		add_action('init', array($this, 'load_plugin_textdomain'));
211
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
212
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
213 213
 
214
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-welcome.php';
215
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-accommodation.php';
216
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-destination.php';
217
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-tours.php';
218
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-settings.php';
214
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-welcome.php';
215
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-accommodation.php';
216
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-destination.php';
217
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-tours.php';
218
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-settings.php';
219 219
 
220
-		add_action( 'init', array( $this, 'load_class' ) );
220
+		add_action('init', array($this, 'load_class'));
221 221
 
222
-		if ( 'default' !== $this->tab_slug ) {
223
-			add_action( 'wp_ajax_lsx_tour_importer', array( $this, 'process_ajax_search' ) );
224
-			add_action( 'wp_ajax_nopriv_lsx_tour_importer', array( $this, 'process_ajax_search' ) );
222
+		if ('default' !== $this->tab_slug) {
223
+			add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));
224
+			add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));
225 225
 
226
-			add_action( 'wp_ajax_lsx_import_items', array( $this, 'process_ajax_import' ) );
227
-			add_action( 'wp_ajax_nopriv_lsx_import_items', array( $this, 'process_ajax_import' ) );
226
+			add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));
227
+			add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
228 228
 		}
229 229
 	}
230 230
 
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
 	 * @since 1.0.0
237 237
 	 */
238 238
 	public function load_plugin_textdomain() {
239
-		load_plugin_textdomain( 'lsx-wetu-importer', false, basename( LSX_WETU_IMPORTER_PATH ) . '/languages' );
239
+		load_plugin_textdomain('lsx-wetu-importer', false, basename(LSX_WETU_IMPORTER_PATH).'/languages');
240 240
 	}
241 241
 
242 242
 	/**
243 243
 	 * Sets the variables used throughout the plugin.
244 244
 	 */
245 245
 	public function set_variables() {
246
-		$this->post_types = array( 'accommodation', 'destination', 'tour' );
246
+		$this->post_types = array('accommodation', 'destination', 'tour');
247 247
 		$options = \lsx_wetu_importer\includes\helpers\get_options();
248 248
 
249 249
 		// Set the options.
250
-		if ( ! empty( $options ) ) {
250
+		if (!empty($options)) {
251 251
 			$this->options = $options;
252 252
 
253
-			$temp_options = get_option( '_lsx-to_settings', false );
254
-			if ( false !== $temp_options ) {
253
+			$temp_options = get_option('_lsx-to_settings', false);
254
+			if (false !== $temp_options) {
255 255
 				$this->accommodation_settings = $temp_options['accommodation'];
256 256
 				$this->tour_settings          = $temp_options['tour'];
257 257
 				$this->destination_settings   = $temp_options['destination'];
@@ -259,49 +259,49 @@  discard block
 block discarded – undo
259 259
 
260 260
 			$this->api_key = false;
261 261
 
262
-			if ( ! defined( 'WETU_API_KEY' ) ) {
263
-				if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
262
+			if (!defined('WETU_API_KEY')) {
263
+				if (isset($options['api_key']) && '' !== $options['api_key']) {
264 264
 					$this->api_key = $options['api_key'];
265 265
 				}
266
-			} else {
266
+			}else {
267 267
 				$this->api_key = WETU_API_KEY;
268 268
 			}
269 269
 
270 270
 			// Set the tab slug.
271
-			if ( isset( $_GET['tab'] ) || ( defined( 'DOING_AJAX' ) && check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ) && isset( $_POST['type'] ) ) ) {
272
-				if ( isset( $_GET['tab'] ) ) {
273
-					$this->tab_slug = wp_unslash( $_GET['tab'] );
274
-				} else {
275
-					$this->tab_slug = wp_unslash( $_POST['type'] );
271
+			if (isset($_GET['tab']) || (defined('DOING_AJAX') && check_ajax_referer('lsx_wetu_ajax_action', 'security') && isset($_POST['type']))) {
272
+				if (isset($_GET['tab'])) {
273
+					$this->tab_slug = wp_unslash($_GET['tab']);
274
+				}else {
275
+					$this->tab_slug = wp_unslash($_POST['type']);
276 276
 				}
277 277
 
278 278
 				// If any tours were queued.
279
-				$this->queued_imports = get_option( 'lsx_wetu_importer_que', array() );
279
+				$this->queued_imports = get_option('lsx_wetu_importer_que', array());
280 280
 			}
281 281
 
282 282
 			// Set the scaling options.
283
-			if ( isset( $this->options ) && isset( $this->options['image_scaling'] ) ) {
283
+			if (isset($this->options) && isset($this->options['image_scaling'])) {
284 284
 				$this->scale_images = true;
285 285
 
286 286
 				$width = '1024';
287
-				if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) {
287
+				if (isset($this->options['width']) && '' !== $this->options['width']) {
288 288
 					$width = $this->options['width'];
289 289
 				}
290 290
 
291 291
 				$height = '768';
292
-				if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) {
292
+				if (isset($this->options['height']) && '' !== $this->options['height']) {
293 293
 					$height = $this->options['height'];
294 294
 				}
295 295
 
296 296
 				$cropping = 'w';
297
-				if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) {
297
+				if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
298 298
 					$cropping = $this->options['cropping'];
299 299
 				}
300 300
 
301
-				$this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
301
+				$this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
302 302
 			}
303 303
 
304
-			if ( isset( $this->options ) && isset( $this->options['image_limit'] ) && '' !== $this->options['image_limit'] ) {
304
+			if (isset($this->options) && isset($this->options['image_limit']) && '' !== $this->options['image_limit']) {
305 305
 				$this->image_limit = $this->options['image_limit'];
306 306
 			}
307 307
 		}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @since 1.0.0
325 325
 	 */
326 326
 	public static function compatible_version() {
327
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
327
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
328 328
 			return false;
329 329
 		}
330 330
 
@@ -338,13 +338,13 @@  discard block
 block discarded – undo
338 338
 	 * @since 1.0.0
339 339
 	 */
340 340
 	public function compatible_version_check() {
341
-		if ( ! self::compatible_version() ) {
342
-			if ( is_plugin_active( plugin_basename( LSX_WETU_IMPORTER_CORE ) ) ) {
343
-				deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) );
344
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
341
+		if (!self::compatible_version()) {
342
+			if (is_plugin_active(plugin_basename(LSX_WETU_IMPORTER_CORE))) {
343
+				deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE));
344
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
345 345
 
346
-				if ( isset( $_GET['activate'] ) ) {
347
-					unset( $_GET['activate'] );
346
+				if (isset($_GET['activate'])) {
347
+					unset($_GET['activate']);
348 348
 				}
349 349
 			}
350 350
 		}
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
 	 */
358 358
 	public function compatible_version_notice() {
359 359
 		$class = 'notice notice-error';
360
-		$message = esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' );
361
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
360
+		$message = esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer');
361
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
362 362
 	}
363 363
 
364 364
 	/**
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
 	 * @since 1.0.0
369 369
 	 */
370 370
 	public static function compatible_version_check_on_activation() {
371
-		if ( ! self::compatible_version() ) {
372
-			deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) );
373
-			wp_die( esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' ) );
371
+		if (!self::compatible_version()) {
372
+			deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE));
373
+			wp_die(esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer'));
374 374
 		}
375 375
 	}
376 376
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 * Load the importer class you want to use
381 381
 	 */
382 382
 	public function load_class() {
383
-		switch ( $this->tab_slug ) {
383
+		switch ($this->tab_slug) {
384 384
 			case 'accommodation':
385 385
 				$this->current_importer = new LSX_WETU_Importer_Accommodation();
386 386
 				break;
@@ -407,32 +407,32 @@  discard block
 block discarded – undo
407 407
 	 * Registers the admin page which will house the importer form.
408 408
 	 */
409 409
 	public function register_importer_page() {
410
-		add_submenu_page( 'tour-operator', esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'lsx-wetu-importer', array( $this, 'display_page' ) );
410
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'lsx-wetu-importer', array($this, 'display_page'));
411 411
 	}
412 412
 
413 413
 	/**
414 414
 	 * Enqueue the JS needed to contact wetu and return your result.
415 415
 	 */
416 416
 	public function admin_scripts() {
417
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
417
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
418 418
 			$min = '';
419
-		} else {
419
+		}else {
420 420
 			$min = '.min';
421 421
 		}
422 422
 
423 423
 		$min = '';
424 424
 
425
-		if ( is_admin() && isset( $_GET['page'] ) && $this->plugin_slug === $_GET['page'] ) {
425
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
426 426
 
427
-			wp_enqueue_style( 'lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL . 'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true );
428
-			wp_enqueue_script( 'lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL . 'assets/js/lsx-wetu-importer' . $min . '.js', array( 'jquery' ), LSX_WETU_IMPORTER_VER, true );
427
+			wp_enqueue_style('lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL.'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true);
428
+			wp_enqueue_script('lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL.'assets/js/lsx-wetu-importer'.$min.'.js', array('jquery'), LSX_WETU_IMPORTER_VER, true);
429 429
 
430 430
 			wp_localize_script(
431 431
 				'lsx-wetu-importers-script',
432 432
 				'lsx_tour_importer_params',
433 433
 				array(
434
-					'ajax_url' => admin_url( 'admin-ajax.php' ),
435
-					'ajax_nonce' => wp_create_nonce( 'lsx_wetu_ajax_action' ),
434
+					'ajax_url' => admin_url('admin-ajax.php'),
435
+					'ajax_nonce' => wp_create_nonce('lsx_wetu_ajax_action'),
436 436
 				)
437 437
 			);
438 438
 		}
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 		?>
446 446
 		<div class="wrap">
447 447
 			<?php
448
-			$this->navigation( $this->tab_slug );
449
-			if ( 'default' !== $this->tab_slug && 'settings' !== $this->tab_slug ) {
448
+			$this->navigation($this->tab_slug);
449
+			if ('default' !== $this->tab_slug && 'settings' !== $this->tab_slug) {
450 450
 				$this->wetu_status();
451 451
 				$this->post_status_navigation();
452 452
 			}
@@ -464,15 +464,15 @@  discard block
 block discarded – undo
464 464
 	public function post_status_navigation() {
465 465
 		?>
466 466
 		<ul class="subsubsub">
467
-			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?></a> | </li>
468
-			<li class="publish"><a href="#publish"><?php esc_attr_e( 'Published', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'publish ' ) ); ?>)</span></a> | </li>
469
-			<li class="pending"><a href="#pending"><?php esc_attr_e( 'Pending', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'pending ' ) ); ?>)</span></a>| </li> 
470
-			<li class="draft"><a href="#draft"><?php esc_attr_e( 'Draft', 'lsx-wetu-importer' ); ?></a> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'draft ' ) ); ?>)</span></li>
471
-
472
-			<?php if ( 'tour' === $this->tab_slug ) { ?>
473
-				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e( 'WETU', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_wetu_tour_count() ); ?>)</span></a></li>
474
-			<?php } else if ( ! empty( $this->queued_imports ) ) { ?>
475
-				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e( 'WETU Queue', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_wetu_queue_count( $this->tab_slug ) ); ?>)</span></a></li>
467
+			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e('Search', 'lsx-wetu-importer'); ?></a> | </li>
468
+			<li class="publish"><a href="#publish"><?php esc_attr_e('Published', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'publish ')); ?>)</span></a> | </li>
469
+			<li class="pending"><a href="#pending"><?php esc_attr_e('Pending', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'pending ')); ?>)</span></a>| </li> 
470
+			<li class="draft"><a href="#draft"><?php esc_attr_e('Draft', 'lsx-wetu-importer'); ?></a> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'draft ')); ?>)</span></li>
471
+
472
+			<?php if ('tour' === $this->tab_slug) { ?>
473
+				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_wetu_tour_count()); ?>)</span></a></li>
474
+			<?php }else if (!empty($this->queued_imports)) { ?>
475
+				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_wetu_queue_count($this->tab_slug)); ?>)</span></a></li>
476 476
 			<?php } ?>
477 477
 		</ul>
478 478
 		<?php
@@ -483,29 +483,29 @@  discard block
 block discarded – undo
483 483
 	 */
484 484
 	public function search_form() {
485 485
 		?>
486
-		<form class="ajax-form" id="<?php echo esc_attr( $this->plugin_slug ); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr( $this->tab_slug ); ?>">
487
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
486
+		<form class="ajax-form" id="<?php echo esc_attr($this->plugin_slug); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr($this->tab_slug); ?>">
487
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->tab_slug); ?>" />
488 488
 
489
-			<?php do_action( 'lsx_wetu_importer_search_form',$this ); ?>
489
+			<?php do_action('lsx_wetu_importer_search_form', $this); ?>
490 490
 
491 491
 			<div class="normal-search">
492
-				<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e( 'Search', 'lsx-wetu-importer' ); ?>" />
492
+				<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e('Search', 'lsx-wetu-importer'); ?>" />
493 493
 			</div>
494 494
 
495 495
 			<div class="advanced-search hidden" style="display:none;">
496 496
 				<textarea rows="10" cols="40" name="bulk-keywords"></textarea>
497
-				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?>" />
497
+				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e('Search', 'lsx-wetu-importer'); ?>" />
498 498
 			</div>
499 499
 
500 500
 			<div class="ajax-loader" style="display:none;width:100%;text-align:center;">
501
-				<img style="width:64px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
501
+				<img style="width:64px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
502 502
 			</div>
503 503
 
504 504
 			<div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
505
-				<img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
505
+				<img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
506 506
 			</div>
507 507
 
508
-			<a class="button advanced-search-toggle" href="#"><?php esc_html_e( 'Bulk Search', 'lsx-wetu-importer' ); ?></a>
508
+			<a class="button advanced-search-toggle" href="#"><?php esc_html_e('Bulk Search', 'lsx-wetu-importer'); ?></a>
509 509
 		</form>
510 510
 		<?php
511 511
 	}
@@ -553,43 +553,43 @@  discard block
 block discarded – undo
553 553
 	 *
554 554
 	 * @param $tab string
555 555
 	 */
556
-	public function navigation( $tab = '' ) {
556
+	public function navigation($tab = '') {
557 557
 		$post_types = array(
558
-			'tour'          => esc_attr( 'Tours', 'lsx-wetu-importer' ),
559
-			'accommodation' => esc_attr( 'Accommodation', 'lsx-wetu-importer' ),
560
-			'destination'   => esc_attr( 'Destinations', 'lsx-wetu-importer' ),
558
+			'tour'          => esc_attr('Tours', 'lsx-wetu-importer'),
559
+			'accommodation' => esc_attr('Accommodation', 'lsx-wetu-importer'),
560
+			'destination'   => esc_attr('Destinations', 'lsx-wetu-importer'),
561 561
 		);
562 562
 
563
-		echo wp_kses_post( '<div class="wp-filter">' );
564
-		echo wp_kses_post( '<ul class="filter-links">' );
565
-		echo wp_kses_post( '<li><a class="' . $this->itemd( $tab, 'default', 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '">' . esc_attr__( 'Home', 'lsx-wetu-importer' ) . '</a></li>' );
563
+		echo wp_kses_post('<div class="wp-filter">');
564
+		echo wp_kses_post('<ul class="filter-links">');
565
+		echo wp_kses_post('<li><a class="'.$this->itemd($tab, 'default', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr__('Home', 'lsx-wetu-importer').'</a></li>');
566 566
 
567
-		foreach ( $post_types as $post_type => $label ) {
568
-			echo wp_kses_post( ' | <li><a class="' . $this->itemd( $tab, $post_type, 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '&tab=' . $post_type . '">' . $label . '</a></li>' );
567
+		foreach ($post_types as $post_type => $label) {
568
+			echo wp_kses_post(' | <li><a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a></li>');
569 569
 		}
570 570
 
571
-		echo wp_kses_post( ' | <li><a class="' . $this->itemd( $tab, 'settings', 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '&tab=settings">' . esc_attr__( 'Settings', 'lsx-wetu-importer' ) . '</a></li>' );
572
-		echo wp_kses_post( '</ul> </div>' );
571
+		echo wp_kses_post(' | <li><a class="'.$this->itemd($tab, 'settings', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=settings">'.esc_attr__('Settings', 'lsx-wetu-importer').'</a></li>');
572
+		echo wp_kses_post('</ul> </div>');
573 573
 	}
574 574
 
575 575
 	/**
576 576
 	 * Wetu Status Bar.
577 577
 	 */
578 578
 	public function wetu_status() {
579
-		$tours = get_transient( 'lsx_ti_tours' );
580
-		echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status','lsx-wetu-importer' ) . ' - ';
579
+		$tours = get_transient('lsx_ti_tours');
580
+		echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').' - ';
581 581
 
582
-		if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) {
582
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
583 583
 			$result = $this->update_options();
584 584
 
585
-			if ( true === $result ) {
586
-				echo '<span style="color:green;">' . esc_attr( 'Connected','lsx-wetu-importer' ) . '</span>';
587
-				echo ' - <small><a href="#">' . esc_attr( 'Refresh','lsx-wetu-importer' ) . '</a></small>';
588
-			} else {
589
-				echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>';
585
+			if (true === $result) {
586
+				echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span>';
587
+				echo ' - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>';
588
+			}else {
589
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
590 590
 			}
591
-		} else {
592
-			echo '<span style="color:green;">' . esc_attr( 'Connected','lsx-wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh','lsx-wetu-importer' ) . '</a></small>';
591
+		}else {
592
+			echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>';
593 593
 		}
594 594
 		echo '</h3>';
595 595
 		echo '</div>';
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	/**
599 599
 	 * Set_taxonomy with some terms
600 600
 	 */
601
-	public function team_member_checkboxes( $selected = array() ) {
602
-		if ( post_type_exists( 'team' ) ) { ?>
601
+	public function team_member_checkboxes($selected = array()) {
602
+		if (post_type_exists('team')) { ?>
603 603
 			<ul>
604 604
 				<?php
605 605
 					$team_args = array(
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
 						'fields' => 'ids',
610 610
 					);
611 611
 
612
-					$team_members = new WP_Query( $team_args );
612
+					$team_members = new WP_Query($team_args);
613 613
 
614
-					if ( $team_members->have_posts() ) {
615
-						foreach ( $team_members->posts as $member ) {
614
+					if ($team_members->have_posts()) {
615
+						foreach ($team_members->posts as $member) {
616 616
 							?>
617
-							<li><input class="team" <?php $this->checked( $selected, $member ); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title( $member ); ?></li>
617
+							<li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
618 618
 							<?php
619 619
 						}
620
-					} else { ?>
621
-						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e( 'None', 'lsx-wetu-importer' ); ?></li>
620
+					}else { ?>
621
+						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e('None', 'lsx-wetu-importer'); ?></li>
622 622
 					<?php }
623 623
 				?>
624 624
 			</ul>
@@ -635,13 +635,13 @@  discard block
 block discarded – undo
635 635
 	 * @param $needle string
636 636
 	 * @param $echo bool
637 637
 	 */
638
-	public function checked( $haystack = false, $needle = '', $echo = true ) {
639
-		$return = $this->itemd( $haystack,$needle, 'checked' );
638
+	public function checked($haystack = false, $needle = '', $echo = true) {
639
+		$return = $this->itemd($haystack, $needle, 'checked');
640 640
 
641
-		if ( '' !== $return ) {
642
-			if ( true === $echo ) {
643
-				echo wp_kses_post( $return );
644
-			} else {
641
+		if ('' !== $return) {
642
+			if (true === $echo) {
643
+				echo wp_kses_post($return);
644
+			}else {
645 645
 				return $return;
646 646
 			}
647 647
 		}
@@ -654,13 +654,13 @@  discard block
 block discarded – undo
654 654
 	 * @param $needle string
655 655
 	 * @param $echo bool
656 656
 	 */
657
-	public function selected( $haystack = false, $needle = '', $echo = true ) {
658
-		$return = $this->itemd( $haystack, $needle, 'selected' );
657
+	public function selected($haystack = false, $needle = '', $echo = true) {
658
+		$return = $this->itemd($haystack, $needle, 'selected');
659 659
 
660
-		if ( '' !== $return ) {
661
-			if ( true === $echo ) {
662
-				echo wp_kses_post( $return );
663
-			} else {
660
+		if ('' !== $return) {
661
+			if (true === $echo) {
662
+				echo wp_kses_post($return);
663
+			}else {
664 664
 				return $return;
665 665
 			}
666 666
 		}
@@ -675,17 +675,17 @@  discard block
 block discarded – undo
675 675
 	 * @param $wrap bool
676 676
 	 * @return $html string
677 677
 	 */
678
-	public function itemd( $haystack = false, $needle = '', $type = '', $wrap = true ) {
678
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
679 679
 		$html = '';
680 680
 
681
-		if ( '' !== $type ) {
682
-			if ( ! is_array( $haystack ) ) {
683
-				$haystack = array( $haystack );
681
+		if ('' !== $type) {
682
+			if (!is_array($haystack)) {
683
+				$haystack = array($haystack);
684 684
 			}
685
-			if ( in_array( $needle, $haystack ) ) {
686
-				if ( true === $wrap || 'true' === $wrap ) {
687
-					$html = $type . '="' . $type . '"';
688
-				} else {
685
+			if (in_array($needle, $haystack)) {
686
+				if (true === $wrap || 'true' === $wrap) {
687
+					$html = $type.'="'.$type.'"';
688
+				}else {
689 689
 					$html = $type;
690 690
 				}
691 691
 			}
@@ -697,9 +697,9 @@  discard block
 block discarded – undo
697 697
 	/**
698 698
 	 * Grabs any attachments for the current item
699 699
 	 */
700
-	public function find_attachments( $id = false ) {
701
-		if ( false !== $id ) {
702
-			if ( empty( $this->found_attachments ) ) {
700
+	public function find_attachments($id = false) {
701
+		if (false !== $id) {
702
+			if (empty($this->found_attachments)) {
703 703
 				$attachments_args = array(
704 704
 					'post_parent' => $id,
705 705
 					'post_status' => 'inherit',
@@ -709,11 +709,11 @@  discard block
 block discarded – undo
709 709
 					'posts_per_page' => '-1',
710 710
 				);
711 711
 
712
-				$attachments = new WP_Query( $attachments_args );
712
+				$attachments = new WP_Query($attachments_args);
713 713
 
714
-				if ( $attachments->have_posts() ) {
715
-					foreach ( $attachments->posts as $attachment ) {
716
-						$this->found_attachments[ $attachment->ID ] = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $attachment->post_title );
714
+				if ($attachments->have_posts()) {
715
+					foreach ($attachments->posts as $attachment) {
716
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
717 717
 					}
718 718
 				}
719 719
 			}
@@ -725,19 +725,19 @@  discard block
 block discarded – undo
725 725
 	/**
726 726
 	 * Saves the room data
727 727
 	 */
728
-	public function save_custom_field( $value = false, $meta_key, $id, $decrease = false, $unique = true ) {
729
-		if ( false !== $value ) {
730
-			if ( false !== $decrease ) {
731
-				$value = intval( $value );
728
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
729
+		if (false !== $value) {
730
+			if (false !== $decrease) {
731
+				$value = intval($value);
732 732
 				$value--;
733 733
 			}
734 734
 
735
-			$prev = get_post_meta( $id, $meta_key, true );
735
+			$prev = get_post_meta($id, $meta_key, true);
736 736
 
737
-			if ( false !== $id && '0' !== $id && false !== $prev && true === $unique ) {
738
-				update_post_meta( $id, $meta_key, $value, $prev );
739
-			} else {
740
-				add_post_meta( $id, $meta_key, $value, $unique );
737
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
738
+				update_post_meta($id, $meta_key, $value, $prev);
739
+			}else {
740
+				add_post_meta($id, $meta_key, $value, $unique);
741 741
 			}
742 742
 		}
743 743
 	}
@@ -746,15 +746,15 @@  discard block
 block discarded – undo
746 746
 	 * Grabs the custom fields,  and resaves an array of unique items.
747 747
 	 */
748 748
 	public function cleanup_posts() {
749
-		if ( ! empty( $this->cleanup_posts ) ) {
749
+		if (!empty($this->cleanup_posts)) {
750 750
 
751
-			foreach ( $this->cleanup_posts as $id => $key ) {
752
-				$prev_items = get_post_meta( $id, $key, false );
753
-				$new_items = array_unique( $prev_items );
754
-				delete_post_meta( $id, $key );
751
+			foreach ($this->cleanup_posts as $id => $key) {
752
+				$prev_items = get_post_meta($id, $key, false);
753
+				$new_items = array_unique($prev_items);
754
+				delete_post_meta($id, $key);
755 755
 
756
-				foreach ( $new_items as $new_item ) {
757
-					add_post_meta( $id, $key, $new_item, false );
756
+				foreach ($new_items as $new_item) {
757
+					add_post_meta($id, $key, $new_item, false);
758 758
 				}
759 759
 			}
760 760
 		}
@@ -765,26 +765,26 @@  discard block
 block discarded – undo
765 765
 	/**
766 766
 	 * Set_taxonomy with some terms
767 767
 	 */
768
-	public function set_taxonomy( $taxonomy, $terms, $id ) {
768
+	public function set_taxonomy($taxonomy, $terms, $id) {
769 769
 		$result = array();
770 770
 
771
-		if ( ! empty( $data ) ) {
772
-			foreach ( $data as $k ) {
773
-				if ( $id ) {
774
-					$term = term_exists( trim( $k ), $tax );
775
-					if ( ! $term ) {
776
-						$term = wp_insert_term( trim( $k ), $tax );
777
-
778
-						if ( is_wp_error( $term ) ) {
779
-							echo wp_kses_post( $term->get_error_message() );
780
-						} else {
781
-							wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
771
+		if (!empty($data)) {
772
+			foreach ($data as $k) {
773
+				if ($id) {
774
+					$term = term_exists(trim($k), $tax);
775
+					if (!$term) {
776
+						$term = wp_insert_term(trim($k), $tax);
777
+
778
+						if (is_wp_error($term)) {
779
+							echo wp_kses_post($term->get_error_message());
780
+						}else {
781
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
782 782
 						}
783
-					} else {
784
-						wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
783
+					}else {
784
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
785 785
 					}
786
-				} else {
787
-					$result[] = trim( $k );
786
+				}else {
787
+					$result[] = trim($k);
788 788
 				}
789 789
 			}
790 790
 		}
@@ -800,23 +800,23 @@  discard block
 block discarded – undo
800 800
 	 * @param boolean $parent
801 801
 	 * @return void
802 802
 	 */
803
-	public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) {
804
-		$term = term_exists( $name, $taxonomy );
805
-		if ( ! $term ) {
806
-			if ( false !== $parent ) {
803
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
804
+		$term = term_exists($name, $taxonomy);
805
+		if (!$term) {
806
+			if (false !== $parent) {
807 807
 				$parent = array(
808 808
 					'parent' => $parent,
809 809
 				);
810 810
 			}
811
-			$term = wp_insert_term( trim( $name ), $taxonomy,$parent );
811
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
812 812
 
813
-			if ( is_wp_error( $term ) ) {
814
-				echo wp_kses_post( $term->get_error_message() );
815
-			} else {
816
-				wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
813
+			if (is_wp_error($term)) {
814
+				echo wp_kses_post($term->get_error_message());
815
+			}else {
816
+				wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
817 817
 			}
818
-		} else {
819
-			wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
818
+		}else {
819
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
820 820
 		}
821 821
 
822 822
 		return $term['term_id'];
@@ -825,22 +825,22 @@  discard block
 block discarded – undo
825 825
 	/**
826 826
 	 * set_taxonomy with some terms
827 827
 	 */
828
-	public function taxonomy_checkboxes( $taxonomy = false, $selected = array() ) {
828
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
829 829
 		$return = '';
830 830
 
831
-		if ( false !== $taxonomy ) {
831
+		if (false !== $taxonomy) {
832 832
 			$return .= '<ul>';
833
-			$terms = get_terms( array(
833
+			$terms = get_terms(array(
834 834
 				'taxonomy' => $taxonomy,
835 835
 				'hide_empty' => false,
836
-			) );
836
+			));
837 837
 
838
-			if ( ! is_wp_error( $terms ) ) {
839
-				foreach ( $terms as $term ) {
840
-					$return .= '<li><input class="' . $taxonomy . '" ' . $this->checked( $selected,$term->term_id,false ) . ' type="checkbox" value="' . $term->term_id . '" /> ' . $term->name . '</li>';
838
+			if (!is_wp_error($terms)) {
839
+				foreach ($terms as $term) {
840
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
841 841
 				}
842
-			} else {
843
-				$return .= '<li><input type="checkbox" value="" /> ' . __( 'None', 'lsx-wetu-importer' ) . '</li>';
842
+			}else {
843
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'lsx-wetu-importer').'</li>';
844 844
 			}
845 845
 
846 846
 			$return .= '</ul>';
@@ -854,44 +854,44 @@  discard block
 block discarded – undo
854 854
 	/**
855 855
 	 * Saves the longitude and lattitude, as well as sets the map marker.
856 856
 	 */
857
-	public function set_map_data( $data, $id, $zoom = '10' ) {
857
+	public function set_map_data($data, $id, $zoom = '10') {
858 858
 		$longitude = false;
859 859
 		$latitude = false;
860 860
 		$address = false;
861 861
 
862
-		if ( isset( $data[0]['position'] ) ) {
863
-			if ( isset( $data[0]['position']['driving_latitude'] ) ) {
862
+		if (isset($data[0]['position'])) {
863
+			if (isset($data[0]['position']['driving_latitude'])) {
864 864
 				$latitude = $data[0]['position']['driving_latitude'];
865
-			} elseif ( isset( $data[0]['position']['latitude'] ) ) {
865
+			} elseif (isset($data[0]['position']['latitude'])) {
866 866
 				$latitude = $data[0]['position']['latitude'];
867 867
 			}
868 868
 
869
-			if ( isset( $data[0]['position']['driving_longitude'] ) ) {
869
+			if (isset($data[0]['position']['driving_longitude'])) {
870 870
 				$longitude = $data[0]['position']['driving_longitude'];
871
-			} elseif ( isset( $data[0]['position']['longitude'] ) ) {
871
+			} elseif (isset($data[0]['position']['longitude'])) {
872 872
 				$longitude = $data[0]['position']['longitude'];
873 873
 			}
874 874
 		}
875 875
 
876
-		if ( isset( $data[0]['content'] ) && isset( $data[0]['content']['contact_information'] ) ) {
877
-			if ( isset( $data[0]['content']['contact_information']['address'] ) ) {
878
-				$address = strip_tags( $data[0]['content']['contact_information']['address'] );
879
-				$address = explode( "\n", $address );
876
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
877
+			if (isset($data[0]['content']['contact_information']['address'])) {
878
+				$address = strip_tags($data[0]['content']['contact_information']['address']);
879
+				$address = explode("\n", $address);
880 880
 
881
-				foreach ( $address as $bitkey => $bit ) {
882
-					$bit = ltrim( rtrim( $bit ) );
881
+				foreach ($address as $bitkey => $bit) {
882
+					$bit = ltrim(rtrim($bit));
883 883
 
884
-					if ( false === $bit || '' === $bit || null === $bit || empty( $bit ) ) {
885
-						unset( $address[ $bitkey ] );
884
+					if (false === $bit || '' === $bit || null === $bit || empty($bit)) {
885
+						unset($address[$bitkey]);
886 886
 					}
887 887
 				}
888 888
 
889
-				$address = implode( ', ',$address );
890
-				$address = str_replace( ', , ', ', ', $address );
889
+				$address = implode(', ', $address);
890
+				$address = str_replace(', , ', ', ', $address);
891 891
 			}
892 892
 		}
893 893
 
894
-		if ( false !== $longitude ) {
894
+		if (false !== $longitude) {
895 895
 			$location_data = array(
896 896
 				'address'	=> (string) $address,
897 897
 				'lat'		=> (string) $latitude,
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
 				'elevation'	=> '',
901 901
 			);
902 902
 
903
-			if ( false !== $id && '0' !== $id ) {
904
-				$prev = get_post_meta( $id,'location',true );
905
-				update_post_meta( $id,'location',$location_data,$prev );
906
-			} else {
907
-				add_post_meta( $id,'location',$location_data,true );
903
+			if (false !== $id && '0' !== $id) {
904
+				$prev = get_post_meta($id, 'location', true);
905
+				update_post_meta($id, 'location', $location_data, $prev);
906
+			}else {
907
+				add_post_meta($id, 'location', $location_data, true);
908 908
 			}
909 909
 		}
910 910
 	}
@@ -914,17 +914,17 @@  discard block
 block discarded – undo
914 914
 	/**
915 915
 	 * Creates the main gallery data
916 916
 	 */
917
-	public function set_featured_image( $data, $id ) {
918
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
919
-			$this->featured_image = $this->attach_image( $data[0]['content']['images'][0], $id,  array(
917
+	public function set_featured_image($data, $id) {
918
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
919
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id, array(
920 920
 				'width' => '800',
921 921
 				'height' => '600',
922 922
 				'cropping' => 'h',
923
-			) );
923
+			));
924 924
 
925
-			if ( false !== $this->featured_image ) {
926
-				delete_post_meta( $id,'_thumbnail_id' );
927
-				add_post_meta( $id,'_thumbnail_id',$this->featured_image,true );
925
+			if (false !== $this->featured_image) {
926
+				delete_post_meta($id, '_thumbnail_id');
927
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
928 928
 			}
929 929
 		}
930 930
 	}
@@ -932,26 +932,26 @@  discard block
 block discarded – undo
932 932
 	/**
933 933
 	 * Sets a banner image
934 934
 	 */
935
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
936
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
937
-			if ( in_array( 'unique_banner_image', $content ) && isset( $data[0]['destination_image'] ) && is_array( $data[0]['destination_image'] ) ) {
938
-				$temp_banner = $this->attach_image( $data[0]['destination_image'], $id, array(
935
+	public function set_banner_image($data, $id, $content = array('none')) {
936
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
937
+			if (in_array('unique_banner_image', $content) && isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
938
+				$temp_banner = $this->attach_image($data[0]['destination_image'], $id, array(
939 939
 					'width' => '1920',
940 940
 					'height' => '600',
941 941
 					'cropping' => 'c',
942 942
 				));
943
-			} else {
944
-				$temp_banner = $this->attach_image( $data[0]['content']['images'][1], $id, array(
943
+			}else {
944
+				$temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array(
945 945
 					'width' => '1920',
946 946
 					'height' => '600',
947 947
 					'cropping' => 'c',
948 948
 				));
949 949
 			}
950 950
 
951
-			if ( false !== $temp_banner ) {
951
+			if (false !== $temp_banner) {
952 952
 				$this->banner_image = $temp_banner;
953 953
 
954
-				delete_post_meta( $id,'image_group' );
954
+				delete_post_meta($id, 'image_group');
955 955
 
956 956
 				$new_banner = array(
957 957
 					'banner_image' => array(
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 					),
960 960
 				);
961 961
 
962
-				add_post_meta( $id,'image_group',$new_banner,true );
962
+				add_post_meta($id, 'image_group', $new_banner, true);
963 963
 			}
964 964
 		}
965 965
 	}
@@ -967,17 +967,17 @@  discard block
 block discarded – undo
967 967
 	/**
968 968
 	 * Creates the main gallery data
969 969
 	 */
970
-	public function create_main_gallery( $data, $id ) {
971
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
972
-			if ( isset( $this->options['image_replacing'] ) && 'on' === $this->options['image_replacing'] ) {
973
-				$current_gallery = get_post_meta( $id, 'gallery', false );
970
+	public function create_main_gallery($data, $id) {
971
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
972
+			if (isset($this->options['image_replacing']) && 'on' === $this->options['image_replacing']) {
973
+				$current_gallery = get_post_meta($id, 'gallery', false);
974 974
 
975
-				if ( false !== $current_gallery && ! empty( $current_gallery ) ) {
976
-					foreach ( $current_gallery as $g ) {
977
-						delete_post_meta( $id,'gallery', $g );
975
+				if (false !== $current_gallery && !empty($current_gallery)) {
976
+					foreach ($current_gallery as $g) {
977
+						delete_post_meta($id, 'gallery', $g);
978 978
 
979
-						if ( 'attachment' === get_post_type( $g ) ) {
980
-							wp_delete_attachment( $g, true );
979
+						if ('attachment' === get_post_type($g)) {
980
+							wp_delete_attachment($g, true);
981 981
 						}
982 982
 					}
983 983
 				}
@@ -985,32 +985,32 @@  discard block
 block discarded – undo
985 985
 
986 986
 			$counter = 0;
987 987
 
988
-			foreach ( $data[0]['content']['images'] as $image_data ) {
989
-				if ( ( 0 === $counter && false !== $this->featured_image ) || ( 1 === $counter && false !== $this->banner_image ) ) {
988
+			foreach ($data[0]['content']['images'] as $image_data) {
989
+				if ((0 === $counter && false !== $this->featured_image) || (1 === $counter && false !== $this->banner_image)) {
990 990
 					$counter++;
991 991
 
992
-					if ( false !== $this->image_limit && false !== $this->image_limit ) {
992
+					if (false !== $this->image_limit && false !== $this->image_limit) {
993 993
 						$this->image_limit++;
994 994
 					}
995 995
 
996 996
 					continue;
997 997
 				}
998 998
 
999
-				if ( false !== $this->image_limit && $counter >= $this->image_limit ) {
999
+				if (false !== $this->image_limit && $counter >= $this->image_limit) {
1000 1000
 					continue;
1001 1001
 				}
1002 1002
 
1003
-				$this->gallery_meta[] = $this->attach_image( $image_data,$id );
1003
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
1004 1004
 				$counter++;
1005 1005
 			}
1006 1006
 
1007
-			if ( ! empty( $this->gallery_meta ) ) {
1008
-				delete_post_meta( $id,'gallery' );
1009
-				$this->gallery_meta = array_unique( $this->gallery_meta );
1007
+			if (!empty($this->gallery_meta)) {
1008
+				delete_post_meta($id, 'gallery');
1009
+				$this->gallery_meta = array_unique($this->gallery_meta);
1010 1010
 
1011
-				foreach ( $this->gallery_meta as $gallery_id ) {
1012
-					if ( false !== $gallery_id && '' !== $gallery_id && ! is_array( $gallery_id ) ) {
1013
-						add_post_meta( $id,'gallery',$gallery_id,false );
1011
+				foreach ($this->gallery_meta as $gallery_id) {
1012
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
1013
+						add_post_meta($id, 'gallery', $gallery_id, false);
1014 1014
 					}
1015 1015
 				}
1016 1016
 			}
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 	/**
1021 1021
 	 * search_form
1022 1022
 	 */
1023
-	public function get_scaling_url( $args = array() ) {
1023
+	public function get_scaling_url($args = array()) {
1024 1024
 		$defaults = array(
1025 1025
 			'width' => '1024',
1026 1026
 			'height' => '768',
@@ -1028,59 +1028,59 @@  discard block
 block discarded – undo
1028 1028
 			'cropping' => 'h',
1029 1029
 		);
1030 1030
 
1031
-		if ( false !== $this->options ) {
1032
-			if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) {
1031
+		if (false !== $this->options) {
1032
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
1033 1033
 				$defaults['width'] = $this->options['width'];
1034 1034
 			}
1035 1035
 
1036
-			if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) {
1036
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
1037 1037
 				$defaults['height'] = $this->options['height'];
1038 1038
 			}
1039 1039
 
1040
-			if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) {
1040
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
1041 1041
 				$defaults['cropping'] = $this->options['cropping'];
1042 1042
 			}
1043 1043
 		}
1044 1044
 
1045
-		$args = wp_parse_args( $args, $defaults );
1045
+		$args = wp_parse_args($args, $defaults);
1046 1046
 		$cropping = $args['cropping'];
1047 1047
 		$width = $args['width'];
1048 1048
 		$height = $args['height'];
1049 1049
 
1050
-		return 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
1050
+		return 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
1051 1051
 	}
1052 1052
 
1053 1053
 	/**
1054 1054
 	 * Attaches 1 image
1055 1055
 	 */
1056
-	public function attach_image( $v = false, $parent_id, $image_sizes = false, $banner = false ) {
1057
-		if ( false !== $v ) {
1058
-			$temp_fragment = explode( '/',$v['url_fragment'] );
1059
-			$url_filename = $temp_fragment[ count( $temp_fragment ) -1 ];
1060
-			$url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename );
1061
-			$url_filename = trim( $url_filename );
1056
+	public function attach_image($v = false, $parent_id, $image_sizes = false, $banner = false) {
1057
+		if (false !== $v) {
1058
+			$temp_fragment = explode('/', $v['url_fragment']);
1059
+			$url_filename = $temp_fragment[count($temp_fragment) - 1];
1060
+			$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1061
+			$url_filename = trim($url_filename);
1062 1062
 			$title = $url_filename;
1063
-			$url_filename = str_replace( ' ','_',$url_filename );
1063
+			$url_filename = str_replace(' ', '_', $url_filename);
1064 1064
 
1065
-			if ( ! isset( $this->options['image_replacing'] ) && in_array( $url_filename, $this->found_attachments ) ) {
1066
-				return array_search( $url_filename,$this->found_attachments );
1065
+			if (!isset($this->options['image_replacing']) && in_array($url_filename, $this->found_attachments)) {
1066
+				return array_search($url_filename, $this->found_attachments);
1067 1067
 			}
1068 1068
 
1069 1069
 			$postdata = array();
1070 1070
 
1071
-			if ( empty( $v['label'] ) ) {
1071
+			if (empty($v['label'])) {
1072 1072
 				$v['label'] = '';
1073 1073
 			}
1074 1074
 
1075
-			if ( ! empty( $v['description'] ) ) {
1076
-				$desc = wp_strip_all_tags( $v['description'] );
1075
+			if (!empty($v['description'])) {
1076
+				$desc = wp_strip_all_tags($v['description']);
1077 1077
 				$posdata = array(
1078 1078
 					'post_excerpt' => $desc,
1079 1079
 				);
1080 1080
 			}
1081 1081
 
1082
-			if ( ! empty( $v['section'] ) ) {
1083
-				$desc = wp_strip_all_tags( $v['section'] );
1082
+			if (!empty($v['section'])) {
1083
+				$desc = wp_strip_all_tags($v['section']);
1084 1084
 				$posdata = array(
1085 1085
 					'post_excerpt' => $desc,
1086 1086
 				);
@@ -1088,88 +1088,88 @@  discard block
 block discarded – undo
1088 1088
 
1089 1089
 			$attach_id = null;
1090 1090
 			//Resizor - add option to setting if required
1091
-			$fragment = str_replace( ' ','%20',$v['url_fragment'] );
1092
-			$url = $this->get_scaling_url( $image_sizes ) . $fragment;
1091
+			$fragment = str_replace(' ', '%20', $v['url_fragment']);
1092
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1093 1093
 
1094
-			$attach_id = $this->attach_external_image2( $url,$parent_id,'',$v['label'],$postdata );
1094
+			$attach_id = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
1095 1095
 
1096
-			$this->found_attachments[ $attach_id ] = $url_filename;
1096
+			$this->found_attachments[$attach_id] = $url_filename;
1097 1097
 
1098 1098
 			//echo($attach_id.' add image');
1099
-			if ( ! empty( $attach_id ) ) {
1099
+			if (!empty($attach_id)) {
1100 1100
 				return $attach_id;
1101 1101
 			}
1102 1102
 		}
1103 1103
 		return 	false;
1104 1104
 	}
1105 1105
 
1106
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1107
-		if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); }
1106
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
1107
+		if (!$url || !$post_id) { return new WP_Error('missing', 'Need a valid URL and post ID...'); }
1108 1108
 
1109
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
1110
-		require_once( ABSPATH . 'wp-admin/includes/media.php' );
1111
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
1109
+		require_once(ABSPATH.'wp-admin/includes/file.php');
1110
+		require_once(ABSPATH.'wp-admin/includes/media.php');
1111
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1112 1112
 		// Download file to temp location, returns full server path to temp file
1113 1113
 		//$tmp = download_url( $url );
1114 1114
 
1115 1115
 		//var_dump($tmp);
1116
-		$tmp = tempnam( '/tmp', 'FOO' );
1116
+		$tmp = tempnam('/tmp', 'FOO');
1117 1117
 
1118
-		$image = file_get_contents( $url );
1119
-		file_put_contents( $tmp, $image );
1120
-		chmod( $tmp,'777' );
1118
+		$image = file_get_contents($url);
1119
+		file_put_contents($tmp, $image);
1120
+		chmod($tmp, '777');
1121 1121
 
1122
-		preg_match( '/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches );    // fix file filename for query strings
1123
-		$url_filename = basename( $matches[0] );
1124
-		$url_filename = str_replace( '%20','_',$url_filename );
1122
+		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings
1123
+		$url_filename = basename($matches[0]);
1124
+		$url_filename = str_replace('%20', '_', $url_filename);
1125 1125
 		// extract filename from url for title
1126
-		$url_type = wp_check_filetype( $url_filename );                                           // determine file type (ext and mime/type)
1126
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
1127 1127
 
1128 1128
 		// override filename if given, reconstruct server path
1129
-		if ( ! empty( $filename ) && ' ' != $filename ) {
1130
-			$filename = sanitize_file_name( $filename );
1131
-			$tmppath = pathinfo( $tmp );
1129
+		if (!empty($filename) && ' ' != $filename) {
1130
+			$filename = sanitize_file_name($filename);
1131
+			$tmppath = pathinfo($tmp);
1132 1132
 
1133 1133
 			$extension = '';
1134
-			if ( isset( $tmppath['extension'] ) ) {
1134
+			if (isset($tmppath['extension'])) {
1135 1135
 				$extension = $tmppath['extension'];
1136 1136
 			}
1137 1137
 
1138
-			$new = $tmppath['dirname'] . '/' . $filename . '.' . $extension;
1139
-			rename( $tmp, $new );                                                                 // renames temp file on server
1140
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
1138
+			$new = $tmppath['dirname'].'/'.$filename.'.'.$extension;
1139
+			rename($tmp, $new); // renames temp file on server
1140
+			$tmp = $new; // push new filename (in path) to be used in file array later
1141 1141
 		}
1142 1142
 
1143 1143
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
1144
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
1144
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
1145 1145
 
1146
-		if ( ! empty( $filename ) && ' ' != $filename ) {
1147
-			$file_array['name'] = $filename . '.' . $url_type['ext'];                           // user given filename for title, add original URL extension
1148
-		} else {
1149
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
1146
+		if (!empty($filename) && ' ' != $filename) {
1147
+			$file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension
1148
+		}else {
1149
+			$file_array['name'] = $url_filename; // just use original URL filename
1150 1150
 		}
1151 1151
 
1152 1152
 		// set additional wp_posts columns
1153
-		if ( empty( $post_data['post_title'] ) ) {
1153
+		if (empty($post_data['post_title'])) {
1154 1154
 
1155
-			$url_filename = str_replace( '%20',' ',$url_filename );
1155
+			$url_filename = str_replace('%20', ' ', $url_filename);
1156 1156
 
1157
-			$post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] );         // just use the original filename (no extension)
1157
+			$post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension)
1158 1158
 		}
1159 1159
 
1160 1160
 		// make sure gets tied to parent
1161
-		if ( empty( $post_data['post_parent'] ) ) {
1161
+		if (empty($post_data['post_parent'])) {
1162 1162
 			$post_data['post_parent'] = $post_id;
1163 1163
 		}
1164 1164
 
1165 1165
 		// required libraries for media_handle_sideload
1166 1166
 
1167 1167
 		// do the validation and storage stuff
1168
-		$att_id = media_handle_sideload( $file_array, $post_id, null, $post_data );             // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1168
+		$att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1169 1169
 
1170 1170
 		// If error storing permanently, unlink
1171
-		if ( is_wp_error( $att_id ) ) {
1172
-			unlink( $file_array['tmp_name'] );   // clean up
1171
+		if (is_wp_error($att_id)) {
1172
+			unlink($file_array['tmp_name']); // clean up
1173 1173
 			return false; // output wp_error
1174 1174
 			//return $att_id; // output wp_error
1175 1175
 		}
@@ -1197,33 +1197,33 @@  discard block
 block discarded – undo
1197 1197
 	/**
1198 1198
 	 * Formats the row for the completed list.
1199 1199
 	 */
1200
-	public function format_completed_row( $response ) {
1201
-		echo wp_kses_post( '<li class="post-' . $response . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $response ) . '">' . get_the_title( $response ) . '</a></li>' );
1200
+	public function format_completed_row($response) {
1201
+		echo wp_kses_post('<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>');
1202 1202
 	}
1203 1203
 
1204 1204
 	/**
1205 1205
 	 * Formats the error.
1206 1206
 	 */
1207
-	public function format_error( $response ) {
1208
-		echo wp_kses_post( '<li class="post-error"><span class="dashicons dashicons-no"></span>' . $response . '</li>' );
1207
+	public function format_error($response) {
1208
+		echo wp_kses_post('<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>');
1209 1209
 	}
1210 1210
 
1211 1211
 	/**
1212 1212
 	 * Does a multine search
1213 1213
 	 */
1214
-	public function multineedle_stripos( $haystack, $needles, $offset = 0 ) {
1214
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1215 1215
 		$found = false;
1216
-		$needle_count = count( $needles );
1216
+		$needle_count = count($needles);
1217 1217
 
1218
-		foreach ( $needles as $needle ) {
1219
-			if ( false !== stripos( $haystack, $needle, $offset ) ) {
1218
+		foreach ($needles as $needle) {
1219
+			if (false !== stripos($haystack, $needle, $offset)) {
1220 1220
 				$found[] = true;
1221 1221
 			}
1222 1222
 		}
1223 1223
 
1224
-		if ( false !== $found && count( $found ) === $needle_count ) {
1224
+		if (false !== $found && count($found) === $needle_count) {
1225 1225
 			return true;
1226
-		} else {
1226
+		}else {
1227 1227
 			return false;
1228 1228
 		}
1229 1229
 	}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 	/**
1232 1232
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1233 1233
 	 */
1234
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
1234
+	public function find_current_accommodation($post_type = 'accommodation') {
1235 1235
 		global $wpdb;
1236 1236
 		$return = array();
1237 1237
 
@@ -1250,9 +1250,9 @@  discard block
 block discarded – undo
1250 1250
 		");
1251 1251
 		// @codingStandardsIgnoreEnd
1252 1252
 
1253
-		if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
1254
-			foreach ( $current_accommodation as $accom ) {
1255
-				$return[ $accom->meta_value ] = $accom;
1253
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1254
+			foreach ($current_accommodation as $accom) {
1255
+				$return[$accom->meta_value] = $accom;
1256 1256
 			}
1257 1257
 		}
1258 1258
 
@@ -1262,20 +1262,20 @@  discard block
 block discarded – undo
1262 1262
 	/**
1263 1263
 	 * Set the Video date
1264 1264
 	 */
1265
-	public function set_video_data( $data, $id ) {
1266
-		if ( ! empty( $data[0]['content']['youtube_videos'] ) && is_array( $data[0]['content']['youtube_videos'] ) ) {
1265
+	public function set_video_data($data, $id) {
1266
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1267 1267
 			$videos = false;
1268 1268
 
1269
-			foreach ( $data[0]['content']['youtube_videos'] as $video ) {
1269
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1270 1270
 				$temp_video = array();
1271 1271
 
1272
-				if ( isset( $video['label'] ) ) {
1272
+				if (isset($video['label'])) {
1273 1273
 					$temp_video['title'] = $video['label'];
1274 1274
 				}
1275
-				if ( isset( $video['description'] ) ) {
1276
-					$temp_video['description'] = strip_tags( $video['description'] );
1275
+				if (isset($video['description'])) {
1276
+					$temp_video['description'] = strip_tags($video['description']);
1277 1277
 				}
1278
-				if ( isset( $video['url'] ) ) {
1278
+				if (isset($video['url'])) {
1279 1279
 					$temp_video['url'] = $video['url'];
1280 1280
 				}
1281 1281
 
@@ -1283,24 +1283,24 @@  discard block
 block discarded – undo
1283 1283
 				$videos[] = $temp_video;
1284 1284
 			}
1285 1285
 
1286
-			if ( false !== $id && '0' !== $id ) {
1287
-				delete_post_meta( $id, 'videos' );
1286
+			if (false !== $id && '0' !== $id) {
1287
+				delete_post_meta($id, 'videos');
1288 1288
 			}
1289 1289
 
1290
-			foreach ( $videos as $video ) {
1291
-				add_post_meta( $id,'videos',$video,false );
1290
+			foreach ($videos as $video) {
1291
+				add_post_meta($id, 'videos', $video, false);
1292 1292
 			}
1293 1293
 		}
1294 1294
 	}
1295 1295
 
1296
-	public function shuffle_assoc( &$array ) {
1296
+	public function shuffle_assoc(&$array) {
1297 1297
 		$new = array();
1298
-		$keys = array_keys( $array );
1298
+		$keys = array_keys($array);
1299 1299
 
1300
-		shuffle( $keys );
1300
+		shuffle($keys);
1301 1301
 
1302
-		foreach ( $keys as $key ) {
1303
-			$new[ $key ] = $array[ $key ];
1302
+		foreach ($keys as $key) {
1303
+			$new[$key] = $array[$key];
1304 1304
 		}
1305 1305
 
1306 1306
 		$array = $new;
@@ -1314,29 +1314,29 @@  discard block
 block discarded – undo
1314 1314
 	public function update_options() {
1315 1315
 		$own = '';
1316 1316
 		$options = array();
1317
-		delete_option( 'lsx_ti_tours_api_options' );
1317
+		delete_option('lsx_ti_tours_api_options');
1318 1318
 
1319
-		if ( isset( $_GET['own'] ) ) {
1319
+		if (isset($_GET['own'])) {
1320 1320
 			$this->current_importer->url_qs .= '&own=true';
1321 1321
 			$options[] = 'own';
1322 1322
 		}
1323 1323
 
1324
-		if ( isset( $_GET['type'] ) && 'allitineraries' !== $_GET['type'] ) {
1325
-			$this->current_importer->url_qs .= '&type=' . implode( '', $_GET['type'] );
1326
-			$options[] = implode( '', $_GET['type'] );
1324
+		if (isset($_GET['type']) && 'allitineraries' !== $_GET['type']) {
1325
+			$this->current_importer->url_qs .= '&type='.implode('', $_GET['type']);
1326
+			$options[] = implode('', $_GET['type']);
1327 1327
 		}
1328 1328
 
1329 1329
 		$this->current_importer->url_qs .= '&results=2000';
1330 1330
 
1331
-		add_option( 'lsx_ti_tours_api_options', $options );
1331
+		add_option('lsx_ti_tours_api_options', $options);
1332 1332
 
1333
-		$data = wp_remote_get( $this->current_importer->url . '/V8/List?' . $this->current_importer->url_qs );
1334
-		$tours = json_decode( wp_remote_retrieve_body( $data ), true );
1333
+		$data = wp_remote_get($this->current_importer->url.'/V8/List?'.$this->current_importer->url_qs);
1334
+		$tours = json_decode(wp_remote_retrieve_body($data), true);
1335 1335
 
1336
-		if ( isset( $tours['error'] ) ) {
1336
+		if (isset($tours['error'])) {
1337 1337
 			return $tours['error'];
1338
-		} elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) {
1339
-			set_transient( 'lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2 );
1338
+		} elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
1339
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
1340 1340
 			return true;
1341 1341
 		}
1342 1342
 	}
Please login to merge, or discard this patch.
lsx-importer-for-wetu.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
  * Domain Path: /languages/
12 12
  */
13 13
 
14
-define( 'LSX_WETU_IMPORTER_PATH', plugin_dir_path( __FILE__ ) );
15
-define( 'LSX_WETU_IMPORTER_CORE', __FILE__ );
16
-define( 'LSX_WETU_IMPORTER_URL', plugin_dir_url( __FILE__ ) );
17
-define( 'LSX_WETU_IMPORTER_VER', '1.2.0' );
14
+define('LSX_WETU_IMPORTER_PATH', plugin_dir_path(__FILE__));
15
+define('LSX_WETU_IMPORTER_CORE', __FILE__);
16
+define('LSX_WETU_IMPORTER_URL', plugin_dir_url(__FILE__));
17
+define('LSX_WETU_IMPORTER_VER', '1.2.0');
18 18
 
19
-register_activation_hook( LSX_WETU_IMPORTER_CORE, array( 'LSX_WETU_Importer', 'register_activation_hook' ) );
19
+register_activation_hook(LSX_WETU_IMPORTER_CORE, array('LSX_WETU_Importer', 'register_activation_hook'));
20 20
 
21 21
 /* ======================= Below is the Plugin Class init ========================= */
22 22
 
23
-require_once( LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-logger.php' );
24
-require_once( LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer.php' );
23
+require_once(LSX_WETU_IMPORTER_PATH.'classes/class-lsx-logger.php');
24
+require_once(LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer.php');
Please login to merge, or discard this patch.
classes/class-settings.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 			'height'                             => '600',
59 59
 			'scaling'                            => 'h',
60 60
 		);
61
-		$this->fields   = array_keys( $this->defaults );
62
-		add_action( 'admin_init', array( $this, 'save_options' ) );
61
+		$this->fields = array_keys($this->defaults);
62
+		add_action('admin_init', array($this, 'save_options'));
63 63
 	}
64 64
 
65 65
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public static function get_instance() {
71 71
 		// If the single instance hasn't been set, set it now.
72
-		if ( ! isset( self::$instance ) ) {
72
+		if (!isset(self::$instance)) {
73 73
 			self::$instance = new self();
74 74
 		}
75 75
 		return self::$instance;
@@ -80,117 +80,117 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function display_page() {
82 82
 		$options = \lsx_wetu_importer\includes\helpers\get_options();
83
-		foreach ( $options as $key => $value ) {
84
-			$value = trim( $value );
83
+		foreach ($options as $key => $value) {
84
+			$value = trim($value);
85 85
 		}
86
-		$options = wp_parse_args( $options, $this->defaults );
86
+		$options = wp_parse_args($options, $this->defaults);
87 87
 		?>
88 88
 		<div class="wrap">
89 89
 			<form method="post" class="">
90
-				<?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?>
90
+				<?php wp_nonce_field('lsx_wetu_importer_save', 'lsx_wetu_importer_save_options'); ?>
91 91
 				
92
-				<h1><?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></h1>
92
+				<h1><?php esc_html_e('General', 'lsx-wetu-importer'); ?></h1>
93 93
 				<table class="form-table">
94 94
 					<tbody>
95 95
 						<tr class="form-field">
96 96
 							<th scope="row">
97
-								<label for="wetu_api_key"> <?php esc_html_e( 'API Key', 'lsx-wetu-importer' ); ?></label>
97
+								<label for="wetu_api_key"> <?php esc_html_e('API Key', 'lsx-wetu-importer'); ?></label>
98 98
 							</th>
99 99
 							<td>
100
-								<input type="text" value="<?php if ( isset( $options['api_key'] ) ) { echo esc_attr( $options['api_key'] ); } ?>" name="api_key" />
100
+								<input type="text" value="<?php if (isset($options['api_key'])) { echo esc_attr($options['api_key']); } ?>" name="api_key" />
101 101
 							</td>
102 102
 						</tr>
103 103
 						<tr class="form-field -wrap">
104 104
 							<th scope="row">
105
-								<label for="disable_tour_descriptions"><?php esc_html_e( 'Disable Tour Descriptions', 'lsx-wetu-importer' ); ?></label>
105
+								<label for="disable_tour_descriptions"><?php esc_html_e('Disable Tour Descriptions', 'lsx-wetu-importer'); ?></label>
106 106
 							</th>
107 107
 							<td>
108 108
 								<input type="checkbox"
109 109
 								<?php
110
-								if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
111
-									echo esc_attr( 'checked="checked"' );
110
+								if (isset($options['disable_tour_descriptions']) && '' !== $options['disable_tour_descriptions']) {
111
+									echo esc_attr('checked="checked"');
112 112
 								}
113 113
 								?>
114 114
 								name="disable_tour_descriptions" />
115 115
 
116
-								<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>
116
+								<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>
117 117
 							</td>
118 118
 						</tr>
119 119
 						<tr class="form-field -wrap">
120 120
 							<th scope="row">
121
-								<label for="disable_accommodation_descriptions"><?php esc_html_e( 'Disable Accommodation Descriptions', 'lsx-wetu-importer' ); ?></label>
121
+								<label for="disable_accommodation_descriptions"><?php esc_html_e('Disable Accommodation Descriptions', 'lsx-wetu-importer'); ?></label>
122 122
 							</th>
123 123
 							<td>
124 124
 								<input type="checkbox"
125 125
 								<?php
126
-								if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
127
-									echo esc_attr( 'checked="checked"' );
126
+								if (isset($options['disable_accommodation_descriptions']) && '' !== $options['disable_accommodation_descriptions']) {
127
+									echo esc_attr('checked="checked"');
128 128
 								}
129 129
 								?>
130 130
 								name="disable_accommodation_descriptions" />
131
-								<small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small>
131
+								<small><?php esc_html_e('If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer'); ?></small>
132 132
 							</td>
133 133
 						</tr>
134 134
 						<tr class="form-field -wrap">
135 135
 							<th scope="row">
136
-								<label for="disable_accommodation_excerpts"><?php esc_html_e( 'Disable Accommodation Excerpts', 'lsx-wetu-importer' ); ?></label>
136
+								<label for="disable_accommodation_excerpts"><?php esc_html_e('Disable Accommodation Excerpts', 'lsx-wetu-importer'); ?></label>
137 137
 							</th>
138 138
 							<td>
139 139
 								<input type="checkbox"
140 140
 								<?php
141
-								if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
142
-									echo esc_attr( 'checked="checked"' );
141
+								if (isset($options['disable_accommodation_excerpts']) && '' !== $options['disable_accommodation_excerpts']) {
142
+									echo esc_attr('checked="checked"');
143 143
 								}
144 144
 								?>
145 145
 								name="disable_accommodation_excerpts" />
146
-								<small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small>
146
+								<small><?php esc_html_e('If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer'); ?></small>
147 147
 							</td>
148 148
 						</tr>
149 149
 						<tr class="form-field -wrap">
150 150
 							<th scope="row">
151
-								<label for="disable_destination_descriptions"><?php esc_html_e( 'Disable Destinations Descriptions', 'lsx-wetu-importer' ); ?></label>
151
+								<label for="disable_destination_descriptions"><?php esc_html_e('Disable Destinations Descriptions', 'lsx-wetu-importer'); ?></label>
152 152
 							</th>
153 153
 							<td>
154 154
 								<input type="checkbox"
155 155
 								<?php
156
-								if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
157
-									echo esc_attr( 'checked="checked"' );
156
+								if (isset($options['disable_destination_descriptions']) && '' !== $options['disable_destination_descriptions']) {
157
+									echo esc_attr('checked="checked"');
158 158
 								}
159 159
 								?>
160 160
 								name="disable_destination_descriptions" />
161
-								<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>
161
+								<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>
162 162
 							</td>
163 163
 						</tr>					
164 164
 					</tbody>
165 165
 				</table>
166 166
 
167
-				<h1><?php esc_html_e( 'Images', 'lsx-wetu-importer' ); ?></h1>
167
+				<h1><?php esc_html_e('Images', 'lsx-wetu-importer'); ?></h1>
168 168
 
169 169
 				<table class="form-table">
170 170
 					<tbody>
171 171
 						<tr class="form-field -wrap">
172 172
 							<th scope="row">
173
-								<label for="image_replacing"><?php esc_html_e( 'Replace Images', 'lsx-wetu-importer' ); ?></label>
173
+								<label for="image_replacing"><?php esc_html_e('Replace Images', 'lsx-wetu-importer'); ?></label>
174 174
 							</th>
175 175
 							<td>
176 176
 								<input type="checkbox"
177 177
 								<?php
178
-								if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
179
-									echo esc_attr( 'checked="checked"' );
178
+								if (isset($options['image_replacing']) && '' !== $options['image_replacing']) {
179
+									echo esc_attr('checked="checked"');
180 180
 								}
181 181
 								?>
182 182
 								name="image_replacing" />
183
-								<p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p>
183
+								<p><?php esc_html_e('Do you want your images to be replaced on each import.', 'lsx-wetu-importer'); ?></p>
184 184
 							</td>
185 185
 						</tr>
186 186
 						<tr class="form-field -wrap">
187 187
 							<th scope="row">
188
-								<label for="image_limit"> <?php esc_html_e( 'Limit the amount of images imported to the gallery', 'lsx-wetu-importer' ); ?></label>
188
+								<label for="image_limit"> <?php esc_html_e('Limit the amount of images imported to the gallery', 'lsx-wetu-importer'); ?></label>
189 189
 							</th>
190 190
 							<td>
191 191
 								<input placeholder="" type="text" value="<?php
192
-								if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
193
-									echo esc_attr( $options['image_limit'] );
192
+								if (isset($options['image_limit']) && '' !== $options['image_limit']) {
193
+									echo esc_attr($options['image_limit']);
194 194
 								}
195 195
 								?>
196 196
 								"
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 
201 201
 						<tr class="form-field -wrap">
202 202
 							<th scope="row">
203
-								<label for="image_scaling"><?php esc_html_e( 'Enable Image Scaling', 'lsx-wetu-importer' ); ?></label>
203
+								<label for="image_scaling"><?php esc_html_e('Enable Image Scaling', 'lsx-wetu-importer'); ?></label>
204 204
 							</th>
205 205
 							<td>
206 206
 								<input type="checkbox"
207 207
 								<?php
208
-								if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
209
-									echo esc_attr( 'checked="checked"' );
208
+								if (isset($options['image_scaling']) && '' !== $options['image_scaling']) {
209
+									echo esc_attr('checked="checked"');
210 210
 								}
211 211
 								?>
212 212
 								name="image_scaling" />
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
 						</tr>
215 215
 						<tr class="form-field -wrap">
216 216
 							<th scope="row">
217
-								<label for="width"> <?php esc_html_e( 'Width (px)', 'lsx-wetu-importer' ); ?></label>
217
+								<label for="width"> <?php esc_html_e('Width (px)', 'lsx-wetu-importer'); ?></label>
218 218
 							</th>
219 219
 							<td>
220 220
 								<input placeholder="800" type="text" value="<?php
221
-								if ( isset( $options['width'] ) && '' !== $options['width'] ) {
222
-									echo esc_attr( $options['width'] );
221
+								if (isset($options['width']) && '' !== $options['width']) {
222
+									echo esc_attr($options['width']);
223 223
 								}
224 224
 								?>"
225 225
 								name="width" />
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 						</tr>
228 228
 						<tr class="form-field -wrap">
229 229
 							<th scope="row">
230
-								<label for="height"> <?php esc_html_e( 'Height (px)', 'lsx-wetu-importer' ); ?></label>
230
+								<label for="height"> <?php esc_html_e('Height (px)', 'lsx-wetu-importer'); ?></label>
231 231
 							</th>
232 232
 							<td>
233 233
 								<input placeholder="600" type="text" value="<?php
234
-								if ( isset( $options['height'] ) && '' !== $options['height'] ) {
235
-									echo esc_attr( $options['height'] );
234
+								if (isset($options['height']) && '' !== $options['height']) {
235
+									echo esc_attr($options['height']);
236 236
 								}
237 237
 								?>"
238 238
 								name="height" />
@@ -241,63 +241,63 @@  discard block
 block discarded – undo
241 241
 
242 242
 						<tr class="form-field -wrap">
243 243
 							<th scope="row">
244
-								<label for="scaling"> <?php esc_html_e( 'Scaling', 'lsx-wetu-importer' ); ?></label>
244
+								<label for="scaling"> <?php esc_html_e('Scaling', 'lsx-wetu-importer'); ?></label>
245 245
 							</th>
246 246
 							<td>
247 247
 								<input type="radio"
248 248
 								<?php
249
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
250
-									echo esc_attr( 'checked="checked"' );
249
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'raw' === $options['scaling']) {
250
+									echo esc_attr('checked="checked"');
251 251
 								}
252 252
 								?>
253
-								name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br />
253
+								name="scaling" value="raw" /> <?php esc_html_e('Get the Full size image, no cropping takes place.', 'lsx-wetu-importer'); ?><br />
254 254
 								<input type="radio"
255 255
 								<?php
256
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
257
-									echo esc_attr( 'checked="checked"' );
256
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'c' === $options['scaling']) {
257
+									echo esc_attr('checked="checked"');
258 258
 								}
259 259
 								?>
260
-								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 />
260
+								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 />
261 261
 								<input type="radio"
262 262
 								<?php
263
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
264
-									echo esc_attr( 'checked="checked"' );
263
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'h' === $options['scaling']) {
264
+									echo esc_attr('checked="checked"');
265 265
 								}
266 266
 								?>
267
-								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 />
267
+								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 />
268 268
 								<input type="radio"
269 269
 								<?php
270
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
271
-									echo esc_attr( 'checked="checked"' );
270
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'w' === $options['scaling']) {
271
+									echo esc_attr('checked="checked"');
272 272
 								}
273 273
 								?>
274
-								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 />
274
+								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 />
275 275
 								<input type="radio"
276 276
 								<?php
277
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
278
-									echo esc_attr( 'checked="checked"' );
277
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'nf' === $options['scaling']) {
278
+									echo esc_attr('checked="checked"');
279 279
 								}
280 280
 								?>
281
-								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 />
281
+								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 />
282 282
 								<input type="radio"
283 283
 								<?php
284
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
285
-									echo esc_attr( 'checked="checked"' );
284
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'n' === $options['scaling']) {
285
+									echo esc_attr('checked="checked"');
286 286
 								}
287 287
 								?>
288
-								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 />
288
+								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 />
289 289
 								<input type="radio"
290 290
 								<?php
291
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
292
-									echo esc_attr( 'checked="checked"' );
291
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'W' === $options['scaling']) {
292
+									echo esc_attr('checked="checked"');
293 293
 								}
294 294
 								?>
295
-								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' ); ?>
295
+								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'); ?>
296 296
 							</td>
297 297
 						</tr>
298 298
 					</tbody>
299 299
 				</table>
300
-				<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>
300
+				<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>
301 301
 			</form>
302 302
 		</div>
303 303
 		<?php
@@ -309,17 +309,17 @@  discard block
 block discarded – undo
309 309
 	 * @return void
310 310
 	 */
311 311
 	public function save_options() {
312
-		if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
312
+		if (!isset($_POST['lsx_wetu_importer_save_options']) || !wp_verify_nonce($_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save')) {
313 313
 			return;
314 314
 		}
315 315
 		$data_to_save = array();
316
-		foreach ( $this->defaults as $key => $field ) {
317
-			if ( isset( $_POST[ $key ] ) ) {
318
-				$data_to_save[ $key ] = $_POST[ $key ];
319
-			} else {
320
-				$data_to_save[ $key ] = '';
316
+		foreach ($this->defaults as $key => $field) {
317
+			if (isset($_POST[$key])) {
318
+				$data_to_save[$key] = $_POST[$key];
319
+			}else {
320
+				$data_to_save[$key] = '';
321 321
 			}
322 322
 		}
323
-		update_option( 'lsx_wetu_importer_settings', $data_to_save );
323
+		update_option('lsx_wetu_importer_settings', $data_to_save);
324 324
 	}
325 325
 }
Please login to merge, or discard this patch.