@@ -11,50 +11,50 @@ discard block |
||
11 | 11 | * Domain Path: /languages/ |
12 | 12 | */ |
13 | 13 | |
14 | -define( 'WETU_IMPORTER_PATH', plugin_dir_path( __FILE__ ) ); |
|
15 | -define( 'WETU_IMPORTER_CORE', __FILE__ ); |
|
16 | -define( 'WETU_IMPORTER_URL', plugin_dir_url( __FILE__ ) ); |
|
17 | -define( 'WETU_IMPORTER_VER', '1.1.1' ); |
|
14 | +define('WETU_IMPORTER_PATH', plugin_dir_path(__FILE__)); |
|
15 | +define('WETU_IMPORTER_CORE', __FILE__); |
|
16 | +define('WETU_IMPORTER_URL', plugin_dir_url(__FILE__)); |
|
17 | +define('WETU_IMPORTER_VER', '1.1.1'); |
|
18 | 18 | |
19 | -register_activation_hook( WETU_IMPORTER_CORE, array( 'WETU_Importer', 'register_activation_hook' ) ); |
|
19 | +register_activation_hook(WETU_IMPORTER_CORE, array('WETU_Importer', 'register_activation_hook')); |
|
20 | 20 | |
21 | 21 | /* ======================= The API Classes ========================= */ |
22 | 22 | |
23 | -if ( ! class_exists( 'LSX_API_Manager' ) ) { |
|
24 | - require_once( 'classes/class-lsx-api-manager.php' ); |
|
23 | +if (!class_exists('LSX_API_Manager')) { |
|
24 | + require_once('classes/class-lsx-api-manager.php'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Grabs the email and api key from settings. |
29 | 29 | */ |
30 | -function lsx_to_wetu_importer_options_pages_filter( $pages ) { |
|
30 | +function lsx_to_wetu_importer_options_pages_filter($pages) { |
|
31 | 31 | $pages[] = 'lsx-to-settings'; |
32 | 32 | return $pages; |
33 | 33 | } |
34 | 34 | |
35 | -add_filter( 'lsx_api_manager_options_pages', 'lsx_to_wetu_importer_options_pages_filter', 10, 1 ); |
|
35 | +add_filter('lsx_api_manager_options_pages', 'lsx_to_wetu_importer_options_pages_filter', 10, 1); |
|
36 | 36 | |
37 | 37 | function lsx_to_wetu_importer_api_admin_init() { |
38 | - $options = get_option( '_lsx-to_settings', false ); |
|
38 | + $options = get_option('_lsx-to_settings', false); |
|
39 | 39 | |
40 | 40 | $data = array( |
41 | 41 | 'api_key' => '', |
42 | 42 | 'email' => '', |
43 | 43 | ); |
44 | 44 | |
45 | - if ( false !== $options && isset( $options['api'] ) ) { |
|
46 | - if ( isset( $options['api']['wetu-importer_api_key'] ) && '' !== $options['api']['wetu-importer_api_key'] ) { |
|
45 | + if (false !== $options && isset($options['api'])) { |
|
46 | + if (isset($options['api']['wetu-importer_api_key']) && '' !== $options['api']['wetu-importer_api_key']) { |
|
47 | 47 | $data['api_key'] = $options['api']['wetu-importer_api_key']; |
48 | 48 | } |
49 | 49 | |
50 | - if ( isset( $options['api']['wetu-importer_email'] ) && '' !== $options['api']['wetu-importer_email'] ) { |
|
50 | + if (isset($options['api']['wetu-importer_email']) && '' !== $options['api']['wetu-importer_email']) { |
|
51 | 51 | $data['email'] = $options['api']['wetu-importer_email']; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $instance = get_option( 'lsx_api_instance', false ); |
|
55 | + $instance = get_option('lsx_api_instance', false); |
|
56 | 56 | |
57 | - if ( false === $instance ) { |
|
57 | + if (false === $instance) { |
|
58 | 58 | $instance = LSX_API_Manager::generatePassword(); |
59 | 59 | } |
60 | 60 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | 'file' => 'wetu-importer.php', |
68 | 68 | ); |
69 | 69 | |
70 | - $lsx_to_wetu_importer_api_manager = new LSX_API_Manager( $api_array ); |
|
70 | + $lsx_to_wetu_importer_api_manager = new LSX_API_Manager($api_array); |
|
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'admin_init', 'lsx_to_wetu_importer_api_admin_init' ); |
|
73 | +add_action('admin_init', 'lsx_to_wetu_importer_api_admin_init'); |
|
74 | 74 | |
75 | 75 | /* ======================= Below is the Plugin Class init ========================= */ |
76 | 76 | |
77 | -require_once( WETU_IMPORTER_PATH . 'classes/class-wetu-importer.php' ); |
|
77 | +require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer.php'); |
|
78 | 78 | //require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer-connect-accommodation.php'); |
79 | -require_once( WETU_IMPORTER_PATH . 'classes/class-wetu-importer-settings.php' ); |
|
79 | +require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer-settings.php'); |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | public function set_variables() { |
99 | 99 | parent::set_variables(); |
100 | 100 | |
101 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
101 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
102 | 102 | $this->url = 'https://wetu.com/API/Itinerary/'; |
103 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
104 | - } elseif ( false !== $this->api_key ) { |
|
105 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
103 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
104 | + } elseif (false !== $this->api_key) { |
|
105 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
106 | 106 | $this->url_qs = ''; |
107 | 107 | } |
108 | 108 | |
109 | - $temp_options = get_option( '_lsx-to_settings',false ); |
|
109 | + $temp_options = get_option('_lsx-to_settings', false); |
|
110 | 110 | |
111 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
112 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
111 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
112 | + $this->options = $temp_options[$this->plugin_slug]; |
|
113 | 113 | } |
114 | 114 | |
115 | - $tour_options = get_option( 'wetu_importer_tour_settings',false ); |
|
115 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
116 | 116 | |
117 | - if ( false !== $tour_options ) { |
|
117 | + if (false !== $tour_options) { |
|
118 | 118 | $this->tour_options = $tour_options; |
119 | 119 | } |
120 | 120 | } |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | public function display_page() { |
126 | 126 | ?> |
127 | 127 | <div class="wrap"> |
128 | - <?php $this->navigation( 'tour' ); ?> |
|
128 | + <?php $this->navigation('tour'); ?> |
|
129 | 129 | |
130 | 130 | <?php $this->update_options_form(); ?> |
131 | 131 | |
132 | 132 | <?php $this->search_form(); ?> |
133 | 133 | |
134 | 134 | <form method="get" action="" id="posts-filter"> |
135 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
135 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
136 | 136 | |
137 | - <p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','wetu-importer' ); ?>" /> |
|
138 | - <input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','wetu-importer' ); ?>" /> |
|
137 | + <p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>" /> |
|
138 | + <input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'wetu-importer'); ?>" /> |
|
139 | 139 | </p> |
140 | 140 | |
141 | 141 | <table class="wp-list-table widefat fixed posts"> |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | <tbody id="the-list"> |
145 | 145 | <tr class="post-0 type-tour status-none" id="post-0"> |
146 | 146 | <th class="check-column" scope="row"> |
147 | - <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter','wetu-importer' ); ?></label> |
|
147 | + <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
148 | 148 | </th> |
149 | 149 | <td class="post-title page-title column-title"> |
150 | 150 | <strong> |
151 | - <?php esc_html_e( 'Enter a title to search for','wetu-importer' ); ?> |
|
151 | + <?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?> |
|
152 | 152 | </strong> |
153 | 153 | </td> |
154 | 154 | <td class="date column-date"> |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | |
163 | 163 | </table> |
164 | 164 | |
165 | - <p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','wetu-importer' ); ?>" /> |
|
166 | - <input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','wetu-importer' ); ?>" /> |
|
165 | + <p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>" /> |
|
166 | + <input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'wetu-importer'); ?>" /> |
|
167 | 167 | </p> |
168 | 168 | </form> |
169 | 169 | |
@@ -173,20 +173,20 @@ discard block |
||
173 | 173 | |
174 | 174 | <div class="row"> |
175 | 175 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
176 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
176 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
177 | 177 | <ul> |
178 | - <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','wetu-importer' ); ?></li> |
|
178 | + <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', 'wetu-importer'); ?></li> |
|
179 | 179 | |
180 | - <?php if ( isset( $this->options ) && 'on' !== $this->options['disable_tour_descriptions'] ) { ?> |
|
181 | - <li><input class="content" <?php $this->checked( $this->tour_options,'description' ); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description','wetu-importer' ); ?></li> |
|
180 | + <?php if (isset($this->options) && 'on' !== $this->options['disable_tour_descriptions']) { ?> |
|
181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li> |
|
182 | 182 | <?php } ?> |
183 | 183 | |
184 | - <li><input class="content" <?php $this->checked( $this->tour_options,'price' ); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price','wetu-importer' ); ?></li> |
|
185 | - <li><input class="content" <?php $this->checked( $this->tour_options,'duration' ); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration','wetu-importer' ); ?></li> |
|
184 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'wetu-importer'); ?></li> |
|
185 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'wetu-importer'); ?></li> |
|
186 | 186 | |
187 | - <li><input class="content" <?php $this->checked( $this->tour_options,'category' ); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category','wetu-importer' ); ?></li> |
|
187 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'wetu-importer'); ?></li> |
|
188 | 188 | |
189 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itineraries' ); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days','wetu-importer' ); ?></li> |
|
189 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'wetu-importer'); ?></li> |
|
190 | 190 | |
191 | 191 | <?php /*if(class_exists('LSX_TO_Maps')){ ?> |
192 | 192 | <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php esc_html_e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
@@ -194,33 +194,33 @@ discard block |
||
194 | 194 | </ul> |
195 | 195 | </div> |
196 | 196 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
197 | - <h3><?php esc_html_e( 'Itinerary Info' ); ?></h3> |
|
197 | + <h3><?php esc_html_e('Itinerary Info'); ?></h3> |
|
198 | 198 | <ul> |
199 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_description' ); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description','wetu-importer' ); ?></li> |
|
200 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_included' ); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included','wetu-importer' ); ?></li> |
|
201 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_excluded' ); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded','wetu-importer' ); ?></li> |
|
199 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li> |
|
200 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'wetu-importer'); ?></li> |
|
201 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'wetu-importer'); ?></li> |
|
202 | 202 | </ul> |
203 | 203 | |
204 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
204 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
205 | 205 | <ul> |
206 | - <li><input class="content" <?php $this->checked( $this->tour_options,'accommodation' ); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation','wetu-importer' ); ?></li> |
|
207 | - <li><input class="content" <?php $this->checked( $this->tour_options,'destination' ); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations','wetu-importer' ); ?></li> |
|
208 | - <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','wetu-importer' ); ?></li> |
|
209 | - <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','wetu-importer' ); ?></li> |
|
206 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
207 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'wetu-importer'); ?></li> |
|
208 | + <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', 'wetu-importer'); ?></li> |
|
209 | + <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', 'wetu-importer'); ?></li> |
|
210 | 210 | </ul> |
211 | 211 | </div> |
212 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
212 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
213 | 213 | <div style="width:30%;display:block;float:left;"> |
214 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
215 | - <?php $this->team_member_checkboxes( $this->tour_options ); ?> |
|
214 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
215 | + <?php $this->team_member_checkboxes($this->tour_options); ?> |
|
216 | 216 | </div> |
217 | 217 | <?php } ?> |
218 | 218 | |
219 | 219 | <br clear="both" /> |
220 | 220 | </div> |
221 | 221 | |
222 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
223 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','wetu-importer' ); ?>" /></p> |
|
222 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
223 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'wetu-importer'); ?>" /></p> |
|
224 | 224 | <table class="wp-list-table widefat fixed posts"> |
225 | 225 | <?php $this->table_header(); ?> |
226 | 226 | |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | |
233 | 233 | </table> |
234 | 234 | |
235 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','wetu-importer' ); ?>" /></p> |
|
235 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'wetu-importer'); ?>" /></p> |
|
236 | 236 | </form> |
237 | 237 | </div> |
238 | 238 | |
239 | 239 | <div style="display:none;" class="completed-list-wrapper"> |
240 | - <h3><?php esc_html_e( 'Completed', 'wetu-importer' ); ?> - <small><?php esc_html_e( 'Import your', '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','wetu-importer' ); ?></small></h3> |
|
240 | + <h3><?php esc_html_e('Completed', 'wetu-importer'); ?> - <small><?php esc_html_e('Import your', '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', 'wetu-importer'); ?></small></h3> |
|
241 | 241 | <ul> |
242 | 242 | </ul> |
243 | 243 | </div> |
@@ -249,46 +249,46 @@ discard block |
||
249 | 249 | * search_form |
250 | 250 | */ |
251 | 251 | public function update_options_form() { |
252 | - $tours = get_transient( 'lsx_ti_tours' ); |
|
252 | + $tours = get_transient('lsx_ti_tours'); |
|
253 | 253 | |
254 | - echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status','wetu-importer' ) . ' - '; |
|
254 | + echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').' - '; |
|
255 | 255 | |
256 | - if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) { |
|
256 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
257 | 257 | $result = $this->update_options(); |
258 | 258 | |
259 | - if ( true === $result ) { |
|
260 | - echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span>'; |
|
261 | - echo ' - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>'; |
|
262 | - } else { |
|
263 | - echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>'; |
|
259 | + if (true === $result) { |
|
260 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
261 | + echo ' - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
262 | + }else { |
|
263 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
264 | 264 | } |
265 | - } else { |
|
266 | - echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>'; |
|
265 | + }else { |
|
266 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | echo '</h3>'; |
270 | 270 | |
271 | - $form_options = get_option( 'lsx_ti_tours_api_options' ); |
|
272 | - if ( false === $form_options ) { |
|
273 | - $form_options = array( 0 ); |
|
271 | + $form_options = get_option('lsx_ti_tours_api_options'); |
|
272 | + if (false === $form_options) { |
|
273 | + $form_options = array(0); |
|
274 | 274 | } |
275 | 275 | ?> |
276 | - <form method="get" class="tour-refresh-form" action="<?php echo esc_attr( admin_url( 'admin.php' ) ); ?>"> |
|
277 | - <input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" /> |
|
276 | + <form method="get" class="tour-refresh-form" action="<?php echo esc_attr(admin_url('admin.php')); ?>"> |
|
277 | + <input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" /> |
|
278 | 278 | <input type="hidden" name="tab" value="tour" /> |
279 | 279 | <input type="hidden" name="refresh_tours" value="true" /> |
280 | 280 | |
281 | 281 | <p class="tour-search-options"> |
282 | - <label for="own"><input class="content" <?php if ( in_array( 'own',$form_options ) ) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e( 'Own Tours','wetu-importer' ); ?> </label> |
|
282 | + <label for="own"><input class="content" <?php if (in_array('own', $form_options)) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours', 'wetu-importer'); ?> </label> |
|
283 | 283 | </p> |
284 | 284 | |
285 | 285 | <p class="tour-search-options"> |
286 | - <label for="type"><input class="content" <?php if ( in_array( 'allitineraries',$form_options ) ) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php esc_html_e( 'All','wetu-importer' ); ?></label> |
|
287 | - <label for="type"><input class="content" <?php if ( in_array( 'sample',$form_options ) ) { echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php esc_html_e( 'Sample','wetu-importer' ); ?></label> |
|
288 | - <label for="type"><input class="content" <?php if ( in_array( 'personal',$form_options ) ) { echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php esc_html_e( 'Personal','wetu-importer' ); ?></label> |
|
286 | + <label for="type"><input class="content" <?php if (in_array('allitineraries', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php esc_html_e('All', 'wetu-importer'); ?></label> |
|
287 | + <label for="type"><input class="content" <?php if (in_array('sample', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php esc_html_e('Sample', 'wetu-importer'); ?></label> |
|
288 | + <label for="type"><input class="content" <?php if (in_array('personal', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php esc_html_e('Personal', 'wetu-importer'); ?></label> |
|
289 | 289 | </p> |
290 | 290 | |
291 | - <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr( 'Refresh Tours','wetu-importer' ); ?>"></p> |
|
291 | + <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours', 'wetu-importer'); ?>"></p> |
|
292 | 292 | </form> |
293 | 293 | <br /> |
294 | 294 | <?php |
@@ -302,30 +302,30 @@ discard block |
||
302 | 302 | $own = ''; |
303 | 303 | $options = array(); |
304 | 304 | |
305 | - delete_option( 'lsx_ti_tours_api_options' ); |
|
305 | + delete_option('lsx_ti_tours_api_options'); |
|
306 | 306 | |
307 | - if ( isset( $_GET['own'] ) ) { |
|
307 | + if (isset($_GET['own'])) { |
|
308 | 308 | $this->url_qs .= '&own=true'; |
309 | 309 | $options[] = 'own'; |
310 | 310 | } |
311 | 311 | |
312 | - if ( isset( $_GET['type'] ) ) { |
|
313 | - $this->url_qs .= '&type=' . implode( '',$_GET['type'] ); |
|
314 | - $options[] = implode( '',$_GET['type'] ); |
|
312 | + if (isset($_GET['type'])) { |
|
313 | + $this->url_qs .= '&type='.implode('', $_GET['type']); |
|
314 | + $options[] = implode('', $_GET['type']); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | $this->url_qs .= '&results=2000'; |
318 | 318 | |
319 | - add_option( 'lsx_ti_tours_api_options',$options ); |
|
319 | + add_option('lsx_ti_tours_api_options', $options); |
|
320 | 320 | |
321 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs ); |
|
321 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs); |
|
322 | 322 | |
323 | - $tours = json_decode( $data, true ); |
|
323 | + $tours = json_decode($data, true); |
|
324 | 324 | |
325 | - if ( isset( $tours['error'] ) ) { |
|
325 | + if (isset($tours['error'])) { |
|
326 | 326 | return $tours['error']; |
327 | - } elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) { |
|
328 | - set_transient( 'lsx_ti_tours',$tours['itineraries'],60 * 60 * 2 ); |
|
327 | + } elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
328 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
329 | 329 | return true; |
330 | 330 | } |
331 | 331 | } |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | LIMIT 0,500 |
351 | 351 | "); |
352 | 352 | |
353 | - if ( null !== $current_tours && ! empty( $current_tours ) ) { |
|
354 | - foreach ( $current_tours as $tour ) { |
|
355 | - $return[ $tour->meta_value ] = $tour; |
|
353 | + if (null !== $current_tours && !empty($current_tours)) { |
|
354 | + foreach ($current_tours as $tour) { |
|
355 | + $return[$tour->meta_value] = $tour; |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
@@ -366,47 +366,47 @@ discard block |
||
366 | 366 | $return = false; |
367 | 367 | |
368 | 368 | // @codingStandardsIgnoreLine |
369 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) { |
|
370 | - $tours = get_transient( 'lsx_ti_tours' ); |
|
369 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
370 | + $tours = get_transient('lsx_ti_tours'); |
|
371 | 371 | |
372 | - if ( false !== $tours ) { |
|
372 | + if (false !== $tours) { |
|
373 | 373 | |
374 | 374 | $searched_items = false; |
375 | 375 | |
376 | 376 | // @codingStandardsIgnoreLine |
377 | - if ( isset( $_POST['keyword'] ) ) { |
|
377 | + if (isset($_POST['keyword'])) { |
|
378 | 378 | // @codingStandardsIgnoreLine |
379 | 379 | $keyphrases = $_POST['keyword']; |
380 | - } else { |
|
381 | - $keyphrases = array( 0 ); |
|
380 | + }else { |
|
381 | + $keyphrases = array(0); |
|
382 | 382 | } |
383 | 383 | |
384 | - if ( ! is_array( $keyphrases ) ) { |
|
385 | - $keyphrases = array( $keyphrases ); |
|
384 | + if (!is_array($keyphrases)) { |
|
385 | + $keyphrases = array($keyphrases); |
|
386 | 386 | } |
387 | - foreach ( $keyphrases as &$keyword ) { |
|
388 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
387 | + foreach ($keyphrases as &$keyword) { |
|
388 | + $keyword = ltrim(rtrim($keyword)); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | $post_status = false; |
392 | - if ( in_array( 'publish',$keyphrases ) ) { |
|
392 | + if (in_array('publish', $keyphrases)) { |
|
393 | 393 | $post_status = 'publish'; |
394 | 394 | } |
395 | - if ( in_array( 'pending',$keyphrases ) ) { |
|
395 | + if (in_array('pending', $keyphrases)) { |
|
396 | 396 | $post_status = 'pending'; |
397 | 397 | } |
398 | - if ( in_array( 'draft',$keyphrases ) ) { |
|
398 | + if (in_array('draft', $keyphrases)) { |
|
399 | 399 | $post_status = 'draft'; |
400 | 400 | } |
401 | - if ( in_array( 'import',$keyphrases ) ) { |
|
401 | + if (in_array('import', $keyphrases)) { |
|
402 | 402 | $post_status = 'import'; |
403 | 403 | } |
404 | 404 | |
405 | - if ( ! empty( $tours ) ) { |
|
405 | + if (!empty($tours)) { |
|
406 | 406 | $current_tours = $this->find_current_tours(); |
407 | 407 | |
408 | - foreach ( $tours as $row_key => $row ) { |
|
409 | - if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) { |
|
408 | + foreach ($tours as $row_key => $row) { |
|
409 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
410 | 410 | continue; |
411 | 411 | } |
412 | 412 | |
@@ -417,56 +417,56 @@ discard block |
||
417 | 417 | //If this is a current tour, add its ID to the row. |
418 | 418 | $row['post_id'] = 0; |
419 | 419 | |
420 | - if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) { |
|
421 | - $row['post_id'] = $current_tours[ $row['identifier'] ]->post_id; |
|
420 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
421 | + $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | //If we are searching for |
425 | - if ( false !== $post_status ) { |
|
426 | - if ( 'import' === $post_status ) { |
|
425 | + if (false !== $post_status) { |
|
426 | + if ('import' === $post_status) { |
|
427 | 427 | |
428 | - if ( 0 !== $row['post_id'] ) { |
|
428 | + if (0 !== $row['post_id']) { |
|
429 | 429 | continue; |
430 | - } else { |
|
431 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
430 | + }else { |
|
431 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
432 | 432 | } |
433 | - } else { |
|
434 | - if ( 0 === $row['post_id'] ) { |
|
433 | + }else { |
|
434 | + if (0 === $row['post_id']) { |
|
435 | 435 | continue; |
436 | - } else { |
|
437 | - $current_status = get_post_status( $row['post_id'] ); |
|
436 | + }else { |
|
437 | + $current_status = get_post_status($row['post_id']); |
|
438 | 438 | |
439 | - if ( $current_status !== $post_status ) { |
|
439 | + if ($current_status !== $post_status) { |
|
440 | 440 | continue; |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
444 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
445 | 445 | } |
446 | - } else { |
|
446 | + }else { |
|
447 | 447 | //Search through each keyword. |
448 | - foreach ( $keyphrases as $keyphrase ) { |
|
448 | + foreach ($keyphrases as $keyphrase) { |
|
449 | 449 | |
450 | 450 | //Make sure the keyphrase is turned into an array |
451 | - $keywords = explode( ' ',$keyphrase ); |
|
452 | - if ( ! is_array( $keywords ) ) { |
|
453 | - $keywords = array( $keywords ); |
|
451 | + $keywords = explode(' ', $keyphrase); |
|
452 | + if (!is_array($keywords)) { |
|
453 | + $keywords = array($keywords); |
|
454 | 454 | } |
455 | 455 | |
456 | - if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) { |
|
457 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
456 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
457 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
464 | - if ( false !== $searched_items ) { |
|
465 | - ksort( $searched_items ); |
|
466 | - $return = implode( $searched_items ); |
|
464 | + if (false !== $searched_items) { |
|
465 | + ksort($searched_items); |
|
466 | + $return = implode($searched_items); |
|
467 | 467 | } |
468 | 468 | } |
469 | - print_r( $return ); |
|
469 | + print_r($return); |
|
470 | 470 | die(); |
471 | 471 | } |
472 | 472 | } |
@@ -474,28 +474,28 @@ discard block |
||
474 | 474 | /** |
475 | 475 | * Formats the row for output on the screen. |
476 | 476 | */ |
477 | - public function format_row( $row = false ) { |
|
478 | - if ( false !== $row ) { |
|
477 | + public function format_row($row = false) { |
|
478 | + if (false !== $row) { |
|
479 | 479 | $status = 'import'; |
480 | 480 | |
481 | - if ( 0 !== $row['post_id'] ) { |
|
482 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
481 | + if (0 !== $row['post_id']) { |
|
482 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | $row_html = ' |
486 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
486 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
487 | 487 | <th class="check-column" scope="row"> |
488 | - <label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
489 | - <input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '"> |
|
488 | + <label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
489 | + <input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'"> |
|
490 | 490 | </th> |
491 | 491 | <td class="post-title page-title column-title"> |
492 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
492 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
493 | 493 | </td> |
494 | 494 | <td class="date column-date"> |
495 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
495 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
496 | 496 | </td> |
497 | 497 | <td class="ssid column-ssid"> |
498 | - ' . $row['identifier'] . ' |
|
498 | + ' . $row['identifier'].' |
|
499 | 499 | </td> |
500 | 500 | </tr>'; |
501 | 501 | return $row_html; |
@@ -505,50 +505,50 @@ discard block |
||
505 | 505 | /** |
506 | 506 | * Connect to wetu |
507 | 507 | */ |
508 | - public function process_ajax_import( $force = false ) { |
|
508 | + public function process_ajax_import($force = false) { |
|
509 | 509 | $return = false; |
510 | 510 | |
511 | 511 | // @codingStandardsIgnoreLine |
512 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) { |
|
512 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
513 | 513 | |
514 | 514 | // @codingStandardsIgnoreLine |
515 | 515 | $wetu_id = $_POST['wetu_id']; |
516 | 516 | |
517 | 517 | // @codingStandardsIgnoreLine |
518 | - if ( isset( $_POST['post_id'] ) ) { |
|
518 | + if (isset($_POST['post_id'])) { |
|
519 | 519 | // @codingStandardsIgnoreLine |
520 | 520 | $post_id = $_POST['post_id']; |
521 | - } else { |
|
521 | + }else { |
|
522 | 522 | $post_id = 0; |
523 | 523 | } |
524 | 524 | |
525 | - delete_option( 'wetu_importer_tour_settings' ); |
|
525 | + delete_option('wetu_importer_tour_settings'); |
|
526 | 526 | |
527 | 527 | // @codingStandardsIgnoreLine |
528 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
528 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
529 | 529 | // @codingStandardsIgnoreLine |
530 | 530 | $content = $_POST['content']; |
531 | - add_option( 'wetu_importer_tour_settings',$content ); |
|
532 | - } else { |
|
531 | + add_option('wetu_importer_tour_settings', $content); |
|
532 | + }else { |
|
533 | 533 | $content = false; |
534 | 534 | } |
535 | 535 | |
536 | - $jdata = file_get_contents( 'http://wetu.com/API/Itinerary/V7/Get?id=' . $wetu_id ); |
|
536 | + $jdata = file_get_contents('http://wetu.com/API/Itinerary/V7/Get?id='.$wetu_id); |
|
537 | 537 | |
538 | - if ( $jdata ) { |
|
539 | - $jdata = json_decode( $jdata,true ); |
|
540 | - if ( ! empty( $jdata ) && ! isset( $jdata['error'] ) ) { |
|
541 | - $return = $this->import_row( $jdata,$wetu_id,$post_id,$content ); |
|
542 | - $this->format_completed_row( $return ); |
|
538 | + if ($jdata) { |
|
539 | + $jdata = json_decode($jdata, true); |
|
540 | + if (!empty($jdata) && !isset($jdata['error'])) { |
|
541 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
542 | + $this->format_completed_row($return); |
|
543 | 543 | $this->save_queue(); |
544 | 544 | $this->cleanup_posts(); |
545 | - $this->attach_destination_images( $content ); |
|
546 | - $this->clean_attached_destinations( $return ); |
|
547 | - } else { |
|
548 | - if ( isset( $adata['error'] ) ) { |
|
549 | - $this->format_error( $adata['error'] ); |
|
550 | - } else { |
|
551 | - $this->format_error( esc_html__( 'There was a problem importing your tour, please try refreshing the page.','wetu-importer' ) ); |
|
545 | + $this->attach_destination_images($content); |
|
546 | + $this->clean_attached_destinations($return); |
|
547 | + }else { |
|
548 | + if (isset($adata['error'])) { |
|
549 | + $this->format_error($adata['error']); |
|
550 | + }else { |
|
551 | + $this->format_error(esc_html__('There was a problem importing your tour, please try refreshing the page.', 'wetu-importer')); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | } |
@@ -561,13 +561,13 @@ discard block |
||
561 | 561 | * @param $id string |
562 | 562 | * @return void |
563 | 563 | */ |
564 | - public function clean_attached_destinations( $id ) { |
|
565 | - $current_connections = get_post_meta( $id, 'destination_to_tour', false ); |
|
566 | - delete_post_meta( $id,'destination_to_tour' ); |
|
567 | - $current_connections = array_unique( $current_connections ); |
|
564 | + public function clean_attached_destinations($id) { |
|
565 | + $current_connections = get_post_meta($id, 'destination_to_tour', false); |
|
566 | + delete_post_meta($id, 'destination_to_tour'); |
|
567 | + $current_connections = array_unique($current_connections); |
|
568 | 568 | |
569 | - foreach ( $current_connections as $connection ) { |
|
570 | - add_post_meta( $id, 'destination_to_tour',$connection, false ); |
|
569 | + foreach ($current_connections as $connection) { |
|
570 | + add_post_meta($id, 'destination_to_tour', $connection, false); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @param $data array |
578 | 578 | * @param $wetu_id string |
579 | 579 | */ |
580 | - public function import_row( $data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false ) { |
|
580 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
581 | 581 | $post_name = ''; |
582 | 582 | $data_post_content = ''; |
583 | 583 | $data_post_excerpt = ''; |
@@ -589,12 +589,12 @@ discard block |
||
589 | 589 | //Set the post_content |
590 | 590 | $content_used_general_description = false; |
591 | 591 | |
592 | - if ( false !== $importable_content && in_array( 'description',$importable_content ) ) { |
|
592 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
593 | 593 | $data_post_content = ''; |
594 | 594 | |
595 | - if ( isset( $data['description'] ) ) { |
|
595 | + if (isset($data['description'])) { |
|
596 | 596 | $data_post_content = $data['description']; |
597 | - } elseif ( isset( $data['summary'] ) ) { |
|
597 | + } elseif (isset($data['summary'])) { |
|
598 | 598 | $data_post_content = $data['summary']; |
599 | 599 | } |
600 | 600 | |
@@ -602,46 +602,46 @@ discard block |
||
602 | 602 | } |
603 | 603 | |
604 | 604 | //Create or update the post |
605 | - if ( false !== $id && '0' !== $id ) { |
|
605 | + if (false !== $id && '0' !== $id) { |
|
606 | 606 | $post['ID'] = $id; |
607 | 607 | $post['post_status'] = 'publish'; |
608 | - $id = wp_update_post( $post ); |
|
609 | - $prev_date = get_post_meta( $id,'lsx_wetu_modified_date',true ); |
|
610 | - update_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data['last_modified'] ),$prev_date ); |
|
611 | - } else { |
|
608 | + $id = wp_update_post($post); |
|
609 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
610 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
611 | + }else { |
|
612 | 612 | //Set the name |
613 | - if ( isset( $data['name'] ) ) { |
|
614 | - $post_name = wp_unique_post_slug( sanitize_title( $data['name'] ),$id, 'draft', 'tour', 0 ); |
|
613 | + if (isset($data['name'])) { |
|
614 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | $post['post_name'] = $post_name; |
618 | 618 | $post['post_title'] = $data['name']; |
619 | 619 | $post['post_status'] = 'publish'; |
620 | - $id = wp_insert_post( $post ); |
|
620 | + $id = wp_insert_post($post); |
|
621 | 621 | |
622 | 622 | //Save the WETU ID and the Last date it was modified. |
623 | - if ( false !== $id ) { |
|
624 | - add_post_meta( $id,'lsx_wetu_id',$wetu_id ); |
|
625 | - add_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data['last_modified'] ) ); |
|
623 | + if (false !== $id) { |
|
624 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
625 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 | |
629 | 629 | //Set the price |
630 | - if ( false !== $importable_content && in_array( 'price',$importable_content ) ) { |
|
631 | - $this->set_price( $data,$id ); |
|
630 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
631 | + $this->set_price($data, $id); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | //Set the Duration |
635 | - if ( false !== $importable_content && in_array( 'duration',$importable_content ) ) { |
|
636 | - $this->set_duration( $data,$id ); |
|
635 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
636 | + $this->set_duration($data, $id); |
|
637 | 637 | } |
638 | 638 | |
639 | - if ( false !== $importable_content && in_array( 'itineraries',$importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) { |
|
640 | - $this->process_itineraries( $data,$id,$importable_content ); |
|
639 | + if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
640 | + $this->process_itineraries($data, $id, $importable_content); |
|
641 | 641 | } |
642 | 642 | |
643 | - if ( in_array( 'map',$importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) { |
|
644 | - $this->set_map_data( $data,$id ); |
|
643 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
644 | + $this->set_map_data($data, $id); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | return $id; |
@@ -650,197 +650,197 @@ discard block |
||
650 | 650 | /** |
651 | 651 | * A loop which runs through each leg on the tour. |
652 | 652 | */ |
653 | - public function process_itineraries( $data, $id, $importable_content ) { |
|
653 | + public function process_itineraries($data, $id, $importable_content) { |
|
654 | 654 | $day_counter = 1; |
655 | 655 | $leg_counter = 0; |
656 | 656 | |
657 | - delete_post_meta( $id,'itinerary' ); |
|
657 | + delete_post_meta($id, 'itinerary'); |
|
658 | 658 | |
659 | - if ( false !== $importable_content && in_array( 'accommodation',$importable_content ) ) { |
|
660 | - delete_post_meta( $id,'accommodation_to_tour' ); |
|
659 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
660 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
661 | 661 | } |
662 | - if ( false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
662 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
663 | 663 | //delete_post_meta($id,'destination_to_tour'); |
664 | - delete_post_meta( $id,'departs_from' ); |
|
665 | - delete_post_meta( $id,'ends_in' ); |
|
664 | + delete_post_meta($id, 'departs_from'); |
|
665 | + delete_post_meta($id, 'ends_in'); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | $departs_from = false; |
669 | 669 | $ends_in = false; |
670 | 670 | |
671 | - foreach ( $data['legs'] as $leg ) { |
|
671 | + foreach ($data['legs'] as $leg) { |
|
672 | 672 | //Itinerary Accommodation |
673 | 673 | $current_accommodation = false; |
674 | - if ( false !== $importable_content && in_array( 'accommodation',$importable_content ) ) { |
|
675 | - $current_accommodation = $this->set_accommodation( $leg,$id ); |
|
674 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
675 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | //Itinerary Destination |
679 | 679 | $current_destination = false; |
680 | - if ( false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
681 | - $current_destination = $this->set_destination( $leg,$id,$leg_counter ); |
|
680 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
681 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
685 | - if ( ((1 <= (int) $leg['nights'] && isset( $leg['days'] ))) || 0 === $leg['itinerary_leg_id'] ) { |
|
686 | - foreach ( $leg['days'] as $day ) { |
|
685 | + if (((1 <= (int) $leg['nights'] && isset($leg['days']))) || 0 === $leg['itinerary_leg_id']) { |
|
686 | + foreach ($leg['days'] as $day) { |
|
687 | 687 | $current_day = array(); |
688 | - $current_day['title'] = esc_attr( 'Day ', 'wetu-importer' ) . $day_counter; |
|
688 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
689 | 689 | |
690 | 690 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
691 | 691 | |
692 | 692 | //Description |
693 | - if ( false !== $importable_content && in_array( 'itinerary_description',$importable_content ) && isset( $day['notes'] ) ) { |
|
693 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
694 | 694 | $current_day['description'] = $day['notes']; |
695 | - } else { |
|
695 | + }else { |
|
696 | 696 | $current_day['description'] = ''; |
697 | 697 | } |
698 | 698 | |
699 | 699 | //Itinerary Gallery |
700 | - if ( false !== $importable_content && in_array( 'itinerary_gallery',$importable_content ) && isset( $day['images'] ) ) { |
|
700 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
701 | 701 | $current_day['featured_image'] = ''; |
702 | - } else { |
|
702 | + }else { |
|
703 | 703 | $current_day['featured_image'] = ''; |
704 | 704 | } |
705 | 705 | |
706 | 706 | //Accommodation |
707 | - if ( false !== $current_accommodation ) { |
|
708 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
709 | - } else { |
|
707 | + if (false !== $current_accommodation) { |
|
708 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
709 | + }else { |
|
710 | 710 | $current_day['accommodation_to_tour'] = array(); |
711 | 711 | } |
712 | 712 | |
713 | 713 | //Destination |
714 | - if ( false !== $current_destination ) { |
|
715 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
716 | - } else { |
|
714 | + if (false !== $current_destination) { |
|
715 | + $current_day['destination_to_tour'] = array($current_destination); |
|
716 | + }else { |
|
717 | 717 | $current_day['destination_to_tour'] = array(); |
718 | 718 | } |
719 | 719 | |
720 | 720 | //Included |
721 | - if ( false !== $importable_content && in_array( 'itinerary_included',$importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) { |
|
721 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
722 | 722 | $current_day['included'] = $day['included']; |
723 | - } else { |
|
723 | + }else { |
|
724 | 724 | $current_day['included'] = ''; |
725 | 725 | } |
726 | 726 | |
727 | 727 | //Excluded |
728 | - if ( false !== $importable_content && in_array( 'itinerary_excluded',$importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) { |
|
728 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
729 | 729 | $current_day['excluded'] = $day['excluded']; |
730 | - } else { |
|
730 | + }else { |
|
731 | 731 | $current_day['excluded'] = ''; |
732 | 732 | } |
733 | 733 | |
734 | - $this->set_itinerary_day( $current_day,$id ); |
|
734 | + $this->set_itinerary_day($current_day, $id); |
|
735 | 735 | $day_counter++; |
736 | 736 | } |
737 | - } else { |
|
737 | + }else { |
|
738 | 738 | // This is for the by destination |
739 | 739 | |
740 | 740 | $current_day = array(); |
741 | 741 | $next_day_count = $day_counter + (int) $leg['nights']; |
742 | - $day_count_label = $next_day_count -1; |
|
742 | + $day_count_label = $next_day_count - 1; |
|
743 | 743 | |
744 | - $current_day['title'] = esc_attr( 'Day ','wetu-importer' ) . $day_counter; |
|
744 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
745 | 745 | |
746 | - if ( 0 !== (int) $leg['nights'] ) { |
|
747 | - $current_day['title'] .= ' - ' . $day_count_label; |
|
746 | + if (0 !== (int) $leg['nights']) { |
|
747 | + $current_day['title'] .= ' - '.$day_count_label; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | //Description |
751 | - if ( false !== $importable_content && in_array( 'itinerary_description',$importable_content ) && isset( $leg['notes'] ) ) { |
|
751 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) { |
|
752 | 752 | $current_day['description'] = $leg['notes']; |
753 | - } else { |
|
753 | + }else { |
|
754 | 754 | $current_day['description'] = ''; |
755 | 755 | } |
756 | 756 | |
757 | 757 | //Itinerary Gallery |
758 | - if ( false !== $importable_content && in_array( 'itinerary_gallery',$importable_content ) && isset( $leg['images'] ) ) { |
|
758 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) { |
|
759 | 759 | $current_day['featured_image'] = ''; |
760 | - } else { |
|
760 | + }else { |
|
761 | 761 | $current_day['featured_image'] = ''; |
762 | 762 | } |
763 | 763 | |
764 | 764 | //Accommodation |
765 | - if ( false !== $current_accommodation ) { |
|
766 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
767 | - } else { |
|
765 | + if (false !== $current_accommodation) { |
|
766 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
767 | + }else { |
|
768 | 768 | $current_day['accommodation_to_tour'] = array(); |
769 | 769 | } |
770 | 770 | |
771 | 771 | //Destination |
772 | - if ( false !== $current_destination ) { |
|
773 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
774 | - } else { |
|
772 | + if (false !== $current_destination) { |
|
773 | + $current_day['destination_to_tour'] = array($current_destination); |
|
774 | + }else { |
|
775 | 775 | $current_day['destination_to_tour'] = array(); |
776 | 776 | } |
777 | 777 | |
778 | 778 | //Included |
779 | - if ( false !== $importable_content && in_array( 'itinerary_included',$importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) { |
|
779 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) { |
|
780 | 780 | $current_day['included'] = $leg['included']; |
781 | - } else { |
|
781 | + }else { |
|
782 | 782 | $current_day['included'] = ''; |
783 | 783 | } |
784 | 784 | |
785 | 785 | //Excluded |
786 | - if ( false !== $importable_content && in_array( 'itinerary_excluded',$importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) { |
|
786 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) { |
|
787 | 787 | $current_day['excluded'] = $leg['excluded']; |
788 | - } else { |
|
788 | + }else { |
|
789 | 789 | $current_day['excluded'] = ''; |
790 | 790 | } |
791 | 791 | |
792 | - $this->set_itinerary_day( $current_day,$id ); |
|
792 | + $this->set_itinerary_day($current_day, $id); |
|
793 | 793 | $day_counter = $next_day_count; |
794 | 794 | } |
795 | 795 | |
796 | 796 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
797 | - if ( 0 === $leg_counter && false !== $current_destination ) { |
|
797 | + if (0 === $leg_counter && false !== $current_destination) { |
|
798 | 798 | $departs_from = $current_destination; |
799 | 799 | } |
800 | 800 | |
801 | 801 | //If its the last leg then save it as the ends in. |
802 | 802 | // @codingStandardsIgnoreLine |
803 | - if ( $leg_counter === (count( $data['legs'] ) -2) && false !== $current_destination ) { |
|
803 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
804 | 804 | $ends_in = $current_destination; |
805 | 805 | } |
806 | 806 | |
807 | 807 | $leg_counter++; |
808 | 808 | } |
809 | 809 | |
810 | - if ( false !== $departs_from ) { |
|
811 | - add_post_meta( $id,'departs_from',$departs_from,true ); |
|
810 | + if (false !== $departs_from) { |
|
811 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
812 | 812 | } |
813 | - if ( false !== $ends_in ) { |
|
814 | - add_post_meta( $id,'ends_in',$ends_in,true ); |
|
813 | + if (false !== $ends_in) { |
|
814 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
818 | 818 | /** |
819 | 819 | * Run through your routes and save the points as a KML file. |
820 | 820 | */ |
821 | - public function set_map_data( $data, $id, $zoom = 9 ) { |
|
822 | - if ( ! empty( $data['routes'] ) ) { |
|
823 | - delete_post_meta( $id,'wetu_map_points' ); |
|
821 | + public function set_map_data($data, $id, $zoom = 9) { |
|
822 | + if (!empty($data['routes'])) { |
|
823 | + delete_post_meta($id, 'wetu_map_points'); |
|
824 | 824 | |
825 | 825 | $points = array(); |
826 | 826 | |
827 | - foreach ( $data['routes'] as $route ) { |
|
827 | + foreach ($data['routes'] as $route) { |
|
828 | 828 | |
829 | - if ( isset( $route['points'] ) && '' !== $route['points'] ) { |
|
829 | + if (isset($route['points']) && '' !== $route['points']) { |
|
830 | 830 | |
831 | - $temp_points = explode( ';',$route['points'] ); |
|
832 | - $point_counter = count( $temp_points ); |
|
831 | + $temp_points = explode(';', $route['points']); |
|
832 | + $point_counter = count($temp_points); |
|
833 | 833 | |
834 | - for ( $x = 0; $x <= $point_counter; $x++ ) { |
|
834 | + for ($x = 0; $x <= $point_counter; $x++) { |
|
835 | 835 | $y = $x + 1; |
836 | - $points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ]; |
|
836 | + $points[] = $temp_points[$x].','.$temp_points[$y]; |
|
837 | 837 | $x++; |
838 | 838 | } |
839 | 839 | } |
840 | 840 | } |
841 | 841 | |
842 | - if ( ! empty( $points ) ) { |
|
843 | - $this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true ); |
|
842 | + if (!empty($points)) { |
|
843 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
@@ -851,66 +851,66 @@ discard block |
||
851 | 851 | /** |
852 | 852 | * Set the Itinerary Day |
853 | 853 | */ |
854 | - public function set_itinerary_day( $day, $id ) { |
|
855 | - $this->save_custom_field( $day,'itinerary',$id,false,false ); |
|
854 | + public function set_itinerary_day($day, $id) { |
|
855 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
859 | 859 | * Set the price |
860 | 860 | */ |
861 | - public function set_price( $data, $id ) { |
|
861 | + public function set_price($data, $id) { |
|
862 | 862 | //Price |
863 | - if ( isset( $data['price'] ) && '' !== $data['price'] ) { |
|
864 | - $price = preg_replace( '/[^0-9,.]/', '', $data['price'] ); |
|
865 | - $this->save_custom_field( $price,'price',$id ); |
|
863 | + if (isset($data['price']) && '' !== $data['price']) { |
|
864 | + $price = preg_replace('/[^0-9,.]/', '', $data['price']); |
|
865 | + $this->save_custom_field($price, 'price', $id); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | //Price includes |
869 | - if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) { |
|
870 | - $this->save_custom_field( $data['price_includes'],'included',$id ); |
|
869 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
870 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | //Price Excludes |
874 | - if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) { |
|
875 | - $this->save_custom_field( $data['price_excludes'],'not_included',$id ); |
|
874 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
875 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
876 | 876 | } |
877 | 877 | } |
878 | 878 | |
879 | 879 | /** |
880 | 880 | * Set the duration |
881 | 881 | */ |
882 | - public function set_duration( $data, $id ) { |
|
883 | - if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) { |
|
882 | + public function set_duration($data, $id) { |
|
883 | + if (isset($data['days']) && !empty($data['days'])) { |
|
884 | 884 | $price = $data['days']; |
885 | - $price = preg_replace( '/[^0-9,.]/', '', $price ); |
|
886 | - $this->save_custom_field( $price,'duration',$id ); |
|
885 | + $price = preg_replace('/[^0-9,.]/', '', $price); |
|
886 | + $this->save_custom_field($price, 'duration', $id); |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
891 | 891 | * Connects the Accommodation if its available |
892 | 892 | */ |
893 | - public function set_accommodation( $day, $id ) { |
|
893 | + public function set_accommodation($day, $id) { |
|
894 | 894 | $ac_id = false; |
895 | 895 | $this->current_accommodation = $this->find_current_accommodation(); |
896 | 896 | |
897 | - if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) { |
|
898 | - if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) { |
|
899 | - $ac_id = $this->current_accommodation[ $day['content_entity_id'] ]; |
|
900 | - } else { |
|
897 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
898 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
899 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
900 | + }else { |
|
901 | 901 | $ac_id = wp_insert_post(array( |
902 | 902 | 'post_type' => 'accommodation', |
903 | 903 | 'post_status' => 'draft', |
904 | 904 | 'post_title' => $day['content_entity_id'], |
905 | 905 | )); |
906 | 906 | |
907 | - $this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id ); |
|
907 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
908 | 908 | } |
909 | 909 | |
910 | - if ( '' !== $ac_id && false !== $ac_id ) { |
|
911 | - $this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false ); |
|
912 | - $this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false ); |
|
913 | - $this->queue_item( $ac_id ); |
|
910 | + if ('' !== $ac_id && false !== $ac_id) { |
|
911 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
912 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
913 | + $this->queue_item($ac_id); |
|
914 | 914 | } |
915 | 915 | } |
916 | 916 | return $ac_id; |
@@ -922,14 +922,14 @@ discard block |
||
922 | 922 | * @param $post_type string |
923 | 923 | * @return boolean / array |
924 | 924 | */ |
925 | - public function find_current_accommodation( $post_type = 'accommodation' ) { |
|
925 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
926 | 926 | global $wpdb; |
927 | - $accommodation = parent::find_current_accommodation( $post_type ); |
|
927 | + $accommodation = parent::find_current_accommodation($post_type); |
|
928 | 928 | $return = false; |
929 | 929 | |
930 | - if ( ! empty( $accommodation ) ) { |
|
931 | - foreach ( $accommodation as $key => $acc ) { |
|
932 | - $return[ $acc->meta_value ] = $acc->post_id; |
|
930 | + if (!empty($accommodation)) { |
|
931 | + foreach ($accommodation as $key => $acc) { |
|
932 | + $return[$acc->meta_value] = $acc->post_id; |
|
933 | 933 | } |
934 | 934 | } |
935 | 935 | |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | * @return boolean / array |
942 | 942 | */ |
943 | 943 | public function find_current_destinations() { |
944 | - return $this->find_current_accommodation( 'destination' ); |
|
944 | + return $this->find_current_accommodation('destination'); |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | /** |
@@ -951,42 +951,42 @@ discard block |
||
951 | 951 | * @param $id string |
952 | 952 | * @return boolean / string |
953 | 953 | */ |
954 | - public function set_destination( $day, $id, $leg_counter ) { |
|
954 | + public function set_destination($day, $id, $leg_counter) { |
|
955 | 955 | $dest_id = false; |
956 | 956 | $country_id = false; |
957 | 957 | $this->current_destinations = $this->find_current_destinations(); |
958 | 958 | |
959 | - if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) { |
|
960 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'],$this->current_destinations ) ) { |
|
961 | - $dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ]; |
|
959 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
960 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
961 | + $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
|
962 | 962 | |
963 | 963 | //TODO Check for attachments here. |
964 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
964 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
965 | 965 | |
966 | 966 | //Check if there is a country asigned. |
967 | - $potential_id = wp_get_post_parent_id( $dest_id ); |
|
968 | - $country_wetu_id = get_post_meta( $potential_id,'lsx_wetu_id',true ); |
|
967 | + $potential_id = wp_get_post_parent_id($dest_id); |
|
968 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
969 | 969 | |
970 | - if ( false !== $country_wetu_id ) { |
|
971 | - $country_id = $this->set_country( $country_wetu_id, $id ); |
|
970 | + if (false !== $country_wetu_id) { |
|
971 | + $country_id = $this->set_country($country_wetu_id, $id); |
|
972 | 972 | } |
973 | - } else { |
|
974 | - $destination_json = file_get_contents( 'http://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] ); |
|
973 | + }else { |
|
974 | + $destination_json = file_get_contents('http://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']); |
|
975 | 975 | |
976 | - if ( $destination_json ) { |
|
977 | - $destination_data = json_decode( $destination_json, true ); |
|
976 | + if ($destination_json) { |
|
977 | + $destination_data = json_decode($destination_json, true); |
|
978 | 978 | |
979 | - if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) { |
|
979 | + if (!empty($destination_data) && !isset($destination_data['error'])) { |
|
980 | 980 | $destination_title = $day['destination_content_entity_id']; |
981 | 981 | |
982 | - if ( isset( $destination_data[0]['name'] ) ) { |
|
982 | + if (isset($destination_data[0]['name'])) { |
|
983 | 983 | $destination_title = $destination_data[0]['name']; |
984 | 984 | } |
985 | 985 | |
986 | - if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] ) |
|
987 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) { |
|
986 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
987 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
988 | 988 | |
989 | - $country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id ); |
|
989 | + $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
|
990 | 990 | // Save the destination so we can grab the tour featured image and banner from them |
991 | 991 | } |
992 | 992 | |
@@ -996,40 +996,40 @@ discard block |
||
996 | 996 | 'post_title' => $destination_title, |
997 | 997 | ); |
998 | 998 | |
999 | - if ( false !== $country_id ) { |
|
999 | + if (false !== $country_id) { |
|
1000 | 1000 | $dest_post['post_parent'] = $country_id; |
1001 | 1001 | } |
1002 | - $dest_id = wp_insert_post( $dest_post ); |
|
1002 | + $dest_id = wp_insert_post($dest_post); |
|
1003 | 1003 | |
1004 | 1004 | //Make sure we register the |
1005 | - $this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id; |
|
1005 | + $this->current_destinations[$day['destination_content_entity_id']] = $dest_id; |
|
1006 | 1006 | |
1007 | 1007 | //If there are images attached then use the destination |
1008 | - if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) { |
|
1009 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
1008 | + if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) { |
|
1009 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | - $this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id ); |
|
1012 | + $this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id); |
|
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( '' !== $dest_id && false !== $dest_id ) { |
|
1018 | - $this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false ); |
|
1019 | - $this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false ); |
|
1017 | + if ('' !== $dest_id && false !== $dest_id) { |
|
1018 | + $this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false); |
|
1019 | + $this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false); |
|
1020 | 1020 | |
1021 | 1021 | //Save the item to display in the queue |
1022 | - $this->queue_item( $dest_id ); |
|
1022 | + $this->queue_item($dest_id); |
|
1023 | 1023 | |
1024 | 1024 | //Save the item to clean up the amount of connections. |
1025 | - $this->cleanup_posts[ $dest_id ] = 'tour_to_destination'; |
|
1025 | + $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
|
1026 | 1026 | |
1027 | 1027 | //Add this relation info so we can make sure certain items are set as countries. |
1028 | - if ( 0 !== $country_id && false !== $country_id ) { |
|
1029 | - $this->relation_meta[ $dest_id ] = $country_id; |
|
1030 | - $this->relation_meta[ $country_id ] = 0; |
|
1031 | - } else { |
|
1032 | - $this->relation_meta[ $dest_id ] = 0; |
|
1028 | + if (0 !== $country_id && false !== $country_id) { |
|
1029 | + $this->relation_meta[$dest_id] = $country_id; |
|
1030 | + $this->relation_meta[$country_id] = 0; |
|
1031 | + }else { |
|
1032 | + $this->relation_meta[$dest_id] = 0; |
|
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1045,25 +1045,25 @@ discard block |
||
1045 | 1045 | * |
1046 | 1046 | * @return string |
1047 | 1047 | */ |
1048 | - public function set_country( $country_wetu_id, $id ) { |
|
1048 | + public function set_country($country_wetu_id, $id) { |
|
1049 | 1049 | $country_id = false; |
1050 | 1050 | $this->current_destinations = $this->find_current_destinations(); |
1051 | 1051 | |
1052 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) { |
|
1053 | - $country_id = $this->current_destinations[ $country_wetu_id ]; |
|
1054 | - $this->destination_images[ $id ][] = array( $country_id, $country_wetu_id ); |
|
1055 | - } else { |
|
1056 | - $country_json = file_get_contents( 'http://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id ); |
|
1052 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
1053 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
1054 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
1055 | + }else { |
|
1056 | + $country_json = file_get_contents('http://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id); |
|
1057 | 1057 | |
1058 | - if ( $country_json ) { |
|
1059 | - $country_data = json_decode( $country_json, true ); |
|
1058 | + if ($country_json) { |
|
1059 | + $country_data = json_decode($country_json, true); |
|
1060 | 1060 | |
1061 | - if ( ! empty( $country_data ) && ! isset( $country_data['error'] ) ) { |
|
1061 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
1062 | 1062 | |
1063 | 1063 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
1064 | 1064 | $country_title = $country_wetu_id; |
1065 | 1065 | |
1066 | - if ( isset( $country_data[0]['name'] ) ) { |
|
1066 | + if (isset($country_data[0]['name'])) { |
|
1067 | 1067 | $country_title = $country_data[0]['name']; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1074,24 +1074,24 @@ discard block |
||
1074 | 1074 | )); |
1075 | 1075 | |
1076 | 1076 | //add the country to the current destination stack |
1077 | - $this->current_destinations[ $country_wetu_id ] = $country_id; |
|
1077 | + $this->current_destinations[$country_wetu_id] = $country_id; |
|
1078 | 1078 | |
1079 | 1079 | // Check if there are images and save fore use later. |
1080 | - if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) { |
|
1081 | - $this->destination_images[ $id ][] = array( $country_id,$country_wetu_id ); |
|
1080 | + if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) { |
|
1081 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | //Save the wetu field |
1085 | - $this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id ); |
|
1085 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
1086 | 1086 | } |
1087 | 1087 | } |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - if ( '' !== $country_id && false !== $country_id ) { |
|
1091 | - $this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false ); |
|
1092 | - $this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false ); |
|
1093 | - $this->queue_item( $country_id ); |
|
1094 | - $this->cleanup_posts[ $country_id ] = 'tour_to_destination'; |
|
1090 | + if ('' !== $country_id && false !== $country_id) { |
|
1091 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
1092 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
1093 | + $this->queue_item($country_id); |
|
1094 | + $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
|
1095 | 1095 | |
1096 | 1096 | return $country_id; |
1097 | 1097 | } |
@@ -1106,12 +1106,12 @@ discard block |
||
1106 | 1106 | * |
1107 | 1107 | * @return string |
1108 | 1108 | */ |
1109 | - public function attach_destination_images( $importable_content = array() ) { |
|
1110 | - if ( false !== $this->destination_images ) { |
|
1111 | - $this->shuffle_assoc( $this->destination_images ); |
|
1109 | + public function attach_destination_images($importable_content = array()) { |
|
1110 | + if (false !== $this->destination_images) { |
|
1111 | + $this->shuffle_assoc($this->destination_images); |
|
1112 | 1112 | |
1113 | - foreach ( $this->destination_images as $tour => $destinations ) { |
|
1114 | - $this->shuffle_assoc( $destinations ); |
|
1113 | + foreach ($this->destination_images as $tour => $destinations) { |
|
1114 | + $this->shuffle_assoc($destinations); |
|
1115 | 1115 | |
1116 | 1116 | /*print_r('<pre>'); |
1117 | 1117 | print_r( $tour ); |
@@ -1121,33 +1121,33 @@ discard block |
||
1121 | 1121 | $image_set = false; |
1122 | 1122 | $forced = false; |
1123 | 1123 | |
1124 | - foreach ( $destinations as $destination ) { |
|
1125 | - if ( false === $image_set && false === $forced ) { |
|
1126 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
1124 | + foreach ($destinations as $destination) { |
|
1125 | + if (false === $image_set && false === $forced) { |
|
1126 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
1127 | 1127 | $url_qs = ''; |
1128 | 1128 | |
1129 | - $jdata = file_get_contents( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] ); |
|
1129 | + $jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
1130 | 1130 | |
1131 | - if ( $jdata ) { |
|
1132 | - $adata = json_decode( $jdata, true ); |
|
1131 | + if ($jdata) { |
|
1132 | + $adata = json_decode($jdata, true); |
|
1133 | 1133 | |
1134 | - if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) { |
|
1135 | - $this->find_attachments( $destination[0] ); |
|
1134 | + if (!empty($adata) && !empty($adata[0]['content']['images'])) { |
|
1135 | + $this->find_attachments($destination[0]); |
|
1136 | 1136 | |
1137 | 1137 | //Set the featured image |
1138 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
1139 | - $image_set = $this->set_featured_image( $adata, $tour ); |
|
1140 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
1138 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
1139 | + $image_set = $this->set_featured_image($adata, $tour); |
|
1140 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
1141 | 1141 | $forced = true; |
1142 | 1142 | } |
1143 | 1143 | continue; |
1144 | 1144 | } |
1145 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
1146 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
1145 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
1146 | + $image_set = $this->set_banner_image($adata, $tour); |
|
1147 | 1147 | } |
1148 | 1148 | } |
1149 | 1149 | } |
1150 | - } else { |
|
1150 | + }else { |
|
1151 | 1151 | continue; |
1152 | 1152 | } |
1153 | 1153 | } |
@@ -1158,28 +1158,28 @@ discard block |
||
1158 | 1158 | /** |
1159 | 1159 | * Creates the main gallery data |
1160 | 1160 | */ |
1161 | - public function set_featured_image( $data, $id ) { |
|
1161 | + public function set_featured_image($data, $id) { |
|
1162 | 1162 | $image_set = false; |
1163 | 1163 | $counter = 0; |
1164 | 1164 | |
1165 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
1166 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
1165 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1166 | + foreach ($data[0]['content']['images'] as $v) { |
|
1167 | 1167 | /*print_r('<pre>'); |
1168 | 1168 | print_r( $v ); |
1169 | 1169 | print_r('</pre>');*/ |
1170 | 1170 | |
1171 | - if ( true === $image_set || 0 === $counter ) { |
|
1171 | + if (true === $image_set || 0 === $counter) { |
|
1172 | 1172 | $counter++; |
1173 | 1173 | continue; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
1177 | - $temp_featured_image = $this->attach_image( $v , $id ); |
|
1176 | + if (!$this->check_if_image_is_used($v)) { |
|
1177 | + $temp_featured_image = $this->attach_image($v, $id); |
|
1178 | 1178 | |
1179 | - if ( false !== $temp_featured_image ) { |
|
1179 | + if (false !== $temp_featured_image) { |
|
1180 | 1180 | $this->featured_image = $temp_featured_image; |
1181 | - delete_post_meta( $id, '_thumbnail_id' ); |
|
1182 | - add_post_meta( $id, '_thumbnail_id', $this->featured_image, true ); |
|
1181 | + delete_post_meta($id, '_thumbnail_id'); |
|
1182 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
1183 | 1183 | $image_set = true; |
1184 | 1184 | } |
1185 | 1185 | } |
@@ -1193,40 +1193,40 @@ discard block |
||
1193 | 1193 | /** |
1194 | 1194 | * Sets a banner image |
1195 | 1195 | */ |
1196 | - public function set_banner_image( $data, $id ) { |
|
1196 | + public function set_banner_image($data, $id) { |
|
1197 | 1197 | $image_set = false; |
1198 | 1198 | $counter = 0; |
1199 | 1199 | |
1200 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
1200 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1201 | 1201 | |
1202 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
1202 | + foreach ($data[0]['content']['images'] as $v) { |
|
1203 | 1203 | /*print_r('<pre>'); |
1204 | 1204 | print_r( $v ); |
1205 | 1205 | print_r('</pre>');*/ |
1206 | 1206 | |
1207 | - if ( true === $image_set || 0 === $counter ) { |
|
1207 | + if (true === $image_set || 0 === $counter) { |
|
1208 | 1208 | $counter++; |
1209 | 1209 | continue; |
1210 | 1210 | } |
1211 | 1211 | |
1212 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
1213 | - $temp_banner = $this->attach_image( $v, $id, array( |
|
1212 | + if (!$this->check_if_image_is_used($v)) { |
|
1213 | + $temp_banner = $this->attach_image($v, $id, array( |
|
1214 | 1214 | 'width' => '1920', |
1215 | 1215 | 'height' => '600', |
1216 | 1216 | 'cropping' => 'c', |
1217 | - ) ); |
|
1217 | + )); |
|
1218 | 1218 | |
1219 | - if ( false !== $temp_banner ) { |
|
1219 | + if (false !== $temp_banner) { |
|
1220 | 1220 | $this->banner_image = $temp_banner; |
1221 | 1221 | |
1222 | - delete_post_meta( $id,'image_group' ); |
|
1222 | + delete_post_meta($id, 'image_group'); |
|
1223 | 1223 | |
1224 | 1224 | $new_banner = array( |
1225 | 1225 | 'banner_image' => array( |
1226 | 1226 | 'cmb-field-0' => $this->banner_image, |
1227 | 1227 | ), |
1228 | 1228 | ); |
1229 | - add_post_meta( $id,'image_group',$new_banner,true ); |
|
1229 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
1230 | 1230 | $image_set = true; |
1231 | 1231 | } |
1232 | 1232 | } |
@@ -1240,18 +1240,18 @@ discard block |
||
1240 | 1240 | /** |
1241 | 1241 | * Grabs all of the current used featured images on the site. |
1242 | 1242 | */ |
1243 | - public function check_if_image_is_used( $v ) { |
|
1243 | + public function check_if_image_is_used($v) { |
|
1244 | 1244 | global $wpdb; |
1245 | 1245 | |
1246 | - $temp_fragment = explode( '/',$v['url_fragment'] ); |
|
1247 | - $url_filename = $temp_fragment[ count( $temp_fragment ) -1 ]; |
|
1248 | - $url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename ); |
|
1249 | - $url_filename = trim( $url_filename ); |
|
1250 | - $url_filename = str_replace( ' ','_',$url_filename ); |
|
1246 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
1247 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
1248 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
1249 | + $url_filename = trim($url_filename); |
|
1250 | + $url_filename = str_replace(' ', '_', $url_filename); |
|
1251 | 1251 | |
1252 | - if ( in_array( $url_filename,$this->found_attachments ) ) { |
|
1252 | + if (in_array($url_filename, $this->found_attachments)) { |
|
1253 | 1253 | //check to see if there is a featured image set with this ID. |
1254 | - $found_id = array_search( $url_filename,$this->found_attachments ); |
|
1254 | + $found_id = array_search($url_filename, $this->found_attachments); |
|
1255 | 1255 | |
1256 | 1256 | $querystring = " |
1257 | 1257 | SELECT post_id |
@@ -1260,22 +1260,22 @@ discard block |
||
1260 | 1260 | AND meta_key = '_thumbnail_id' |
1261 | 1261 | "; |
1262 | 1262 | // @codingStandardsIgnoreLine |
1263 | - $results = $wpdb->get_results( $querystring ); |
|
1263 | + $results = $wpdb->get_results($querystring); |
|
1264 | 1264 | |
1265 | - if ( ! empty( $results ) ) { |
|
1265 | + if (!empty($results)) { |
|
1266 | 1266 | return true; |
1267 | - } else { |
|
1267 | + }else { |
|
1268 | 1268 | return false; |
1269 | 1269 | } |
1270 | - } else { |
|
1270 | + }else { |
|
1271 | 1271 | $querystring = " |
1272 | 1272 | SELECT ID |
1273 | 1273 | FROM {$wpdb->posts} |
1274 | 1274 | WHERE post_name = '{$url_filename}' |
1275 | 1275 | "; |
1276 | 1276 | // @codingStandardsIgnoreLine |
1277 | - $results = $wpdb->get_results( $querystring ); |
|
1278 | - if ( ! empty( $results ) ) { |
|
1277 | + $results = $wpdb->get_results($querystring); |
|
1278 | + if (!empty($results)) { |
|
1279 | 1279 | $querystring = " |
1280 | 1280 | SELECT post_id |
1281 | 1281 | FROM {$wpdb->postmeta} |
@@ -1283,13 +1283,13 @@ discard block |
||
1283 | 1283 | AND meta_key = '_thumbnail_id' |
1284 | 1284 | "; |
1285 | 1285 | // @codingStandardsIgnoreLine |
1286 | - $results = $wpdb->get_results( $querystring ); |
|
1287 | - if ( ! empty( $results ) ) { |
|
1286 | + $results = $wpdb->get_results($querystring); |
|
1287 | + if (!empty($results)) { |
|
1288 | 1288 | return true; |
1289 | - } else { |
|
1289 | + }else { |
|
1290 | 1290 | return false; |
1291 | 1291 | } |
1292 | - } else { |
|
1292 | + }else { |
|
1293 | 1293 | return false; |
1294 | 1294 | } |
1295 | 1295 | } |
@@ -1300,10 +1300,10 @@ discard block |
||
1300 | 1300 | * |
1301 | 1301 | * @param $id int |
1302 | 1302 | */ |
1303 | - public function queue_item( $id ) { |
|
1304 | - if ( is_array( $this->import_queue ) && ! in_array( $id,$this->import_queue ) ) { |
|
1303 | + public function queue_item($id) { |
|
1304 | + if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) { |
|
1305 | 1305 | $this->import_queue[] = $id; |
1306 | - } else { |
|
1306 | + }else { |
|
1307 | 1307 | $this->import_queue[] = $id; |
1308 | 1308 | } |
1309 | 1309 | } |
@@ -1312,18 +1312,18 @@ discard block |
||
1312 | 1312 | * Saves the queue to the option. |
1313 | 1313 | */ |
1314 | 1314 | public function save_queue() { |
1315 | - if ( ! empty( $this->import_queue ) ) { |
|
1316 | - if ( ! empty( $this->queued_imports ) ) { |
|
1317 | - $saved_imports = array_merge( $this->queued_imports,$this->import_queue ); |
|
1318 | - } else { |
|
1315 | + if (!empty($this->import_queue)) { |
|
1316 | + if (!empty($this->queued_imports)) { |
|
1317 | + $saved_imports = array_merge($this->queued_imports, $this->import_queue); |
|
1318 | + }else { |
|
1319 | 1319 | $saved_imports = $this->import_queue; |
1320 | 1320 | } |
1321 | 1321 | |
1322 | - delete_option( 'wetu_importer_que' ); |
|
1322 | + delete_option('wetu_importer_que'); |
|
1323 | 1323 | |
1324 | - if ( ! empty( $saved_imports ) ) { |
|
1325 | - $saved_imports = array_unique( $saved_imports ); |
|
1326 | - update_option( 'wetu_importer_que',$saved_imports ); |
|
1324 | + if (!empty($saved_imports)) { |
|
1325 | + $saved_imports = array_unique($saved_imports); |
|
1326 | + update_option('wetu_importer_que', $saved_imports); |
|
1327 | 1327 | } |
1328 | 1328 | } |
1329 | 1329 | } |