1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
|
|
|
|
3
|
|
|
* @package LSX_WETU_Importer_Accommodation |
4
|
|
|
* @author LightSpeed |
5
|
|
|
* @license GPL-2.0+ |
6
|
|
|
* @link |
7
|
|
|
* @copyright 2016 LightSpeed |
8
|
|
|
**/ |
|
|
|
|
9
|
|
|
|
10
|
|
|
class LSX_WETU_Importer_Accommodation extends LSX_WETU_Importer { |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* The url to list items from WETU |
14
|
|
|
* |
15
|
|
|
* @since 0.0.1 |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
public $tab_slug = 'accommodation'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The url to list items from WETU |
23
|
|
|
* |
24
|
|
|
* @since 0.0.1 |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
public $url = false; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The query string url to list items from WETU |
32
|
|
|
* |
33
|
|
|
* @since 0.0.1 |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
public $url_qs = false; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Options |
41
|
|
|
* |
42
|
|
|
* @since 0.0.1 |
43
|
|
|
* |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
public $options = false; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The fields you wish to import |
50
|
|
|
* |
51
|
|
|
* @since 0.0.1 |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
public $accommodation_options = false; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Initialize the plugin by setting localization, filters, and administration functions. |
59
|
|
|
* |
60
|
|
|
* @since 1.0.0 |
61
|
|
|
* |
62
|
|
|
* @access private |
63
|
|
|
*/ |
64
|
|
|
public function __construct() { |
|
|
|
|
65
|
|
|
$this->set_variables(); |
66
|
|
|
} |
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Sets the variables used throughout the plugin. |
70
|
|
|
*/ |
71
|
|
|
public function set_variables() { |
72
|
|
|
parent::set_variables(); |
73
|
|
|
|
74
|
|
|
// ** This request only works with API KEY ** |
75
|
|
|
// if ( false !== $this->api_username && false !== $this->api_password ) { |
76
|
|
|
// $this->url = 'https://wetu.com/API/Pins/'; |
77
|
|
|
// $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
78
|
|
|
// } elseif ( false !== $this->api_key ) { |
79
|
|
|
$this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
80
|
|
|
$this->url_qs = 'all=include'; |
81
|
|
|
// } |
82
|
|
|
|
83
|
|
|
$temp_options = get_option( '_lsx-to_settings', false ); |
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 ]; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
$accommodation_options = get_option( 'lsx_wetu_importer_accommodation_settings', false ); |
90
|
|
|
|
91
|
|
|
if ( false !== $accommodation_options ) { |
|
|
|
|
92
|
|
|
$this->accommodation_options = $accommodation_options; |
93
|
|
|
} |
94
|
|
|
} |
|
|
|
|
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Display the importer administration screen |
98
|
|
|
*/ |
99
|
|
|
public function display_page() { |
100
|
|
|
?> |
101
|
|
|
<div class="wrap"> |
102
|
|
|
|
103
|
|
|
<div class="tablenav top"> |
104
|
|
|
<div class="actions"> |
105
|
|
|
<?php $this->search_form(); ?> |
106
|
|
|
</div> |
107
|
|
|
</div> |
108
|
|
|
|
109
|
|
|
<form method="get" action="" id="posts-filter"> |
110
|
|
|
<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
111
|
|
|
|
112
|
|
|
<table class="wp-list-table widefat fixed posts"> |
113
|
|
|
<?php $this->table_header(); ?> |
114
|
|
|
|
115
|
|
|
<tbody id="the-list"> |
116
|
|
|
<tr class="post-0 type-tour status-none" id="post-0"> |
117
|
|
|
<th class="check-column" scope="row"> |
118
|
|
|
<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> |
119
|
|
|
</th> |
120
|
|
|
<td class="post-title page-title column-title"> |
121
|
|
|
<strong> |
122
|
|
|
<?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?> |
123
|
|
|
</strong> |
124
|
|
|
</td> |
125
|
|
|
<td class="date column-date"> |
126
|
|
|
</td> |
127
|
|
|
<td class="ssid column-ssid"> |
128
|
|
|
</td> |
129
|
|
|
</tr> |
130
|
|
|
</tbody> |
131
|
|
|
|
132
|
|
|
<?php $this->table_footer(); ?> |
133
|
|
|
|
134
|
|
|
</table> |
135
|
|
|
|
136
|
|
|
<p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'lsx-wetu-importer' ); ?>" /> |
137
|
|
|
<input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'lsx-wetu-importer' ); ?>" /> |
138
|
|
|
</p> |
139
|
|
|
</form> |
140
|
|
|
|
141
|
|
|
<div style="display:none;" class="import-list-wrapper"> |
142
|
|
|
<br /> |
143
|
|
|
<form method="get" action="" id="import-list"> |
144
|
|
|
|
145
|
|
|
<div class="row"> |
146
|
|
|
<div class="settings-all" style="width:30%;display:block;float:left;"> |
147
|
|
|
<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
148
|
|
|
<ul> |
149
|
|
|
<?php if ( isset( $this->options['disable_accommodation_descriptions'] ) && 'on' !== $this->options['disable_accommodation_descriptions'] ) { ?> |
|
|
|
|
150
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li> |
151
|
|
|
<?php } ?> |
152
|
|
|
<?php if ( isset( $this->options['disable_accommodation_excerpts'] ) && 'on' !== $this->options['disable_accommodation_excerpts'] ) { ?> |
|
|
|
|
153
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'lsx-wetu-importer' ); ?></li> |
154
|
|
|
<?php } ?> |
155
|
|
|
|
156
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li> |
157
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'lsx-wetu-importer' ); ?></li> |
158
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?></li> |
159
|
|
|
|
160
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'lsx-wetu-importer' ); ?></li> |
161
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'lsx-wetu-importer' ); ?></li> |
162
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'lsx-wetu-importer' ); ?></li> |
163
|
|
|
|
164
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'lsx-wetu-importer' ); ?></li> |
165
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'lsx-wetu-importer' ); ?></li> |
166
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'lsx-wetu-importer' ); ?></li> |
167
|
|
|
|
168
|
|
|
|
169
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'lsx-wetu-importer' ); ?></li> |
170
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'lsx-wetu-importer' ); ?></li> |
171
|
|
|
|
172
|
|
|
<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?> |
|
|
|
|
173
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li> |
174
|
|
|
<?php } ?> |
175
|
|
|
</ul> |
176
|
|
|
<h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
177
|
|
|
<ul> |
178
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?></li> |
179
|
|
|
<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?></li> |
180
|
|
|
</ul> |
181
|
|
|
</div> |
182
|
|
|
<div style="width:30%;display:block;float:left;"> |
183
|
|
|
<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
184
|
|
|
<?php $this->team_member_checkboxes( $this->accommodation_options ); ?> |
185
|
|
|
</div> |
186
|
|
|
|
187
|
|
|
<div style="width:30%;display:block;float:left;"> |
188
|
|
|
<h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3> |
189
|
|
|
<?php |
190
|
|
|
echo wp_kses_post( $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ) ); |
191
|
|
|
?> |
192
|
|
|
</div> |
193
|
|
|
|
194
|
|
|
<br clear="both" /> |
195
|
|
|
</div> |
196
|
|
|
|
197
|
|
|
<h3><?php esc_html_e( 'Your List' ); ?></h3> |
198
|
|
|
<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p> |
199
|
|
|
<table class="wp-list-table widefat fixed posts"> |
200
|
|
|
<?php $this->table_header(); ?> |
201
|
|
|
|
202
|
|
|
<tbody> |
203
|
|
|
|
204
|
|
|
</tbody> |
205
|
|
|
|
206
|
|
|
<?php $this->table_footer(); ?> |
207
|
|
|
|
208
|
|
|
</table> |
209
|
|
|
|
210
|
|
|
<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p> |
211
|
|
|
</form> |
212
|
|
|
</div> |
213
|
|
|
|
214
|
|
|
<div style="display:none;" class="completed-list-wrapper"> |
215
|
|
|
<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> |
216
|
|
|
<ul> |
217
|
|
|
</ul> |
218
|
|
|
</div> |
219
|
|
|
</div> |
220
|
|
|
<?php |
221
|
|
|
} |
|
|
|
|
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Run through the accommodation grabbed from the DB. |
225
|
|
|
*/ |
226
|
|
|
public function process_ajax_search() { |
227
|
|
|
$return = false; |
228
|
|
|
check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
229
|
|
|
if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] ) { |
|
|
|
|
230
|
|
|
|
231
|
|
|
$searched_items = false; |
232
|
|
|
if ( isset( $_POST['keyword'] ) ) { |
|
|
|
|
233
|
|
|
$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) ); |
234
|
|
|
} else { |
235
|
|
|
$keyphrases = array( 0 ); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
if ( ! is_array( $keyphrases ) ) { |
|
|
|
|
239
|
|
|
$keyphrases = array( $keyphrases ); |
240
|
|
|
} |
|
|
|
|
241
|
|
|
foreach ( $keyphrases as &$keyword ) { |
|
|
|
|
242
|
|
|
$keyword = ltrim( rtrim( $keyword ) ); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
$post_status = false; |
246
|
|
|
|
247
|
|
|
if ( in_array( 'publish', $keyphrases ) ) { |
|
|
|
|
248
|
|
|
$post_status = 'publish'; |
249
|
|
|
} |
|
|
|
|
250
|
|
|
if ( in_array( 'pending', $keyphrases ) ) { |
|
|
|
|
251
|
|
|
$post_status = 'pending'; |
252
|
|
|
} |
|
|
|
|
253
|
|
|
if ( in_array( 'draft', $keyphrases ) ) { |
|
|
|
|
254
|
|
|
$post_status = 'draft'; |
255
|
|
|
} |
|
|
|
|
256
|
|
|
if ( in_array( 'import', $keyphrases ) ) { |
|
|
|
|
257
|
|
|
$post_status = 'import'; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
// If there is a post status use it. |
261
|
|
|
if ( false !== $post_status ) { |
|
|
|
|
262
|
|
|
|
263
|
|
|
$accommodation = array(); |
264
|
|
|
$current_accommodation = $this->find_current_accommodation(); |
265
|
|
|
if ( ! empty( $current_accommodation ) ) { |
|
|
|
|
266
|
|
|
foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
|
|
|
267
|
|
|
$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
268
|
|
|
} |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
// Run through each accommodation and use it. |
272
|
|
|
if ( ! empty( $accommodation ) ) { |
|
|
|
|
273
|
|
|
foreach ( $accommodation as $row_key => $row ) { |
|
|
|
|
274
|
|
|
$row['post_title'] = $row['name']; |
275
|
|
|
if ( 'import' === $post_status ) { |
|
|
|
|
276
|
|
|
if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) { |
|
|
|
|
277
|
|
|
$current_status = get_post_status( $row['post_id'] ); |
278
|
|
|
if ( 'draft' === $current_status ) { |
|
|
|
|
279
|
|
|
$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
280
|
|
|
} |
281
|
|
|
} else { |
282
|
|
|
continue; |
283
|
|
|
} |
284
|
|
|
} else { |
285
|
|
|
if ( 0 === $row['post_id'] ) { |
|
|
|
|
286
|
|
|
continue; |
287
|
|
|
} else { |
288
|
|
|
$current_status = get_post_status( $row['post_id'] ); |
289
|
|
|
if ( $current_status !== $post_status ) { |
|
|
|
|
290
|
|
|
continue; |
291
|
|
|
} |
292
|
|
|
} |
|
|
|
|
293
|
|
|
$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key ); |
294
|
|
|
} |
295
|
|
|
} |
296
|
|
|
} |
297
|
|
|
} else { |
298
|
|
|
$key_string_search = implode( '+', $keyphrases ); |
299
|
|
|
$search_data = wp_remote_get( $this->url . '/Search/' . $key_string_search ); |
300
|
|
|
if ( ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) { |
|
|
|
|
301
|
|
|
|
302
|
|
|
$search_data = json_decode( $search_data['body'], true ); |
303
|
|
|
foreach ( $search_data as $sdata_key => $sdata ) { |
|
|
|
|
304
|
|
|
|
305
|
|
|
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'] ) ) { |
|
|
|
|
306
|
|
|
continue; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
$temp_id = $this->get_post_id_by_key_value( $sdata['id'] ); |
310
|
|
|
if ( false === $temp_id ) { |
|
|
|
|
311
|
|
|
$sdata['post_id'] = 0; |
312
|
|
|
$sdata['post_title'] = $sdata['name']; |
313
|
|
|
} else { |
314
|
|
|
$sdata['post_id'] = $temp_id; |
315
|
|
|
$sdata['post_title'] = get_the_title( $temp_id ); |
316
|
|
|
} |
|
|
|
|
317
|
|
|
$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata, $sdata_key ); |
318
|
|
|
} |
319
|
|
|
} |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
if ( false !== $searched_items ) { |
|
|
|
|
323
|
|
|
$return = implode( $searched_items ); |
324
|
|
|
} |
|
|
|
|
325
|
|
|
print_r( $return ); |
|
|
|
|
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
die(); |
|
|
|
|
329
|
|
|
} |
|
|
|
|
330
|
|
|
|
331
|
|
|
public function prepare_row_attributes( $cs_key, $ccs_id ) { |
|
|
|
|
332
|
|
|
$row_item = array( |
333
|
|
|
'id' => $cs_key, |
334
|
|
|
'type' => 'Accommodation', |
335
|
|
|
'name' => get_the_title( $ccs_id ), |
336
|
|
|
'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ), |
|
|
|
|
337
|
|
|
'post_id' => $ccs_id, |
338
|
|
|
); |
339
|
|
|
return $row_item; |
340
|
|
|
} |
|
|
|
|
341
|
|
|
|
342
|
|
|
/** |
|
|
|
|
343
|
|
|
* Formats the row for output on the screen. |
344
|
|
|
* |
345
|
|
|
* @param boolean $row the current row to format. |
346
|
|
|
* @return void |
|
|
|
|
347
|
|
|
*/ |
348
|
|
|
public function format_row( $row = false, $row_key = '' ) { |
349
|
|
|
if ( false !== $row ) { |
|
|
|
|
350
|
|
|
|
351
|
|
|
$status = 'import'; |
352
|
|
|
if ( 0 !== $row['post_id'] ) { |
|
|
|
|
353
|
|
|
$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
|
|
|
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
$row_html = ' |
357
|
|
|
<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
358
|
|
|
<th class="check-column" scope="row"> |
359
|
|
|
<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
360
|
|
|
<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
361
|
|
|
</th> |
362
|
|
|
<td class="column-order"> |
363
|
|
|
' . ( $row_key + 1 ) . ' |
364
|
|
|
</td> |
365
|
|
|
<td class="post-title page-title column-title"> |
366
|
|
|
<strong>' . $row['post_title'] . '</strong> - ' . $status . ' |
367
|
|
|
</td> |
368
|
|
|
<td class="date column-date"> |
369
|
|
|
<abbr title="' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
|
|
|
370
|
|
|
</td> |
371
|
|
|
<td class="ssid column-ssid"> |
372
|
|
|
' . $row['id'] . ' |
373
|
|
|
</td> |
374
|
|
|
</tr>'; |
375
|
|
|
return $row_html; |
376
|
|
|
} |
377
|
|
|
} |
|
|
|
|
378
|
|
|
|
379
|
|
|
/** |
|
|
|
|
380
|
|
|
* Saves the queue to the option. |
381
|
|
|
*/ |
382
|
|
|
public function remove_from_queue( $id ) { |
383
|
|
|
if ( ! empty( $this->queued_imports ) ) { |
|
|
|
|
384
|
|
|
$key = array_search( $id, $this->queued_imports ); |
|
|
|
|
385
|
|
|
if ( false !== $key ) { |
|
|
|
|
386
|
|
|
unset( $this->queued_imports[ $key ] ); |
387
|
|
|
|
388
|
|
|
delete_option( 'lsx_wetu_importer_que' ); |
389
|
|
|
update_option( 'lsx_wetu_importer_que', $this->queued_imports ); |
390
|
|
|
} |
391
|
|
|
} |
392
|
|
|
} |
|
|
|
|
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* Connect to wetu |
396
|
|
|
*/ |
397
|
|
|
public function process_ajax_import() { |
398
|
|
|
$return = false; |
399
|
|
|
check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
400
|
|
|
|
401
|
|
|
if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) { |
|
|
|
|
402
|
|
|
|
403
|
|
|
$wetu_id = sanitize_text_field( $_POST['wetu_id'] ); |
|
|
|
|
404
|
|
|
if ( isset( $_POST['post_id'] ) ) { |
|
|
|
|
405
|
|
|
$post_id = sanitize_text_field( $_POST['post_id'] ); |
|
|
|
|
406
|
|
|
} else { |
407
|
|
|
$post_id = 0; |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
if ( isset( $_POST['team_members'] ) ) { |
|
|
|
|
411
|
|
|
$team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) ); |
412
|
|
|
} else { |
413
|
|
|
$team_members = false; |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
if ( isset( $_POST['safari_brands'] ) ) { |
|
|
|
|
417
|
|
|
$safari_brands = array_map( 'sanitize_text_field', wp_unslash( $_POST['safari_brands'] ) ); |
418
|
|
|
} else { |
419
|
|
|
$safari_brands = false; |
420
|
|
|
} |
|
|
|
|
421
|
|
|
delete_option( 'lsx_wetu_importer_accommodation_settings' ); |
422
|
|
|
|
423
|
|
|
if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
|
|
|
424
|
|
|
$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) ); |
425
|
|
|
add_option( 'lsx_wetu_importer_accommodation_settings', $content ); |
426
|
|
|
} else { |
427
|
|
|
$content = false; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
431
|
|
|
|
432
|
|
|
if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
|
|
|
433
|
|
|
$adata = json_decode( $jdata['body'], true ); |
434
|
|
|
$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
435
|
|
|
$this->format_completed_row( $return ); |
436
|
|
|
$this->remove_from_queue( $return ); |
437
|
|
|
$this->cleanup_posts(); |
438
|
|
|
} else { |
439
|
|
|
$this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer' ) ); |
440
|
|
|
} |
441
|
|
|
} |
442
|
|
|
} |
|
|
|
|
443
|
|
|
|
444
|
|
|
/** |
|
|
|
|
445
|
|
|
* Connect to wetu |
446
|
|
|
*/ |
447
|
|
|
public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) { |
448
|
|
|
$post_name = ''; |
449
|
|
|
$data_post_content = ''; |
450
|
|
|
$data_post_excerpt = ''; |
451
|
|
|
|
452
|
|
|
$post = array( |
453
|
|
|
'post_type' => 'accommodation', |
454
|
|
|
); |
455
|
|
|
$content_used_general_description = false; |
456
|
|
|
|
457
|
|
|
// Set the post_content. |
458
|
|
|
if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
|
|
|
459
|
|
|
if ( isset( $data[0]['content']['extended_description'] ) ) { |
|
|
|
|
460
|
|
|
$data_post_content = $data[0]['content']['extended_description']; |
461
|
|
|
} elseif ( isset( $data[0]['content']['general_description'] ) ) { |
|
|
|
|
462
|
|
|
$data_post_content = $data[0]['content']['general_description']; |
463
|
|
|
$content_used_general_description = true; |
464
|
|
|
} elseif ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
|
|
|
465
|
|
|
$data_post_content = $data[0]['content']['teaser_description']; |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
if ( isset( $this->options['disable_accommodation_filtering'] ) && 'on' === $this->options['disable_accommodation_filtering'] ) { |
|
|
|
|
469
|
|
|
$post['post_content'] = $data_post_content; |
470
|
|
|
} else { |
471
|
|
|
$post['post_content'] = wp_strip_all_tags( $data_post_content ); |
472
|
|
|
} |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
// set the post_excerpt. |
476
|
|
|
if ( ! empty( $importable_content ) && in_array( 'excerpt', $importable_content ) ) { |
|
|
|
|
477
|
|
|
if ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
|
|
|
478
|
|
|
$data_post_excerpt = $data[0]['content']['teaser_description']; |
479
|
|
|
} elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) { |
|
|
|
|
480
|
|
|
$data_post_excerpt = $data[0]['content']['general_description']; |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
$post['post_excerpt'] = $data_post_excerpt; |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
if ( false !== $id && '0' !== $id ) { |
|
|
|
|
487
|
|
|
$post['ID'] = $id; |
488
|
|
|
|
489
|
|
|
if ( isset( $this->options ) && 'on' !== $this->options['disable_accommodation_title'] && isset( $data[0]['name'] ) ) { |
|
|
|
|
490
|
|
|
$post['post_title'] = $data[0]['name']; |
491
|
|
|
$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 ); |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
$post['post_status'] = 'publish'; |
495
|
|
|
|
496
|
|
|
$id = wp_update_post( $post ); |
497
|
|
|
$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
|
|
|
498
|
|
|
update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
|
|
|
499
|
|
|
} else { |
500
|
|
|
// Set the name. |
501
|
|
|
if ( isset( $data[0]['name'] ) ) { |
|
|
|
|
502
|
|
|
$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 ); |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
$post['post_name'] = $post_name; |
506
|
|
|
$post['post_title'] = $data[0]['name']; |
507
|
|
|
$post['post_status'] = 'publish'; |
508
|
|
|
$id = wp_insert_post( $post ); |
509
|
|
|
|
510
|
|
|
// Save the WETU ID and the Last date it was modified. |
511
|
|
|
if ( false !== $id ) { |
|
|
|
|
512
|
|
|
add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
|
|
|
513
|
|
|
add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
514
|
|
|
} |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
// Setup some default for use in the import. |
518
|
|
|
if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) { |
|
|
|
|
519
|
|
|
$this->find_attachments( $id ); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
// Set the team member if it is there. |
523
|
|
|
if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
|
|
|
524
|
|
|
$this->set_team_member( $id, $team_members ); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
// Set the safari brand. |
528
|
|
|
if ( false !== $safari_brands && '' !== $safari_brands ) { |
|
|
|
|
529
|
|
|
$this->set_safari_brands( $id, $safari_brands ); |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
$this->set_map_data( $data, $id, 9 ); |
533
|
|
|
|
534
|
|
|
if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination', $importable_content ) ) { |
|
|
|
|
535
|
|
|
$this->connect_destinations( $data, $id ); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
if ( false !== $importable_content && in_array( 'category', $importable_content ) ) { |
|
|
|
|
539
|
|
|
$this->set_taxonomy_style( $data, $id ); |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
// Set the Room Data. |
543
|
|
|
if ( false !== $importable_content && in_array( 'rooms', $importable_content ) ) { |
|
|
|
|
544
|
|
|
$this->set_room_data( $data, $id ); |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
// Set the rating. |
548
|
|
|
if ( false !== $importable_content && in_array( 'rating', $importable_content ) ) { |
|
|
|
|
549
|
|
|
$this->set_rating( $data, $id ); |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
// Set the checkin checkout data. |
553
|
|
|
if ( false !== $importable_content && in_array( 'checkin', $importable_content ) ) { |
|
|
|
|
554
|
|
|
$this->set_checkin_checkout( $data, $id ); |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
// Set the Spoken Languages. |
558
|
|
|
if ( false !== $importable_content && in_array( 'spoken_languages', $importable_content ) ) { |
|
|
|
|
559
|
|
|
$this->set_spoken_languages( $data, $id ); |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
// Set the friendly options. |
563
|
|
|
if ( false !== $importable_content && in_array( 'friendly', $importable_content ) ) { |
|
|
|
|
564
|
|
|
$this->set_friendly( $data, $id ); |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
// Set the special_interests. |
568
|
|
|
if ( false !== $importable_content && in_array( 'special_interests', $importable_content ) ) { |
|
|
|
|
569
|
|
|
$this->set_special_interests( $data, $id ); |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
// Import the videos. |
573
|
|
|
if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) { |
|
|
|
|
574
|
|
|
$this->set_video_data( $data, $id ); |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
// Import the facilities. |
578
|
|
|
if ( false !== $importable_content && in_array( 'facilities', $importable_content ) ) { |
|
|
|
|
579
|
|
|
$this->set_facilities( $data, $id ); |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
// Set the featured image. |
583
|
|
|
if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
|
|
|
584
|
|
|
$this->set_featured_image( $data, $id ); |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
|
|
|
588
|
|
|
$this->set_banner_image( $data, $id ); |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
// Import the main gallery. |
592
|
|
|
if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) { |
|
|
|
|
593
|
|
|
$this->create_main_gallery( $data, $id ); |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
return $id; |
597
|
|
|
} |
|
|
|
|
598
|
|
|
|
599
|
|
|
/** |
|
|
|
|
600
|
|
|
* Set the safari brand |
601
|
|
|
*/ |
602
|
|
|
public function set_safari_brands( $id, $safari_brands ) { |
603
|
|
|
foreach ( $safari_brands as $safari_brand ) { |
|
|
|
|
604
|
|
|
wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand', true ); |
605
|
|
|
} |
606
|
|
|
} |
|
|
|
|
607
|
|
|
|
608
|
|
|
/** |
|
|
|
|
609
|
|
|
* Connects the destinations post type |
610
|
|
|
*/ |
611
|
|
|
public function connect_destinations( $data, $id ) { |
612
|
|
|
if ( isset( $data[0]['position'] ) ) { |
|
|
|
|
613
|
|
|
$destinations = false; |
614
|
|
|
|
615
|
|
|
if ( isset( $data[0]['position']['country'] ) ) { |
|
|
|
|
616
|
|
|
$destinations['country'] = $data[0]['position']['country']; |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
if ( isset( $data[0]['position']['destination'] ) ) { |
|
|
|
|
620
|
|
|
$destinations['destination'] = $data[0]['position']['destination']; |
621
|
|
|
} |
622
|
|
|
|
623
|
|
|
if ( false !== $destinations ) { |
|
|
|
|
624
|
|
|
$prev_values = get_post_meta( $id, 'destination_to_accommodation', false ); |
625
|
|
|
|
626
|
|
|
if ( false === $prev_values || ! is_array( $prev_values ) ) { |
|
|
|
|
627
|
|
|
$prev_values = array(); |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
delete_post_meta( $id, 'destination_to_accommodation', $prev_values ); |
631
|
|
|
$destinations = array_unique( $destinations ); |
632
|
|
|
|
633
|
|
|
foreach ( $destinations as $key => $value ) { |
|
|
|
|
634
|
|
|
$destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' ); |
635
|
|
|
if ( null !== $destination ) { |
|
|
|
|
636
|
|
|
if ( ! in_array( $destination->ID, $prev_values ) ) { |
|
|
|
|
637
|
|
|
add_post_meta( $id, 'destination_to_accommodation', $destination->ID, false ); |
638
|
|
|
add_post_meta( $destination->ID, 'accommodation_to_destination', $id, false ); |
639
|
|
|
$this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination'; |
640
|
|
|
} |
641
|
|
|
} |
642
|
|
|
} |
643
|
|
|
} |
644
|
|
|
} |
645
|
|
|
} |
|
|
|
|
646
|
|
|
|
647
|
|
|
/** |
|
|
|
|
648
|
|
|
* Set the Travel Style |
649
|
|
|
*/ |
650
|
|
|
public function set_taxonomy_style( $data, $id ) { |
651
|
|
|
$terms = false; |
652
|
|
|
|
653
|
|
|
if ( isset( $data[0]['category'] ) ) { |
|
|
|
|
654
|
|
|
$term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' ); |
655
|
|
|
if ( ! $term ) { |
|
|
|
|
656
|
|
|
$term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' ); |
657
|
|
|
|
658
|
|
|
if ( is_wp_error( $term ) ) { |
|
|
|
|
659
|
|
|
echo wp_kses_post( $term->get_error_message() ); |
660
|
|
|
} |
661
|
|
|
} else { |
662
|
|
|
wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true ); |
663
|
|
|
} |
664
|
|
|
} else { |
665
|
|
|
wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true ); |
666
|
|
|
} |
667
|
|
|
} |
|
|
|
|
668
|
|
|
|
669
|
|
|
/** |
|
|
|
|
670
|
|
|
* Saves the room data |
671
|
|
|
*/ |
672
|
|
|
public function set_room_data( $data, $id ) { |
673
|
|
|
if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) { |
|
|
|
|
674
|
|
|
$rooms = false; |
675
|
|
|
|
676
|
|
|
foreach ( $data[0]['rooms'] as $room ) { |
|
|
|
|
677
|
|
|
$temp_room = array(); |
678
|
|
|
|
679
|
|
|
if ( isset( $room['name'] ) ) { |
|
|
|
|
680
|
|
|
$temp_room['title'] = $room['name']; |
681
|
|
|
} |
682
|
|
|
|
683
|
|
|
if ( isset( $room['description'] ) ) { |
|
|
|
|
684
|
|
|
$temp_room['description'] = strip_tags( $room['description'] ); |
|
|
|
|
685
|
|
|
} |
686
|
|
|
|
687
|
|
|
$temp_room['price'] = 0; |
688
|
|
|
$temp_room['type'] = 'room'; |
689
|
|
|
|
690
|
|
|
if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) { |
|
|
|
|
691
|
|
|
$temp_room['gallery'] = array(); |
692
|
|
|
$temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id ); |
693
|
|
|
} |
|
|
|
|
694
|
|
|
$rooms[] = $temp_room; |
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
if ( false !== $id && '0' !== $id ) { |
|
|
|
|
698
|
|
|
delete_post_meta( $id, 'units' ); |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
foreach ( $rooms as $room ) { |
|
|
|
|
702
|
|
|
add_post_meta( $id, 'units', $room, false ); |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) { |
|
|
|
|
706
|
|
|
$room_count = $data[0]['features']['rooms']; |
707
|
|
|
} else { |
708
|
|
|
$room_count = count( $data[0]['rooms'] ); |
709
|
|
|
} |
710
|
|
|
|
711
|
|
|
if ( false !== $id && '0' !== $id ) { |
|
|
|
|
712
|
|
|
$prev_rooms = get_post_meta( $id, 'number_of_rooms', true ); |
713
|
|
|
update_post_meta( $id, 'number_of_rooms', $room_count, $prev_rooms ); |
714
|
|
|
} else { |
715
|
|
|
add_post_meta( $id, 'number_of_rooms', $room_count, true ); |
716
|
|
|
} |
717
|
|
|
} |
718
|
|
|
} |
|
|
|
|
719
|
|
|
|
720
|
|
|
/** |
|
|
|
|
721
|
|
|
* Set the ratings |
722
|
|
|
*/ |
723
|
|
|
public function set_rating( $data, $id ) { |
724
|
|
|
if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) { |
|
|
|
|
725
|
|
|
$rating_type = $data[0]['features']['star_authority']; |
726
|
|
|
} else { |
727
|
|
|
$rating_type = 'Unspecified2'; |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
$this->save_custom_field( $rating_type, 'rating_type', $id ); |
731
|
|
|
|
732
|
|
|
if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) { |
|
|
|
|
733
|
|
|
$this->save_custom_field( $data[0]['features']['stars'], 'rating', $id, true ); |
734
|
|
|
} |
735
|
|
|
} |
|
|
|
|
736
|
|
|
|
737
|
|
|
/** |
|
|
|
|
738
|
|
|
* Set the spoken_languages |
739
|
|
|
*/ |
740
|
|
|
public function set_spoken_languages( $data, $id ) { |
741
|
|
|
if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) { |
|
|
|
|
742
|
|
|
$languages = false; |
743
|
|
|
|
744
|
|
|
foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) { |
|
|
|
|
745
|
|
|
$languages[] = sanitize_title( $spoken_language ); |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
if ( false !== $languages ) { |
|
|
|
|
749
|
|
|
$this->save_custom_field( $languages, 'spoken_languages', $id ); |
750
|
|
|
} |
751
|
|
|
} |
752
|
|
|
} |
|
|
|
|
753
|
|
|
|
754
|
|
|
/** |
|
|
|
|
755
|
|
|
* Set the friendly |
756
|
|
|
*/ |
757
|
|
|
public function set_friendly( $data, $id ) { |
758
|
|
|
if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) { |
|
|
|
|
759
|
|
|
$friendly_options = false; |
760
|
|
|
|
761
|
|
|
foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) { |
|
|
|
|
762
|
|
|
$friendly_options[] = sanitize_title( $visitor_type ); |
763
|
|
|
} |
764
|
|
|
|
765
|
|
|
if ( false !== $friendly_options ) { |
|
|
|
|
766
|
|
|
$this->save_custom_field( $friendly_options, 'suggested_visitor_types', $id ); |
767
|
|
|
} |
768
|
|
|
} |
769
|
|
|
} |
|
|
|
|
770
|
|
|
|
771
|
|
|
/** |
|
|
|
|
772
|
|
|
* Set the special interests |
773
|
|
|
*/ |
774
|
|
|
public function set_special_interests( $data, $id ) { |
775
|
|
|
if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) { |
|
|
|
|
776
|
|
|
$interests = false; |
777
|
|
|
|
778
|
|
|
foreach ( $data[0]['features']['special_interests'] as $special_interest ) { |
|
|
|
|
779
|
|
|
$interests[] = sanitize_title( $special_interest ); |
780
|
|
|
} |
781
|
|
|
|
782
|
|
|
if ( false !== $interests ) { |
|
|
|
|
783
|
|
|
$this->save_custom_field( $interests, 'special_interests', $id ); |
784
|
|
|
} |
785
|
|
|
} |
786
|
|
|
} |
|
|
|
|
787
|
|
|
|
788
|
|
|
/** |
|
|
|
|
789
|
|
|
* Set the Check in and Check out Date |
790
|
|
|
*/ |
791
|
|
|
public function set_checkin_checkout( $data, $id ) { |
792
|
|
|
if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) { |
|
|
|
|
793
|
|
|
$time = str_replace( 'h', ':', $data[0]['features']['check_in_time'] ); |
794
|
|
|
$time = date( 'h:ia', strtotime( $time ) ); |
|
|
|
|
795
|
|
|
$this->save_custom_field( $time, 'checkin_time', $id ); |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) { |
|
|
|
|
799
|
|
|
$time = str_replace( 'h', ':', $data[0]['features']['check_out_time'] ); |
800
|
|
|
$time = date( 'h:ia', strtotime( $time ) ); |
|
|
|
|
801
|
|
|
$this->save_custom_field( $time, 'checkout_time', $id ); |
802
|
|
|
} |
803
|
|
|
} |
|
|
|
|
804
|
|
|
|
805
|
|
|
/** |
|
|
|
|
806
|
|
|
* Set the Facilities |
807
|
|
|
*/ |
808
|
|
|
public function set_facilities( $data, $id ) { |
809
|
|
|
$parent_facilities = array( |
810
|
|
|
'available_services' => 'Available Services', |
811
|
|
|
'property_facilities' => 'Property Facilities', |
812
|
|
|
'room_facilities' => 'Room Facilities', |
813
|
|
|
'activities_on_site' => 'Activities on Site', |
814
|
|
|
); |
815
|
|
|
|
816
|
|
|
foreach ( $parent_facilities as $key => $label ) { |
|
|
|
|
817
|
|
|
$terms = false; |
818
|
|
|
|
819
|
|
|
if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) { |
|
|
|
|
820
|
|
|
$parent_id = $this->set_term( $id, $label, 'facility' ); |
|
|
|
|
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
foreach ( $data[0]['features'][ $key ] as $child_facility ) { |
|
|
|
|
824
|
|
|
$this->set_term( $id, $child_facility, 'facility', $parent_id ); |
|
|
|
|
825
|
|
|
} |
826
|
|
|
} |
827
|
|
|
} |
|
|
|
|
828
|
|
|
} |
829
|
|
|
|