Passed
Push — master ( 491c9d...051ec6 )
by Warwick
17:03
created

LSX_WETU_Importer_Accommodation::display_page()   B

Complexity

Conditions 7
Paths 16

Size

Total Lines 119
Code Lines 94

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 94
c 1
b 0
f 0
nc 16
nop 0
dl 0
loc 119
rs 7.1975

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
2
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
3
 * @package   LSX_WETU_Importer_Accommodation
4
 * @author    LightSpeed
5
 * @license   GPL-2.0+
6
 * @link
7
 * @copyright 2016 LightSpeed
8
 **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the class comment
Loading history...
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() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
65
		$this->set_variables();
66
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
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 ) {
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// if ( false !== $this->api_username && false !== $this->api_password ) {" but found "//if ( false !== $this->api_username && false !== $this->api_password ) {"
Loading history...
76
		//	$this->url    = 'https://wetu.com/API/Pins/';
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 2; use block comment if you need indentation
Loading history...
77
		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 2; use block comment if you need indentation
Loading history...
78
		//} elseif ( false !== $this->api_key ) {
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// } elseif ( false !== $this->api_key ) " but found "// elseif ( false !== $this->api_key ) {"
Loading history...
79
			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
80
			$this->url_qs = 'all=include';
81
		//}
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// }" but found "//}"
Loading history...
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 ] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
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 ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
92
			$this->accommodation_options = $accommodation_options;
93
		}
94
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
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'] ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
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'] ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
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' ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
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
								<?php if ( isset( $this->accommodation_settings['disable_single'] ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
180
									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?></li>
181
								<?php } ?>
182
							</ul>
183
						</div>
184
						<div style="width:30%;display:block;float:left;">
185
							<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
186
							<?php $this->team_member_checkboxes( $this->accommodation_options ); ?>
187
						</div>
188
189
						<div style="width:30%;display:block;float:left;">
190
							<h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3>
191
							<?php
192
								echo wp_kses_post( $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ) );
193
							?>
194
						</div>
195
196
						<br clear="both" />
197
					</div>
198
199
					<h3><?php esc_html_e( 'Your List' ); ?></h3>
200
					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
201
					<table class="wp-list-table widefat fixed posts">
202
						<?php $this->table_header(); ?>
203
204
						<tbody>
205
206
						</tbody>
207
208
						<?php $this->table_footer(); ?>
209
210
					</table>
211
212
					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
213
				</form>
214
			</div>
215
216
			<div style="display:none;" class="completed-list-wrapper">
217
				<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>
218
				<ul>
219
				</ul>
220
			</div>
221
		</div>
222
		<?php
223
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
224
225
	/**
226
	 * Run through the accommodation grabbed from the DB.
227
	 */
228
	public function process_ajax_search() {
229
		$return = false;
230
		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
231
		if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
232
233
			$searched_items = false;
234
			if ( isset( $_POST['keyword'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
235
				$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) );
236
			} else {
237
				$keyphrases = array( 0 );
238
			}
239
240
			if ( ! is_array( $keyphrases ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
241
				$keyphrases = array( $keyphrases );
242
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
243
			foreach ( $keyphrases as &$keyword ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
244
				$keyword = ltrim( rtrim( $keyword ) );
245
			}
246
247
			$post_status = false;
248
249
			if ( in_array( 'publish', $keyphrases ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
250
				$post_status = 'publish';
251
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
252
			if ( in_array( 'pending', $keyphrases ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
253
				$post_status = 'pending';
254
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
255
			if ( in_array( 'draft', $keyphrases ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
256
				$post_status = 'draft';
257
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
258
			if ( in_array( 'import', $keyphrases ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
259
				$post_status = 'import';
260
			}
261
262
			// If there is a post status use it.
263
			if ( false !== $post_status ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
264
265
				$accommodation = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
266
				$current_accommodation = $this->find_current_accommodation();
267
				if ( ! empty( $current_accommodation ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
268
					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
269
						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
270
					}
271
				}
272
273
				// Run through each accommodation and use it.
274
				if ( ! empty( $accommodation ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
275
					foreach ( $accommodation as $row_key => $row ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
276
						$row['post_title'] = $row['name'];
277
						if ( 'import' === $post_status ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
278
							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
279
								$current_status = get_post_status( $row['post_id'] );
280
								if ( 'draft' === $current_status ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
281
									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
282
								}
283
							} else {
284
								continue;
285
							}
286
						} else {
287
							if ( 0 === $row['post_id'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
288
								continue;
289
							} else {
290
								$current_status = get_post_status( $row['post_id'] );
291
								if ( $current_status !== $post_status ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
292
									continue;
293
								}
294
							}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
295
							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key );
296
						}
297
					}
298
				}
299
			} else {
300
				$key_string_search = implode( '+', $keyphrases );
301
				$search_data       = wp_remote_get( $this->url . '/Search/' . $key_string_search );
302
				if ( ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
303
304
					$search_data = json_decode( $search_data['body'], true );
305
					foreach ( $search_data as $sdata_key => $sdata ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
306
307
						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'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
308
							continue;
309
						}
310
311
						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
312
						if ( false === $temp_id ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
313
							$sdata['post_id'] = 0;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
314
							$sdata['post_title'] = $sdata['name'];
315
						} else {
316
							$sdata['post_id'] = $temp_id;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
317
							$sdata['post_title'] = get_the_title( $temp_id );
318
						}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
319
						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata, $sdata_key );
320
					}
321
				}
322
			}
323
324
			if ( false !== $searched_items ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
325
				$return = implode( $searched_items );
326
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
327
			print_r( $return );
0 ignored issues
show
introduced by
print_r() found. Debug code should not normally be used in production.
Loading history...
328
		}
329
330
		die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
331
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
332
333
	public function prepare_row_attributes( $cs_key, $ccs_id ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function prepare_row_attributes()
Loading history...
334
		$row_item = array(
335
			'id' => $cs_key,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 12 space(s) between "'id'" and double arrow, but found 1.
Loading history...
336
			'type' => 'Accommodation',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 10 space(s) between "'type'" and double arrow, but found 1.
Loading history...
337
			'name' => get_the_title( $ccs_id ),
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 10 space(s) between "'name'" and double arrow, but found 1.
Loading history...
338
			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
0 ignored issues
show
introduced by
date() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.
Loading history...
339
			'post_id' => $ccs_id,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'post_id'" and double arrow, but found 1.
Loading history...
340
		);
341
		return $row_item;
342
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
343
344
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$row_key" missing
Loading history...
345
	 * Formats the row for output on the screen.
346
	 *
347
	 * @param boolean $row the current row to format.
348
	 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
349
	 */
350
	public function format_row( $row = false, $row_key = '' ) {
351
		if ( false !== $row ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
352
353
			$status = 'import';
354
			if ( 0 !== $row['post_id'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
355
				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
0 ignored issues
show
Bug introduced by
Are you sure get_post_status($row['post_id']) of type false|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

355
				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . /** @scrutinizer ignore-type */ get_post_status( $row['post_id'] ) . '</a>';
Loading history...
356
			}
357
358
			$row_html = '
359
			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
360
				<th class="check-column" scope="row">
361
					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
362
					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
363
				</th>
364
				<td class="column-order">
365
					' . ( $row_key + 1 ) . '
366
				</td>
367
				<td class="post-title page-title column-title">
368
					<strong>' . $row['post_title'] . '</strong> - ' . $status . '
369
				</td>
370
				<td class="date column-date">
371
					<abbr title="' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
0 ignored issues
show
introduced by
date() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.
Loading history...
372
				</td>
373
				<td class="ssid column-ssid">
374
					' . $row['id'] . '
375
				</td>
376
			</tr>';
377
			return $row_html;
378
		}
379
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
380
381
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
382
	 * Saves the queue to the option.
383
	 */
384
	public function remove_from_queue( $id ) {
385
		if ( ! empty( $this->queued_imports ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
386
			$key = array_search( $id, $this->queued_imports );
0 ignored issues
show
Bug introduced by
$this->queued_imports of type integer is incompatible with the type array expected by parameter $haystack of array_search(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

386
			$key = array_search( $id, /** @scrutinizer ignore-type */ $this->queued_imports );
Loading history...
introduced by
Not using strict comparison for array_search; supply true for third argument.
Loading history...
387
			if ( false !== $key ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
388
				unset( $this->queued_imports[ $key ] );
389
390
				delete_option( 'lsx_wetu_importer_que' );
391
				update_option( 'lsx_wetu_importer_que', $this->queued_imports );
392
			}
393
		}
394
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
395
396
	/**
397
	 * Connect to wetu
398
	 */
399
	public function process_ajax_import() {
400
		$return = false;
401
		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
402
403
		if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
404
405
			$wetu_id = sanitize_text_field( $_POST['wetu_id'] );
0 ignored issues
show
introduced by
$_POST data not unslashed before sanitization. Use wp_unslash() or similar
Loading history...
406
			if ( isset( $_POST['post_id'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
407
				$post_id = sanitize_text_field( $_POST['post_id'] );
0 ignored issues
show
introduced by
$_POST data not unslashed before sanitization. Use wp_unslash() or similar
Loading history...
408
			} else {
409
				$post_id = 0;
410
			}
411
412
			if ( isset( $_POST['team_members'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
413
				$team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) );
414
			} else {
415
				$team_members = false;
416
			}
417
418
			if ( isset( $_POST['safari_brands'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
419
				$safari_brands = array_map( 'sanitize_text_field', wp_unslash( $_POST['safari_brands'] ) );
420
			} else {
421
				$safari_brands = false;
422
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
423
			delete_option( 'lsx_wetu_importer_accommodation_settings' );
424
425
			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
426
				$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) );
427
				add_option( 'lsx_wetu_importer_accommodation_settings', $content );
428
			} else {
429
				$content = false;
430
			}
431
432
			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
433
434
			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
435
				$adata = json_decode( $jdata['body'], true );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
436
				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
437
				$this->format_completed_row( $return );
438
				$this->remove_from_queue( $return );
439
				$this->cleanup_posts();
440
			} else {
441
				$this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer' ) );
442
			}
443
		}
444
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
445
446
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$wetu_id" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$team_members" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$importable_content" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$safari_brands" missing
Loading history...
447
	 * Connect to wetu
448
	 */
449
	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
450
		$post_name = '';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
451
		$data_post_content = '';
452
		$data_post_excerpt = '';
453
454
		$post = array(
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 29 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
455
			'post_type' => 'accommodation',
456
		);
457
		$content_used_general_description = false;
458
459
		// Set the post_content.
460
		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
461
			if ( isset( $data[0]['content']['extended_description'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
462
				$data_post_content = $data[0]['content']['extended_description'];
463
			} elseif ( isset( $data[0]['content']['general_description'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
464
				$data_post_content = $data[0]['content']['general_description'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 16 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
465
				$content_used_general_description = true;
466
			} elseif ( isset( $data[0]['content']['teaser_description'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
467
				$data_post_content = $data[0]['content']['teaser_description'];
468
			}
469
470
			if ( isset( $this->options['disable_accommodation_filtering'] ) && 'on' === $this->options['disable_accommodation_filtering'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
471
				$post['post_content'] = $data_post_content;
472
			} else {
473
				$post['post_content'] = wp_strip_all_tags( $data_post_content );
474
			}
475
		}
476
477
		// set the post_excerpt.
478
		if ( ! empty( $importable_content ) && in_array( 'excerpt', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
479
			if ( isset( $data[0]['content']['teaser_description'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
480
				$data_post_excerpt = $data[0]['content']['teaser_description'];
481
			} elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
482
				$data_post_excerpt = $data[0]['content']['general_description'];
483
			}
484
485
			$post['post_excerpt'] = $data_post_excerpt;
486
		}
487
488
		if ( false !== $id && '0' !== $id ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
489
			$post['ID'] = $id;
490
491
			if ( isset( $this->options ) && 'on' !== $this->options['disable_accommodation_title'] && isset( $data[0]['name'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
492
				$post['post_title'] = $data[0]['name'];
493
				$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
494
			}
495
496
			$post['post_status'] = 'publish';
497
498
			$id = wp_update_post( $post );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
499
			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
0 ignored issues
show
Bug introduced by
It seems like $id can also be of type WP_Error; however, parameter $post_id of get_post_meta() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

499
			$prev_date = get_post_meta( /** @scrutinizer ignore-type */ $id, 'lsx_wetu_modified_date', true );
Loading history...
500
			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
0 ignored issues
show
Bug introduced by
It seems like $id can also be of type WP_Error; however, parameter $post_id of update_post_meta() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

500
			update_post_meta( /** @scrutinizer ignore-type */ $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
Loading history...
501
		} else {
502
			// Set the name.
503
			if ( isset( $data[0]['name'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
504
				$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
505
			}
506
507
			$post['post_name']   = $post_name;
508
			$post['post_title']  = $data[0]['name'];
509
			$post['post_status'] = 'publish';
510
			$id                  = wp_insert_post( $post );
511
512
			// Save the WETU ID and the Last date it was modified.
513
			if ( false !== $id ) {
0 ignored issues
show
introduced by
The condition false !== $id is always true.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
514
				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
0 ignored issues
show
Bug introduced by
It seems like $id can also be of type WP_Error; however, parameter $post_id of add_post_meta() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

514
				add_post_meta( /** @scrutinizer ignore-type */ $id, 'lsx_wetu_id', $wetu_id );
Loading history...
515
				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
516
			}
517
		}
518
519
		// Setup some default for use in the import.
520
		if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
521
			$this->find_attachments( $id );
522
		}
523
524
		// Set the team member if it is there.
525
		if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
526
			$this->set_team_member( $id, $team_members );
527
		}
528
529
		// Set the safari brand.
530
		if ( false !== $safari_brands && '' !== $safari_brands ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
531
			$this->set_safari_brands( $id, $safari_brands );
532
		}
533
534
		$this->set_map_data( $data, $id, 9 );
535
536
		if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
537
			$this->connect_destinations( $data, $id );
538
		}
539
540
		if ( false !== $importable_content && in_array( 'category', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
541
			$this->set_taxonomy_style( $data, $id );
542
		}
543
544
		// Set the Room Data.
545
		if ( false !== $importable_content && in_array( 'rooms', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
546
			$this->set_room_data( $data, $id );
547
		}
548
549
		// Set the rating.
550
		if ( false !== $importable_content && in_array( 'rating', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
551
			$this->set_rating( $data, $id );
552
		}
553
554
		// Set the checkin checkout data.
555
		if ( false !== $importable_content && in_array( 'checkin', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
556
			$this->set_checkin_checkout( $data, $id );
557
		}
558
559
		// Set the Spoken Languages.
560
		if ( false !== $importable_content && in_array( 'spoken_languages', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
561
			$this->set_spoken_languages( $data, $id );
562
		}
563
564
		// Set the friendly options.
565
		if ( false !== $importable_content && in_array( 'friendly', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
566
			$this->set_friendly( $data, $id );
567
		}
568
569
		// Set the special_interests.
570
		if ( false !== $importable_content && in_array( 'special_interests', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
571
			$this->set_special_interests( $data, $id );
572
		}
573
574
		// Import the videos.
575
		if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
576
			$this->set_video_data( $data, $id );
577
		}
578
579
		// Import the facilities.
580
		if ( false !== $importable_content && in_array( 'facilities', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
581
			$this->set_facilities( $data, $id );
582
		}
583
584
		// Set the featured image.
585
		if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
586
			$this->set_featured_image( $data, $id );
587
		}
588
589
		if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
590
			$this->set_banner_image( $data, $id );
591
		}
592
593
		// Import the main gallery.
594
		if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
595
			$this->create_main_gallery( $data, $id );
596
		}
597
598
		return $id;
599
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
600
601
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$safari_brands" missing
Loading history...
602
	 * Set the safari brand
603
	 */
604
	public function set_safari_brands( $id, $safari_brands ) {
605
		foreach ( $safari_brands as $safari_brand ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
606
			wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand', true );
607
		}
608
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
609
610
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
611
	 * Connects the destinations post type
612
	 */
613
	public function connect_destinations( $data, $id ) {
614
		if ( isset( $data[0]['position'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
615
			$destinations = false;
616
617
			if ( isset( $data[0]['position']['country'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
618
				$destinations['country'] = $data[0]['position']['country'];
619
			}
620
621
			if ( isset( $data[0]['position']['destination'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
622
				$destinations['destination'] = $data[0]['position']['destination'];
623
			}
624
625
			if ( false !== $destinations ) {
0 ignored issues
show
introduced by
The condition false !== $destinations is always false.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
626
				$prev_values = get_post_meta( $id, 'destination_to_accommodation', false );
627
628
				if ( false === $prev_values || ! is_array( $prev_values ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
629
					$prev_values = array();
630
				}
631
632
				delete_post_meta( $id, 'destination_to_accommodation', $prev_values );
633
				$destinations = array_unique( $destinations );
634
635
				foreach ( $destinations as $key => $value ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
636
					$destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' );
637
					if ( null !== $destination ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
638
						if ( ! in_array( $destination->ID, $prev_values ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
639
							add_post_meta( $id, 'destination_to_accommodation', $destination->ID, false );
640
							add_post_meta( $destination->ID, 'accommodation_to_destination', $id, false );
641
							$this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination';
642
						}
643
					}
644
				}
645
			}
646
		}
647
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
648
649
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
650
	 * Set the Travel Style
651
	 */
652
	public function set_taxonomy_style( $data, $id ) {
653
		$terms = false;
654
655
		if ( isset( $data[0]['category'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
656
			$term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' );
657
			if ( ! $term ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
658
				$term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' );
659
660
				if ( is_wp_error( $term ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
661
					echo wp_kses_post( $term->get_error_message() );
662
				}
663
			} else {
664
				wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
665
			}
666
		} else {
667
			wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
668
		}
669
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
670
671
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
672
	 * Saves the room data
673
	 */
674
	public function set_room_data( $data, $id ) {
675
		if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
676
			$rooms = false;
677
678
			foreach ( $data[0]['rooms'] as $room ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
679
				$temp_room = array();
680
681
				if ( isset( $room['name'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
682
					$temp_room['title'] = $room['name'];
683
				}
684
685
				if ( isset( $room['description'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
686
					$temp_room['description'] = strip_tags( $room['description'] );
0 ignored issues
show
introduced by
strip_tags() is discouraged. Use the more comprehensive wp_strip_all_tags() instead.
Loading history...
687
				}
688
689
				$temp_room['price'] = 0;
690
				$temp_room['type']  = 'room';
691
692
				if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
693
					$temp_room['gallery'] = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
694
					$temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id );
695
				}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
696
				$rooms[] = $temp_room;
697
			}
698
699
			if ( false !== $id && '0' !== $id ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
700
				delete_post_meta( $id, 'units' );
701
			}
702
703
			foreach ( $rooms as $room ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
704
				add_post_meta( $id, 'units', $room, false );
705
			}
706
707
			if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
708
				$room_count = $data[0]['features']['rooms'];
709
			} else {
710
				$room_count = count( $data[0]['rooms'] );
711
			}
712
713
			if ( false !== $id && '0' !== $id ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
714
				$prev_rooms = get_post_meta( $id, 'number_of_rooms', true );
715
				update_post_meta( $id, 'number_of_rooms', $room_count, $prev_rooms );
716
			} else {
717
				add_post_meta( $id, 'number_of_rooms', $room_count, true );
718
			}
719
		}
720
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
721
722
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
723
	 * Set the ratings
724
	 */
725
	public function set_rating( $data, $id ) {
726
		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
727
			$rating_type = $data[0]['features']['star_authority'];
728
		} else {
729
			$rating_type = 'Unspecified2';
730
		}
731
732
		$this->save_custom_field( $rating_type, 'rating_type', $id );
733
734
		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
735
			$this->save_custom_field( $data[0]['features']['stars'], 'rating', $id, true );
736
		}
737
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
738
739
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
740
	 * Set the spoken_languages
741
	 */
742
	public function set_spoken_languages( $data, $id ) {
743
		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
744
			$languages = false;
745
746
			foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
747
				$languages[] = sanitize_title( $spoken_language );
748
			}
749
750
			if ( false !== $languages ) {
0 ignored issues
show
introduced by
The condition false !== $languages is always false.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
751
				$this->save_custom_field( $languages, 'spoken_languages', $id );
752
			}
753
		}
754
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
755
756
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
757
	 * Set the friendly
758
	 */
759
	public function set_friendly( $data, $id ) {
760
		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
761
			$friendly_options = false;
762
763
			foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
764
				$friendly_options[] = sanitize_title( $visitor_type );
765
			}
766
767
			if ( false !== $friendly_options ) {
0 ignored issues
show
introduced by
The condition false !== $friendly_options is always false.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
768
				$this->save_custom_field( $friendly_options, 'suggested_visitor_types', $id );
769
			}
770
		}
771
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
772
773
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
774
	 * Set the special interests
775
	 */
776
	public function set_special_interests( $data, $id ) {
777
		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
778
			$interests = false;
779
780
			foreach ( $data[0]['features']['special_interests'] as $special_interest ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
781
				$interests[] = sanitize_title( $special_interest );
782
			}
783
784
			if ( false !== $interests ) {
0 ignored issues
show
introduced by
The condition false !== $interests is always false.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
785
				$this->save_custom_field( $interests, 'special_interests', $id );
786
			}
787
		}
788
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
789
790
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
791
	 * Set the Check in and Check out Date
792
	 */
793
	public function set_checkin_checkout( $data, $id ) {
794
		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
795
			$time = str_replace( 'h', ':', $data[0]['features']['check_in_time'] );
796
			$time = date( 'h:ia', strtotime( $time ) );
0 ignored issues
show
introduced by
date() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.
Loading history...
797
			$this->save_custom_field( $time, 'checkin_time', $id );
798
		}
799
800
		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
801
			$time = str_replace( 'h', ':', $data[0]['features']['check_out_time'] );
802
			$time = date( 'h:ia', strtotime( $time ) );
0 ignored issues
show
introduced by
date() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.
Loading history...
803
			$this->save_custom_field( $time, 'checkout_time', $id );
804
		}
805
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
806
807
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$data" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$id" missing
Loading history...
808
	 * Set the Facilities
809
	 */
810
	public function set_facilities( $data, $id ) {
811
		$parent_facilities = array(
812
			'available_services' => 'Available Services',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 2 space(s) between "'available_services'" and double arrow, but found 1.
Loading history...
813
			'property_facilities' => 'Property Facilities',
814
			'room_facilities' => 'Room Facilities',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 5 space(s) between "'room_facilities'" and double arrow, but found 1.
Loading history...
815
			'activities_on_site' => 'Activities on Site',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 2 space(s) between "'activities_on_site'" and double arrow, but found 1.
Loading history...
816
		);
817
818
		foreach ( $parent_facilities as $key => $label ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
819
			$terms = false;
820
821
			if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
822
				$parent_id = $this->set_term( $id, $label, 'facility' );
0 ignored issues
show
Bug introduced by
$label of type string is incompatible with the type boolean expected by parameter $name of LSX_WETU_Importer::set_term(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

822
				$parent_id = $this->set_term( $id, /** @scrutinizer ignore-type */ $label, 'facility' );
Loading history...
Bug introduced by
'facility' of type string is incompatible with the type boolean expected by parameter $taxonomy of LSX_WETU_Importer::set_term(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

822
				$parent_id = $this->set_term( $id, $label, /** @scrutinizer ignore-type */ 'facility' );
Loading history...
823
			}
824
825
			foreach ( $data[0]['features'][ $key ] as $child_facility ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
826
				$this->set_term( $id, $child_facility, 'facility', $parent_id );
0 ignored issues
show
Bug introduced by
$parent_id of type void is incompatible with the type boolean expected by parameter $parent of LSX_WETU_Importer::set_term(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

826
				$this->set_term( $id, $child_facility, 'facility', /** @scrutinizer ignore-type */ $parent_id );
Loading history...
827
			}
828
		}
829
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
830
}
831