@@ -229,6 +229,9 @@ |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | + /** |
|
233 | + * @param string $url |
|
234 | + */ |
|
232 | 235 | public function attach_external_image2( $url = null, $post_data = array(), $post_id = '' ) { |
233 | 236 | if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); } |
234 | 237 | $att_id = false; |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @access private |
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | - add_action( 'wp_ajax_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) ); |
|
30 | - add_action( 'wp_ajax_nopriv_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) ); |
|
29 | + add_action('wp_ajax_lsx_import_sync_banners', array($this, 'sync_new_banner')); |
|
30 | + add_action('wp_ajax_nopriv_lsx_import_sync_banners', array($this, 'sync_new_banner')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | public function display_page() { |
37 | 37 | ?> |
38 | 38 | <div class="wrap"> |
39 | - <h2><?php esc_html_e( 'Download new banners straight from WETU','lsx-wetu-importer' ); ?></h2> |
|
39 | + <h2><?php esc_html_e('Download new banners straight from WETU', 'lsx-wetu-importer'); ?></h2> |
|
40 | 40 | |
41 | 41 | <form method="get" action="" id="banners-filter"> |
42 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
42 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
43 | 43 | |
44 | 44 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
45 | - <img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
|
45 | + <img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" /> |
|
46 | 46 | </div> |
47 | 47 | |
48 | 48 | <table class="wp-list-table widefat fixed posts"> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | <?php |
61 | 61 | $accommodation_args = array( |
62 | 62 | 'post_type' => 'accommodation', |
63 | - 'post_status' => array( 'publish','pending','draft','future','private' ), |
|
63 | + 'post_status' => array('publish', 'pending', 'draft', 'future', 'private'), |
|
64 | 64 | 'nopagin' => 'true', |
65 | 65 | 'posts_per_page' => '1000', |
66 | 66 | 'meta_query' => array( |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | ), |
81 | 81 | ), |
82 | 82 | ); |
83 | - $accommodation = new WP_Query( $accommodation_args ); |
|
83 | + $accommodation = new WP_Query($accommodation_args); |
|
84 | 84 | ?> |
85 | 85 | |
86 | 86 | <tbody id="the-list"> |
87 | 87 | <?php |
88 | - if ( $accommodation->have_posts() ) { |
|
89 | - while ( $accommodation->have_posts() ) { |
|
88 | + if ($accommodation->have_posts()) { |
|
89 | + while ($accommodation->have_posts()) { |
|
90 | 90 | $accommodation->the_post(); |
91 | 91 | ?> |
92 | 92 | <tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>"> |
@@ -95,26 +95,26 @@ discard block |
||
95 | 95 | $min_width = '1920'; |
96 | 96 | $min_height = '500'; |
97 | 97 | |
98 | - $img_group = get_post_meta( get_the_ID(),'image_group',true ); |
|
98 | + $img_group = get_post_meta(get_the_ID(), 'image_group', true); |
|
99 | 99 | |
100 | 100 | $thumbnails_html = false; |
101 | 101 | |
102 | - if ( false !== $img_group ) { |
|
103 | - foreach ( $img_group['banner_image'] as $banner_image ) { |
|
104 | - $large = wp_get_attachment_image_src( $banner_image,'full' ); |
|
102 | + if (false !== $img_group) { |
|
103 | + foreach ($img_group['banner_image'] as $banner_image) { |
|
104 | + $large = wp_get_attachment_image_src($banner_image, 'full'); |
|
105 | 105 | $real_width = $large[1]; |
106 | 106 | $real_height = $large[2]; |
107 | 107 | |
108 | 108 | $status = 'optimized'; |
109 | - if ( $real_width < intval( $real_width ) ) { |
|
109 | + if ($real_width < intval($real_width)) { |
|
110 | 110 | $status = 'width not enough.'; |
111 | 111 | } |
112 | 112 | |
113 | - $thumbnail = wp_get_attachment_image_src( $banner_image,'thumbnail' ); |
|
113 | + $thumbnail = wp_get_attachment_image_src($banner_image, 'thumbnail'); |
|
114 | 114 | $thumbnails_html[] = ' |
115 | 115 | <div style="display:block;float:left;"> |
116 | - <img src="' . $thumbnail[0] . '" /> |
|
117 | - <p style="text-align:center;">' . $real_width . 'px by ' . $real_height . 'px</p> |
|
116 | + <img src="' . $thumbnail[0].'" /> |
|
117 | + <p style="text-align:center;">' . $real_width.'px by '.$real_height.'px</p> |
|
118 | 118 | </div>'; |
119 | 119 | } |
120 | 120 | } |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | <input type="checkbox" data-identifier="<?php the_ID(); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>"> |
125 | 125 | </th> |
126 | 126 | |
127 | - <td class="post-title page-title column-title"><?php echo '<a href="' . esc_url( admin_url( '/post.php?post=' . get_the_ID() . '&action=edit' ) ) . '" target="_blank">'; |
|
127 | + <td class="post-title page-title column-title"><?php echo '<a href="'.esc_url(admin_url('/post.php?post='.get_the_ID().'&action=edit')).'" target="_blank">'; |
|
128 | 128 | the_title(); |
129 | 129 | echo '</a>'; ?></td> |
130 | 130 | |
131 | 131 | <td colspan="2" class="thumbnails column-thumbnails"> |
132 | 132 | <?php |
133 | - if ( false !== $thumbnails_html ) { |
|
134 | - echo wp_kses_post( implode( '', $thumbnails_html ) ); |
|
135 | - } else { |
|
133 | + if (false !== $thumbnails_html) { |
|
134 | + echo wp_kses_post(implode('', $thumbnails_html)); |
|
135 | + }else { |
|
136 | 136 | echo '<p>There was an error retrieving your images.</p>'; |
137 | 137 | } |
138 | 138 | ?> |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | </table> |
158 | 158 | |
159 | - <p><input class="button button-primary download" type="button" value="<?php esc_html_e( 'Download new Banners','lsx-wetu-importer' ); ?>" /> |
|
159 | + <p><input class="button button-primary download" type="button" value="<?php esc_html_e('Download new Banners', 'lsx-wetu-importer'); ?>" /> |
|
160 | 160 | </p> |
161 | 161 | </form> |
162 | 162 | </div> |
@@ -167,32 +167,32 @@ discard block |
||
167 | 167 | * Creates the main gallery data |
168 | 168 | */ |
169 | 169 | public function sync_new_banner() { |
170 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
171 | - if ( isset( $_POST['action'] ) && 'lsx_import_sync_banners' === $_POST['action'] && isset( $_POST['post_id'] ) ) { |
|
170 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
171 | + if (isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])) { |
|
172 | 172 | |
173 | - $post_id = sanitize_text_field( $_POST['post_id'] ); |
|
174 | - $banners = get_post_meta( $post_id, 'image_group', true ); |
|
175 | - $this->wetu_id = get_post_meta( $post_id, 'lsx_wetu_id', true ); |
|
173 | + $post_id = sanitize_text_field($_POST['post_id']); |
|
174 | + $banners = get_post_meta($post_id, 'image_group', true); |
|
175 | + $this->wetu_id = get_post_meta($post_id, 'lsx_wetu_id', true); |
|
176 | 176 | |
177 | 177 | $new_banner_array = false; |
178 | 178 | $array_index = 0; |
179 | 179 | |
180 | - foreach ( $banners['banner_image'] as $banner_image ) { |
|
181 | - $image_id = $this->attach_external_image2( $this->format_wetu_url( $banner_image ), array(), $post_id ); |
|
182 | - if ( null !== $image_id && '' !== $image_id ) { |
|
183 | - $new_banner_array['banner_image'][ 'cmb-field-' . $array_index ] = $image_id; |
|
180 | + foreach ($banners['banner_image'] as $banner_image) { |
|
181 | + $image_id = $this->attach_external_image2($this->format_wetu_url($banner_image), array(), $post_id); |
|
182 | + if (null !== $image_id && '' !== $image_id) { |
|
183 | + $new_banner_array['banner_image']['cmb-field-'.$array_index] = $image_id; |
|
184 | 184 | $array_index++; |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - if ( false !== $new_banner_array ) { |
|
189 | - delete_post_meta( $post_id, 'image_group' ); |
|
190 | - add_post_meta( $post_id, 'image_group', $new_banner_array, true ); |
|
188 | + if (false !== $new_banner_array) { |
|
189 | + delete_post_meta($post_id, 'image_group'); |
|
190 | + add_post_meta($post_id, 'image_group', $new_banner_array, true); |
|
191 | 191 | echo true; |
192 | - } else { |
|
192 | + }else { |
|
193 | 193 | echo false; |
194 | 194 | } |
195 | - } else { |
|
195 | + }else { |
|
196 | 196 | echo false; |
197 | 197 | } |
198 | 198 | |
@@ -202,80 +202,80 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * formats the url |
204 | 204 | */ |
205 | - public function format_wetu_url( $post_id ) { |
|
206 | - return 'https://wetu.com/ImageHandler/c1920x800/' . $this->wetu_id . '/' . $this->format_filename( $post_id ); |
|
205 | + public function format_wetu_url($post_id) { |
|
206 | + return 'https://wetu.com/ImageHandler/c1920x800/'.$this->wetu_id.'/'.$this->format_filename($post_id); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | 210 | * formats the filename |
211 | 211 | */ |
212 | - public function format_filename( $post_id ) { |
|
213 | - $base = str_replace( '_',' ',get_the_title( $post_id ) ); |
|
214 | - $base = rawurlencode( $base ); |
|
215 | - $type = get_post_mime_type( $post_id ); |
|
212 | + public function format_filename($post_id) { |
|
213 | + $base = str_replace('_', ' ', get_the_title($post_id)); |
|
214 | + $base = rawurlencode($base); |
|
215 | + $type = get_post_mime_type($post_id); |
|
216 | 216 | |
217 | - switch ( $type ) { |
|
217 | + switch ($type) { |
|
218 | 218 | case 'image/jpeg': |
219 | - return $base . '.jpg'; |
|
219 | + return $base.'.jpg'; |
|
220 | 220 | break; |
221 | 221 | case 'image/png': |
222 | - return $base . '.png'; |
|
222 | + return $base.'.png'; |
|
223 | 223 | break; |
224 | 224 | case 'image/gif': |
225 | - return $base . '.gif'; |
|
225 | + return $base.'.gif'; |
|
226 | 226 | break; |
227 | 227 | default: |
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - public function attach_external_image2( $url = null, $post_data = array(), $post_id = '' ) { |
|
233 | - if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); } |
|
232 | + public function attach_external_image2($url = null, $post_data = array(), $post_id = '') { |
|
233 | + if (!$url) { return new WP_Error('missing', 'Need a valid URL'); } |
|
234 | 234 | $att_id = false; |
235 | 235 | |
236 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
237 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
238 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
236 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
237 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
238 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
239 | 239 | |
240 | - $tmp = tempnam( '/tmp', 'FOO' ); |
|
241 | - $image = wp_remote_get( $url ); |
|
240 | + $tmp = tempnam('/tmp', 'FOO'); |
|
241 | + $image = wp_remote_get($url); |
|
242 | 242 | |
243 | - if ( ! empty( $image ) && isset( $image['response'] ) && isset( $image['response']['code'] ) && 200 === $image['response']['code'] ) { |
|
244 | - file_put_contents( $tmp, $image['body'] ); |
|
245 | - chmod( $tmp, '777' ); |
|
243 | + if (!empty($image) && isset($image['response']) && isset($image['response']['code']) && 200 === $image['response']['code']) { |
|
244 | + file_put_contents($tmp, $image['body']); |
|
245 | + chmod($tmp, '777'); |
|
246 | 246 | |
247 | - preg_match( '/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches ); |
|
248 | - $url_filename = basename( $matches[0] ); |
|
249 | - $url_filename = str_replace( '%20','_', $url_filename ); |
|
247 | + preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); |
|
248 | + $url_filename = basename($matches[0]); |
|
249 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
250 | 250 | // extract filename from url for title. |
251 | - $url_type = wp_check_filetype( $url_filename ); |
|
251 | + $url_type = wp_check_filetype($url_filename); |
|
252 | 252 | |
253 | 253 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using). |
254 | 254 | $file_array['tmp_name'] = $tmp; |
255 | 255 | |
256 | - if ( ! empty( $filename ) && ' ' != $filename ) { |
|
257 | - $file_array['name'] = $filename . '.' . $url_type['ext']; |
|
258 | - } else { |
|
256 | + if (!empty($filename) && ' ' != $filename) { |
|
257 | + $file_array['name'] = $filename.'.'.$url_type['ext']; |
|
258 | + }else { |
|
259 | 259 | $file_array['name'] = $url_filename; |
260 | 260 | } |
261 | 261 | |
262 | 262 | // set additional wp_posts columns. |
263 | - if ( empty( $post_data['post_title'] ) ) { |
|
264 | - $url_filename = str_replace( '%20', ' ', $url_filename ); |
|
265 | - $post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] ); |
|
263 | + if (empty($post_data['post_title'])) { |
|
264 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
265 | + $post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | // make sure gets tied to parent. |
269 | - if ( empty( $post_data['post_parent'] ) ) { |
|
269 | + if (empty($post_data['post_parent'])) { |
|
270 | 270 | $post_data['post_parent'] = $post_id; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // do the validation and storage stuff. |
274 | - $att_id = media_handle_sideload( $file_array, $post_id, null, $post_data ); |
|
274 | + $att_id = media_handle_sideload($file_array, $post_id, null, $post_data); |
|
275 | 275 | |
276 | 276 | // If error storing permanently, unlink. |
277 | - if ( is_wp_error( $att_id ) ) { |
|
278 | - unlink( $file_array['tmp_name'] ); |
|
277 | + if (is_wp_error($att_id)) { |
|
278 | + unlink($file_array['tmp_name']); |
|
279 | 279 | return false; |
280 | 280 | } |
281 | 281 | } |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function set_variables() { |
72 | 72 | parent::set_variables(); |
73 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
73 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
74 | 74 | $this->url_qs = 'all=include'; |
75 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
75 | + $temp_options = get_option('_lsx-to_settings', false); |
|
76 | 76 | |
77 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
78 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
77 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
78 | + $this->options = $temp_options[$this->plugin_slug]; |
|
79 | 79 | } |
80 | 80 | |
81 | - $destination_options = get_option( 'lsx_wetu_importer_destination_settings', false ); |
|
81 | + $destination_options = get_option('lsx_wetu_importer_destination_settings', false); |
|
82 | 82 | |
83 | - if ( false !== $destination_options ) { |
|
83 | + if (false !== $destination_options) { |
|
84 | 84 | $this->destination_options = $destination_options; |
85 | 85 | } |
86 | 86 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | </div> |
97 | 97 | |
98 | 98 | <form method="get" action="" id="posts-filter"> |
99 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/> |
|
99 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/> |
|
100 | 100 | |
101 | 101 | <table class="wp-list-table widefat fixed posts"> |
102 | 102 | <?php $this->table_header(); ?> |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | <tr class="post-0 type-tour status-none" id="post-0"> |
106 | 106 | <th class="check-column" scope="row"> |
107 | 107 | <label for="cb-select-0" |
108 | - class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label> |
|
108 | + class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label> |
|
109 | 109 | </th> |
110 | 110 | <td class="post-title page-title column-title"> |
111 | 111 | <strong> |
112 | - <?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?> |
|
112 | + <?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?> |
|
113 | 113 | </strong> |
114 | 114 | </td> |
115 | 115 | <td class="date column-date"> |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | </table> |
125 | 125 | |
126 | 126 | <p><input class="button button-primary add" type="button" |
127 | - value="<?php esc_html_e( 'Add to List', 'lsx-wetu-importer' ); ?>"/> |
|
127 | + value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>"/> |
|
128 | 128 | <input class="button button-primary clear" type="button" |
129 | - value="<?php esc_html_e( 'Clear', 'lsx-wetu-importer' ); ?>"/> |
|
129 | + value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>"/> |
|
130 | 130 | </p> |
131 | 131 | </form> |
132 | 132 | |
@@ -136,118 +136,118 @@ discard block |
||
136 | 136 | |
137 | 137 | <div class="row"> |
138 | 138 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
139 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
139 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
140 | 140 | <ul> |
141 | 141 | <li> |
142 | - <input class="content select-all" <?php $this->checked( $this->destination_options, 'all' ); ?> |
|
142 | + <input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?> |
|
143 | 143 | type="checkbox" name="content[]" |
144 | - value="all"/> <?php esc_html_e( 'Select All', 'lsx-wetu-importer' ); ?></li> |
|
145 | - <?php if ( isset( $this->options ) && isset( $this->options['disable_destination_descriptions'] ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?> |
|
144 | + value="all"/> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li> |
|
145 | + <?php if (isset($this->options) && isset($this->options['disable_destination_descriptions']) && 'on' !== $this->options['disable_destination_descriptions']) { ?> |
|
146 | 146 | <li> |
147 | - <input class="content" <?php $this->checked( $this->destination_options, 'description' ); ?> |
|
147 | + <input class="content" <?php $this->checked($this->destination_options, 'description'); ?> |
|
148 | 148 | type="checkbox" name="content[]" |
149 | - value="description"/> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li> |
|
149 | + value="description"/> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li> |
|
150 | 150 | <?php } ?> |
151 | 151 | |
152 | 152 | <li> |
153 | - <input class="content" <?php $this->checked( $this->destination_options, 'gallery' ); ?> |
|
153 | + <input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?> |
|
154 | 154 | type="checkbox" name="content[]" |
155 | - value="gallery"/> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li> |
|
156 | - <?php if ( class_exists( 'LSX_TO_Maps' ) ) { ?> |
|
155 | + value="gallery"/> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li> |
|
156 | + <?php if (class_exists('LSX_TO_Maps')) { ?> |
|
157 | 157 | <li> |
158 | - <input class="content" <?php $this->checked( $this->destination_options, 'location' ); ?> |
|
158 | + <input class="content" <?php $this->checked($this->destination_options, 'location'); ?> |
|
159 | 159 | type="checkbox" name="content[]" |
160 | - value="location"/> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?></li> |
|
160 | + value="location"/> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?></li> |
|
161 | 161 | <?php } ?> |
162 | 162 | |
163 | - <?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?> |
|
163 | + <?php if (class_exists('LSX_TO_Videos')) { ?> |
|
164 | 164 | <li> |
165 | - <input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?> |
|
165 | + <input class="content" <?php $this->checked($this->destination_options, 'videos'); ?> |
|
166 | 166 | type="checkbox" name="content[]" |
167 | - value="videos"/> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li> |
|
167 | + value="videos"/> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li> |
|
168 | 168 | <?php } ?> |
169 | 169 | |
170 | 170 | </ul> |
171 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
171 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
172 | 172 | <ul> |
173 | 173 | <li> |
174 | - <input class="content" <?php $this->checked( $this->destination_options, 'country' ); ?> |
|
174 | + <input class="content" <?php $this->checked($this->destination_options, 'country'); ?> |
|
175 | 175 | type="checkbox" name="content[]" |
176 | - value="country"/> <?php esc_html_e( 'Set Country', 'lsx-wetu-importer' ); ?></li> |
|
176 | + value="country"/> <?php esc_html_e('Set Country', 'lsx-wetu-importer'); ?></li> |
|
177 | 177 | <li> |
178 | - <input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?> |
|
178 | + <input class="content" <?php $this->checked($this->destination_options, 'continent'); ?> |
|
179 | 179 | type="checkbox" name="content[]" |
180 | - value="continent"/> <?php esc_html_e( 'Set Continent', 'lsx-wetu-importer' ); ?></li> |
|
180 | + value="continent"/> <?php esc_html_e('Set Continent', 'lsx-wetu-importer'); ?></li> |
|
181 | 181 | |
182 | 182 | <li> |
183 | - <input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?> |
|
183 | + <input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?> |
|
184 | 184 | type="checkbox" name="content[]" |
185 | - value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?> |
|
185 | + value="featured_image"/> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?> |
|
186 | 186 | </li> |
187 | - <?php if ( class_exists( 'LSX_Banners' ) ) { ?> |
|
187 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
188 | 188 | <li> |
189 | - <input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?> |
|
189 | + <input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?> |
|
190 | 190 | type="checkbox" name="content[]" |
191 | - value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?> |
|
191 | + value="banner_image"/> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?> |
|
192 | 192 | </li> |
193 | 193 | <li> |
194 | - <input class="content" <?php $this->checked( $this->destination_options, 'unique_banner_image' ); ?> |
|
194 | + <input class="content" <?php $this->checked($this->destination_options, 'unique_banner_image'); ?> |
|
195 | 195 | type="checkbox" name="content[]" |
196 | - value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'lsx-wetu-importer' ); ?> |
|
196 | + value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'lsx-wetu-importer'); ?> |
|
197 | 197 | </li> |
198 | 198 | <?php } ?> |
199 | 199 | |
200 | 200 | <li> |
201 | - <input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?> |
|
201 | + <input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?> |
|
202 | 202 | type="checkbox" name="content[]" |
203 | - value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'lsx-wetu-importer' ); ?></li> |
|
203 | + value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'lsx-wetu-importer'); ?></li> |
|
204 | 204 | </ul> |
205 | 205 | </div> |
206 | 206 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
207 | - <h3><?php esc_html_e( 'Travel Information' ); ?></h3> |
|
207 | + <h3><?php esc_html_e('Travel Information'); ?></h3> |
|
208 | 208 | <ul> |
209 | 209 | <li> |
210 | - <input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?> |
|
210 | + <input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?> |
|
211 | 211 | type="checkbox" name="content[]" |
212 | - value="electricity"/> <?php esc_html_e( 'Electricity', 'lsx-wetu-importer' ); ?></li> |
|
212 | + value="electricity"/> <?php esc_html_e('Electricity', 'lsx-wetu-importer'); ?></li> |
|
213 | 213 | <li> |
214 | - <input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?> |
|
214 | + <input class="content" <?php $this->checked($this->destination_options, 'banking'); ?> |
|
215 | 215 | type="checkbox" name="content[]" |
216 | - value="banking"/> <?php esc_html_e( 'Banking', 'lsx-wetu-importer' ); ?></li> |
|
216 | + value="banking"/> <?php esc_html_e('Banking', 'lsx-wetu-importer'); ?></li> |
|
217 | 217 | <li> |
218 | - <input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?> |
|
218 | + <input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?> |
|
219 | 219 | type="checkbox" name="content[]" |
220 | - value="cuisine"/> <?php esc_html_e( 'Cuisine', 'lsx-wetu-importer' ); ?></li> |
|
220 | + value="cuisine"/> <?php esc_html_e('Cuisine', 'lsx-wetu-importer'); ?></li> |
|
221 | 221 | <li> |
222 | - <input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?> |
|
222 | + <input class="content" <?php $this->checked($this->destination_options, 'climate'); ?> |
|
223 | 223 | type="checkbox" name="content[]" |
224 | - value="climate"/> <?php esc_html_e( 'Climate', 'lsx-wetu-importer' ); ?></li> |
|
224 | + value="climate"/> <?php esc_html_e('Climate', 'lsx-wetu-importer'); ?></li> |
|
225 | 225 | <li> |
226 | - <input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?> |
|
226 | + <input class="content" <?php $this->checked($this->destination_options, 'transport'); ?> |
|
227 | 227 | type="checkbox" name="content[]" |
228 | - value="transport"/> <?php esc_html_e( 'Transport', 'lsx-wetu-importer' ); ?></li> |
|
229 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?> |
|
228 | + value="transport"/> <?php esc_html_e('Transport', 'lsx-wetu-importer'); ?></li> |
|
229 | + <li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?> |
|
230 | 230 | type="checkbox" name="content[]" |
231 | - value="dress"/> <?php esc_html_e( 'Dress', 'lsx-wetu-importer' ); ?></li> |
|
232 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?> |
|
231 | + value="dress"/> <?php esc_html_e('Dress', 'lsx-wetu-importer'); ?></li> |
|
232 | + <li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?> |
|
233 | 233 | type="checkbox" name="content[]" |
234 | - value="health"/> <?php esc_html_e( 'Health', 'lsx-wetu-importer' ); ?></li> |
|
235 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?> |
|
234 | + value="health"/> <?php esc_html_e('Health', 'lsx-wetu-importer'); ?></li> |
|
235 | + <li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?> |
|
236 | 236 | type="checkbox" name="content[]" |
237 | - value="safety"/> <?php esc_html_e( 'Safety', 'lsx-wetu-importer' ); ?></li> |
|
238 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?> |
|
237 | + value="safety"/> <?php esc_html_e('Safety', 'lsx-wetu-importer'); ?></li> |
|
238 | + <li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?> |
|
239 | 239 | type="checkbox" name="content[]" |
240 | - value="visa"/> <?php esc_html_e( 'Visa', 'lsx-wetu-importer' ); ?></li> |
|
241 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?> |
|
240 | + value="visa"/> <?php esc_html_e('Visa', 'lsx-wetu-importer'); ?></li> |
|
241 | + <li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?> |
|
242 | 242 | type="checkbox" name="content[]" |
243 | - value="additional_info"/> <?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></li> |
|
243 | + value="additional_info"/> <?php esc_html_e('General', 'lsx-wetu-importer'); ?></li> |
|
244 | 244 | </ul> |
245 | 245 | </div> |
246 | 246 | |
247 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
247 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
248 | 248 | <div style="width:30%;display:block;float:left;"> |
249 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
250 | - <?php $this->team_member_checkboxes( $this->destination_options ); ?> |
|
249 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
250 | + <?php $this->team_member_checkboxes($this->destination_options); ?> |
|
251 | 251 | </div> |
252 | 252 | <?php } ?> |
253 | 253 | |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | </div> |
256 | 256 | |
257 | 257 | |
258 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
258 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
259 | 259 | <p><input class="button button-primary" type="submit" |
260 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
260 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
261 | 261 | <table class="wp-list-table widefat fixed posts"> |
262 | 262 | <?php $this->table_header(); ?> |
263 | 263 | |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | </table> |
271 | 271 | |
272 | 272 | <p><input class="button button-primary" type="submit" |
273 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
273 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
274 | 274 | </form> |
275 | 275 | </div> |
276 | 276 | |
277 | 277 | <div style="display:none;" class="completed-list-wrapper"> |
278 | - <h3><?php esc_html_e( 'Completed' ); ?></h3> |
|
278 | + <h3><?php esc_html_e('Completed'); ?></h3> |
|
279 | 279 | <ul> |
280 | 280 | </ul> |
281 | 281 | </div> |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * Grab all the current destination posts via the lsx_wetu_id field. |
288 | 288 | */ |
289 | - public function find_current_destination( $post_type = 'destination' ) { |
|
289 | + public function find_current_destination($post_type = 'destination') { |
|
290 | 290 | global $wpdb; |
291 | 291 | $return = array(); |
292 | 292 | |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | "); |
306 | 306 | // @codingStandardsIgnoreEnd |
307 | 307 | |
308 | - if ( null !== $current_destination && ! empty( $current_destination ) ) { |
|
309 | - foreach ( $current_destination as $accom ) { |
|
310 | - $return[ $accom->meta_value ] = $accom; |
|
308 | + if (null !== $current_destination && !empty($current_destination)) { |
|
309 | + foreach ($current_destination as $accom) { |
|
310 | + $return[$accom->meta_value] = $accom; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -319,117 +319,117 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function process_ajax_search() { |
321 | 321 | $return = false; |
322 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
323 | - if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] ) { |
|
322 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
323 | + if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type']) { |
|
324 | 324 | |
325 | 325 | $searched_items = false; |
326 | - if ( isset( $_POST['keyword'] ) ) { |
|
327 | - $keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) ); |
|
328 | - } else { |
|
329 | - $keyphrases = array( 0 ); |
|
326 | + if (isset($_POST['keyword'])) { |
|
327 | + $keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword'])); |
|
328 | + }else { |
|
329 | + $keyphrases = array(0); |
|
330 | 330 | } |
331 | 331 | |
332 | - if ( ! is_array( $keyphrases ) ) { |
|
333 | - $keyphrases = array( $keyphrases ); |
|
332 | + if (!is_array($keyphrases)) { |
|
333 | + $keyphrases = array($keyphrases); |
|
334 | 334 | } |
335 | - foreach ( $keyphrases as &$keyword ) { |
|
336 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
335 | + foreach ($keyphrases as &$keyword) { |
|
336 | + $keyword = ltrim(rtrim($keyword)); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | $post_status = false; |
340 | 340 | |
341 | - if ( in_array( 'publish', $keyphrases ) ) { |
|
341 | + if (in_array('publish', $keyphrases)) { |
|
342 | 342 | $post_status = 'publish'; |
343 | 343 | } |
344 | - if ( in_array( 'pending', $keyphrases ) ) { |
|
344 | + if (in_array('pending', $keyphrases)) { |
|
345 | 345 | $post_status = 'pending'; |
346 | 346 | } |
347 | - if ( in_array( 'draft', $keyphrases ) ) { |
|
347 | + if (in_array('draft', $keyphrases)) { |
|
348 | 348 | $post_status = 'draft'; |
349 | 349 | } |
350 | - if ( in_array( 'import', $keyphrases ) ) { |
|
350 | + if (in_array('import', $keyphrases)) { |
|
351 | 351 | $post_status = 'import'; |
352 | 352 | } |
353 | 353 | |
354 | 354 | // If there is a post status use it. |
355 | - if ( false !== $post_status ) { |
|
355 | + if (false !== $post_status) { |
|
356 | 356 | |
357 | 357 | $accommodation = array(); |
358 | - $current_accommodation = $this->find_current_accommodation( 'destination' ); |
|
359 | - if ( ! empty( $current_accommodation ) ) { |
|
360 | - foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
361 | - $accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
|
358 | + $current_accommodation = $this->find_current_accommodation('destination'); |
|
359 | + if (!empty($current_accommodation)) { |
|
360 | + foreach ($current_accommodation as $cs_key => $ccs_id) { |
|
361 | + $accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | 365 | // Run through each accommodation and use it. |
366 | - if ( ! empty( $accommodation ) ) { |
|
367 | - foreach ( $accommodation as $row_key => $row ) { |
|
368 | - if ( 'import' === $post_status ) { |
|
369 | - |
|
370 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) { |
|
371 | - $current_status = get_post_status( $row['post_id'] ); |
|
372 | - if ( 'draft' === $current_status ) { |
|
373 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
366 | + if (!empty($accommodation)) { |
|
367 | + foreach ($accommodation as $row_key => $row) { |
|
368 | + if ('import' === $post_status) { |
|
369 | + |
|
370 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
371 | + $current_status = get_post_status($row['post_id']); |
|
372 | + if ('draft' === $current_status) { |
|
373 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
374 | 374 | } |
375 | - } else { |
|
375 | + }else { |
|
376 | 376 | continue; |
377 | 377 | } |
378 | - } else { |
|
379 | - if ( 0 === $row['post_id'] ) { |
|
378 | + }else { |
|
379 | + if (0 === $row['post_id']) { |
|
380 | 380 | continue; |
381 | - } else { |
|
382 | - $current_status = get_post_status( $row['post_id'] ); |
|
381 | + }else { |
|
382 | + $current_status = get_post_status($row['post_id']); |
|
383 | 383 | |
384 | - if ( $current_status !== $post_status ) { |
|
384 | + if ($current_status !== $post_status) { |
|
385 | 385 | continue; |
386 | 386 | } |
387 | 387 | } |
388 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
388 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | } |
392 | - } else { |
|
392 | + }else { |
|
393 | 393 | |
394 | - $key_string_search = implode( '+', $keyphrases ); |
|
395 | - $search_data = wp_remote_get( $this->url . '/Search/' . $key_string_search . '/?all=include' ); |
|
394 | + $key_string_search = implode('+', $keyphrases); |
|
395 | + $search_data = wp_remote_get($this->url.'/Search/'.$key_string_search.'/?all=include'); |
|
396 | 396 | |
397 | - if ( ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) { |
|
398 | - $search_data = json_decode( $search_data['body'], true ); |
|
399 | - foreach ( $search_data as $sdata ) { |
|
397 | + if (!empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) { |
|
398 | + $search_data = json_decode($search_data['body'], true); |
|
399 | + foreach ($search_data as $sdata) { |
|
400 | 400 | |
401 | - if ( 'Destination' !== trim( $sdata['type'] ) ) { |
|
401 | + if ('Destination' !== trim($sdata['type'])) { |
|
402 | 402 | continue; |
403 | 403 | } |
404 | 404 | |
405 | - $temp_id = $this->get_post_id_by_key_value( $sdata['id'] ); |
|
406 | - if ( false === $temp_id ) { |
|
405 | + $temp_id = $this->get_post_id_by_key_value($sdata['id']); |
|
406 | + if (false === $temp_id) { |
|
407 | 407 | $sdata['post_id'] = 0; |
408 | - } else { |
|
408 | + }else { |
|
409 | 409 | $sdata['post_id'] = $temp_id; |
410 | 410 | } |
411 | - $searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata ); |
|
411 | + $searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | - if ( false !== $searched_items ) { |
|
417 | - ksort( $searched_items ); |
|
418 | - $return = implode( $searched_items ); |
|
416 | + if (false !== $searched_items) { |
|
417 | + ksort($searched_items); |
|
418 | + $return = implode($searched_items); |
|
419 | 419 | } |
420 | 420 | |
421 | - print_r( $return ); |
|
421 | + print_r($return); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | die(); |
425 | 425 | } |
426 | 426 | |
427 | - public function prepare_row_attributes( $cs_key, $ccs_id ) { |
|
427 | + public function prepare_row_attributes($cs_key, $ccs_id) { |
|
428 | 428 | $row_item = array( |
429 | 429 | 'id' => $cs_key, |
430 | 430 | 'type' => 'Destination', |
431 | - 'name' => get_the_title( $ccs_id ), |
|
432 | - 'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ), |
|
431 | + 'name' => get_the_title($ccs_id), |
|
432 | + 'last_modified' => date('Y-m-d', strtotime('now')), |
|
433 | 433 | 'post_id' => $ccs_id, |
434 | 434 | ); |
435 | 435 | return $row_item; |
@@ -438,28 +438,28 @@ discard block |
||
438 | 438 | /** |
439 | 439 | * Formats the row for output on the screen. |
440 | 440 | */ |
441 | - public function format_row( $row = false ) { |
|
442 | - if ( false !== $row ) { |
|
441 | + public function format_row($row = false) { |
|
442 | + if (false !== $row) { |
|
443 | 443 | |
444 | 444 | $status = 'import'; |
445 | - if ( 0 !== $row['post_id'] ) { |
|
446 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
445 | + if (0 !== $row['post_id']) { |
|
446 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | $row_html = ' |
450 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
450 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
451 | 451 | <th class="check-column" scope="row"> |
452 | - <label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
453 | - <input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
|
452 | + <label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
453 | + <input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'"> |
|
454 | 454 | </th> |
455 | 455 | <td class="post-title page-title column-title"> |
456 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
456 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
457 | 457 | </td> |
458 | 458 | <td class="date column-date"> |
459 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
459 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
460 | 460 | </td> |
461 | 461 | <td class="ssid column-ssid"> |
462 | - ' . $row['id'] . ' |
|
462 | + ' . $row['id'].' |
|
463 | 463 | </td> |
464 | 464 | </tr>'; |
465 | 465 | return $row_html; |
@@ -472,44 +472,44 @@ discard block |
||
472 | 472 | public function process_ajax_import() { |
473 | 473 | $return = false; |
474 | 474 | |
475 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
476 | - if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) { |
|
475 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
476 | + if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type'] && isset($_POST['wetu_id'])) { |
|
477 | 477 | |
478 | - $wetu_id = sanitize_text_field( $_POST['wetu_id'] ); |
|
478 | + $wetu_id = sanitize_text_field($_POST['wetu_id']); |
|
479 | 479 | |
480 | - if ( isset( $_POST['post_id'] ) ) { |
|
481 | - $post_id = sanitize_text_field( $_POST['post_id'] ); |
|
482 | - $this->current_post = get_post( $post_id ); |
|
483 | - } else { |
|
480 | + if (isset($_POST['post_id'])) { |
|
481 | + $post_id = sanitize_text_field($_POST['post_id']); |
|
482 | + $this->current_post = get_post($post_id); |
|
483 | + }else { |
|
484 | 484 | $post_id = 0; |
485 | 485 | } |
486 | 486 | |
487 | - if ( isset( $_POST['team_members'] ) ) { |
|
488 | - $team_members = sanitize_text_field( $_POST['team_members'] ); |
|
489 | - } else { |
|
487 | + if (isset($_POST['team_members'])) { |
|
488 | + $team_members = sanitize_text_field($_POST['team_members']); |
|
489 | + }else { |
|
490 | 490 | $team_members = false; |
491 | 491 | } |
492 | 492 | |
493 | 493 | $safari_brands = false; |
494 | 494 | |
495 | - delete_option( 'lsx_wetu_importer_destination_settings' ); |
|
495 | + delete_option('lsx_wetu_importer_destination_settings'); |
|
496 | 496 | |
497 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
498 | - $content = sanitize_textarea_field( $_POST['content'] ); |
|
499 | - add_option( 'lsx_wetu_importer_destination_settings', $content ); |
|
500 | - } else { |
|
497 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
498 | + $content = sanitize_textarea_field($_POST['content']); |
|
499 | + add_option('lsx_wetu_importer_destination_settings', $content); |
|
500 | + }else { |
|
501 | 501 | $content = false; |
502 | 502 | } |
503 | 503 | |
504 | - $jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
504 | + $jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
505 | 505 | |
506 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
507 | - $adata = json_decode( $jdata, true ); |
|
508 | - $return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
|
509 | - $this->remove_from_queue( $return ); |
|
510 | - $this->format_completed_row( $return ); |
|
511 | - } else { |
|
512 | - $this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer' ) ); |
|
506 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
507 | + $adata = json_decode($jdata, true); |
|
508 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
509 | + $this->remove_from_queue($return); |
|
510 | + $this->format_completed_row($return); |
|
511 | + }else { |
|
512 | + $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer')); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | } |
@@ -517,14 +517,14 @@ discard block |
||
517 | 517 | /** |
518 | 518 | * Saves the queue to the option. |
519 | 519 | */ |
520 | - public function remove_from_queue( $id ) { |
|
521 | - if ( ! empty( $this->queued_imports ) ) { |
|
522 | - $key = array_search( $id, $this->queued_imports ); |
|
523 | - if ( false !== $key ) { |
|
524 | - unset( $this->queued_imports[ $key ] ); |
|
520 | + public function remove_from_queue($id) { |
|
521 | + if (!empty($this->queued_imports)) { |
|
522 | + $key = array_search($id, $this->queued_imports); |
|
523 | + if (false !== $key) { |
|
524 | + unset($this->queued_imports[$key]); |
|
525 | 525 | |
526 | - delete_option( 'lsx_wetu_importer_que' ); |
|
527 | - update_option( 'lsx_wetu_importer_que', $this->queued_imports ); |
|
526 | + delete_option('lsx_wetu_importer_que'); |
|
527 | + update_option('lsx_wetu_importer_que', $this->queued_imports); |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | } |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | /** |
533 | 533 | * Connect to wetu |
534 | 534 | */ |
535 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) { |
|
536 | - if ( 'Destination' === trim( $data[0]['type'] ) ) { |
|
535 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) { |
|
536 | + if ('Destination' === trim($data[0]['type'])) { |
|
537 | 537 | $post_name = ''; |
538 | 538 | $data_post_content = ''; |
539 | 539 | $data_post_excerpt = ''; |
@@ -542,132 +542,132 @@ discard block |
||
542 | 542 | 'post_type' => 'destination', |
543 | 543 | ); |
544 | 544 | |
545 | - if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) { |
|
546 | - $parent = $this->check_for_parent( $data ); |
|
547 | - if ( false !== $parent ) { |
|
545 | + if (!empty($importable_content) && in_array('country', $importable_content)) { |
|
546 | + $parent = $this->check_for_parent($data); |
|
547 | + if (false !== $parent) { |
|
548 | 548 | $post['post_parent'] = $parent; |
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | 552 | // Set the post_content. |
553 | - if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
554 | - if ( isset( $data[0]['content']['general_description'] ) ) { |
|
553 | + if (!empty($importable_content) && in_array('description', $importable_content)) { |
|
554 | + if (isset($data[0]['content']['general_description'])) { |
|
555 | 555 | |
556 | - if ( in_array( 'strip_tags', $importable_content ) ) { |
|
557 | - $post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] ); |
|
558 | - } else { |
|
556 | + if (in_array('strip_tags', $importable_content)) { |
|
557 | + $post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']); |
|
558 | + }else { |
|
559 | 559 | $post['post_content'] = $data[0]['content']['general_description']; |
560 | 560 | } |
561 | 561 | } |
562 | 562 | } |
563 | 563 | |
564 | - if ( false !== $id && '0' !== $id ) { |
|
564 | + if (false !== $id && '0' !== $id) { |
|
565 | 565 | $post['ID'] = $id; |
566 | 566 | |
567 | - if ( isset( $data[0]['name'] ) ) { |
|
567 | + if (isset($data[0]['name'])) { |
|
568 | 568 | $post['post_title'] = $data[0]['name']; |
569 | 569 | $post['post_status'] = 'publish'; |
570 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
570 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
571 | 571 | } |
572 | 572 | |
573 | - $id = wp_update_post( $post ); |
|
574 | - $prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
575 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
576 | - } else { |
|
573 | + $id = wp_update_post($post); |
|
574 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
575 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
576 | + }else { |
|
577 | 577 | // Set the name. |
578 | - if ( isset( $data[0]['name'] ) ) { |
|
579 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
578 | + if (isset($data[0]['name'])) { |
|
579 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | $post['post_name'] = $post_name; |
583 | 583 | $post['post_title'] = $data[0]['name']; |
584 | 584 | $post['post_status'] = 'publish'; |
585 | - $id = wp_insert_post( $post ); |
|
585 | + $id = wp_insert_post($post); |
|
586 | 586 | |
587 | 587 | // Save the WETU ID and the Last date it was modified. |
588 | - if ( false !== $id ) { |
|
589 | - add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
590 | - add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
|
588 | + if (false !== $id) { |
|
589 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
590 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
594 | - $this->find_attachments( $id ); |
|
594 | + $this->find_attachments($id); |
|
595 | 595 | |
596 | 596 | // Set the team member if it is there. |
597 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
598 | - $this->set_team_member( $id, $team_members ); |
|
597 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
598 | + $this->set_team_member($id, $team_members); |
|
599 | 599 | } |
600 | 600 | |
601 | - if ( class_exists( 'LSX_TO_Maps' ) ) { |
|
602 | - $this->set_map_data( $data, $id, 9 ); |
|
601 | + if (class_exists('LSX_TO_Maps')) { |
|
602 | + $this->set_map_data($data, $id, 9); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | // Set the Room Data. |
606 | - if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) { |
|
607 | - $this->set_video_data( $data, $id ); |
|
606 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
607 | + $this->set_video_data($data, $id); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | // Set the Electricity. |
611 | - if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) { |
|
612 | - $this->set_travel_info( $data, $id, 'electricity', $importable_content ); |
|
611 | + if (false !== $importable_content && in_array('electricity', $importable_content)) { |
|
612 | + $this->set_travel_info($data, $id, 'electricity', $importable_content); |
|
613 | 613 | } |
614 | 614 | // Set the cuisine. |
615 | - if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) { |
|
616 | - $this->set_travel_info( $data, $id, 'cuisine', $importable_content ); |
|
615 | + if (false !== $importable_content && in_array('cuisine', $importable_content)) { |
|
616 | + $this->set_travel_info($data, $id, 'cuisine', $importable_content); |
|
617 | 617 | } |
618 | 618 | // Set the banking. |
619 | - if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) { |
|
620 | - $this->set_travel_info( $data, $id, 'banking', $importable_content ); |
|
619 | + if (false !== $importable_content && in_array('banking', $importable_content)) { |
|
620 | + $this->set_travel_info($data, $id, 'banking', $importable_content); |
|
621 | 621 | } |
622 | 622 | // Set the transport. |
623 | - if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) { |
|
624 | - $this->set_travel_info( $data, $id, 'transport', $importable_content ); |
|
623 | + if (false !== $importable_content && in_array('transport', $importable_content)) { |
|
624 | + $this->set_travel_info($data, $id, 'transport', $importable_content); |
|
625 | 625 | } |
626 | 626 | // Set the dress. |
627 | - if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) { |
|
628 | - $this->set_travel_info( $data, $id, 'dress', $importable_content ); |
|
627 | + if (false !== $importable_content && in_array('dress', $importable_content)) { |
|
628 | + $this->set_travel_info($data, $id, 'dress', $importable_content); |
|
629 | 629 | } |
630 | 630 | // Set the climate. |
631 | - if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) { |
|
632 | - $this->set_travel_info( $data, $id, 'climate', $importable_content ); |
|
631 | + if (false !== $importable_content && in_array('climate', $importable_content)) { |
|
632 | + $this->set_travel_info($data, $id, 'climate', $importable_content); |
|
633 | 633 | } |
634 | 634 | // Set the Health. |
635 | - if ( false !== $importable_content && in_array( 'health', $importable_content ) ) { |
|
636 | - $this->set_travel_info( $data, $id, 'health', $importable_content ); |
|
635 | + if (false !== $importable_content && in_array('health', $importable_content)) { |
|
636 | + $this->set_travel_info($data, $id, 'health', $importable_content); |
|
637 | 637 | } |
638 | 638 | // Set the Safety. |
639 | - if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) { |
|
640 | - $this->set_travel_info( $data, $id, 'safety', $importable_content ); |
|
639 | + if (false !== $importable_content && in_array('safety', $importable_content)) { |
|
640 | + $this->set_travel_info($data, $id, 'safety', $importable_content); |
|
641 | 641 | } |
642 | 642 | // Set the Visa. |
643 | - if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) { |
|
644 | - $this->set_travel_info( $data, $id, 'visa', $importable_content ); |
|
643 | + if (false !== $importable_content && in_array('visa', $importable_content)) { |
|
644 | + $this->set_travel_info($data, $id, 'visa', $importable_content); |
|
645 | 645 | } |
646 | 646 | // Set the General. |
647 | - if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) { |
|
648 | - $this->set_travel_info( $data, $id, 'additional_info', $importable_content ); |
|
647 | + if (false !== $importable_content && in_array('additional_info', $importable_content)) { |
|
648 | + $this->set_travel_info($data, $id, 'additional_info', $importable_content); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | // Setup some default for use in the import. |
652 | - if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) { |
|
653 | - $this->find_attachments( $id ); |
|
652 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
653 | + $this->find_attachments($id); |
|
654 | 654 | |
655 | 655 | // Set the featured image. |
656 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
657 | - $this->set_featured_image( $data, $id ); |
|
656 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
657 | + $this->set_featured_image($data, $id); |
|
658 | 658 | } |
659 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
660 | - $this->set_banner_image( $data, $id, $importable_content ); |
|
659 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
660 | + $this->set_banner_image($data, $id, $importable_content); |
|
661 | 661 | } |
662 | 662 | // Import the main gallery. |
663 | - if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) { |
|
664 | - $this->create_main_gallery( $data, $id ); |
|
663 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
664 | + $this->create_main_gallery($data, $id); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | 668 | // Set the continent. |
669 | - if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) { |
|
670 | - $this->set_continent( $data, $id ); |
|
669 | + if (false !== $importable_content && in_array('continent', $importable_content)) { |
|
670 | + $this->set_continent($data, $id); |
|
671 | 671 | } |
672 | 672 | } |
673 | 673 | |
@@ -677,48 +677,48 @@ discard block |
||
677 | 677 | /** |
678 | 678 | * Set the team memberon each item. |
679 | 679 | */ |
680 | - public function set_team_member( $id, $team_members ) { |
|
681 | - delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
|
680 | + public function set_team_member($id, $team_members) { |
|
681 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
682 | 682 | |
683 | - foreach ( $team_members as $team ) { |
|
684 | - add_post_meta( $id, 'team_to_' . $this->tab_slug, $team ); |
|
683 | + foreach ($team_members as $team) { |
|
684 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
689 | 689 | * Saves the room data |
690 | 690 | */ |
691 | - public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) { |
|
692 | - if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) { |
|
693 | - $content = $data[0]['travel_information'][ $meta_key ]; |
|
691 | + public function set_travel_info($data, $id, $meta_key, $importable = array('none')) { |
|
692 | + if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) { |
|
693 | + $content = $data[0]['travel_information'][$meta_key]; |
|
694 | 694 | |
695 | - if ( in_array( 'strip_tags', $importable ) ) { |
|
696 | - $content = strip_tags( $content ); |
|
695 | + if (in_array('strip_tags', $importable)) { |
|
696 | + $content = strip_tags($content); |
|
697 | 697 | } |
698 | 698 | |
699 | - $this->save_custom_field( $content, $meta_key, $id ); |
|
699 | + $this->save_custom_field($content, $meta_key, $id); |
|
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | 704 | * Set the Travel Style |
705 | 705 | */ |
706 | - public function set_continent( $data, $id ) { |
|
706 | + public function set_continent($data, $id) { |
|
707 | 707 | |
708 | - if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) { |
|
708 | + if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) { |
|
709 | 709 | //get the continent code. |
710 | - $continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) ); |
|
710 | + $continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false))); |
|
711 | 711 | |
712 | - if ( '' !== $continent_code ) { |
|
713 | - $term = term_exists( trim( $continent_code ), 'continent' ); |
|
714 | - if ( ! $term ) { |
|
715 | - $term = wp_insert_term( trim( $continent_code ), 'continent' ); |
|
712 | + if ('' !== $continent_code) { |
|
713 | + $term = term_exists(trim($continent_code), 'continent'); |
|
714 | + if (!$term) { |
|
715 | + $term = wp_insert_term(trim($continent_code), 'continent'); |
|
716 | 716 | |
717 | - if ( is_wp_error( $term ) ) { |
|
718 | - echo wp_kses_post( $term->get_error_message() ); |
|
717 | + if (is_wp_error($term)) { |
|
718 | + echo wp_kses_post($term->get_error_message()); |
|
719 | 719 | } |
720 | - } else { |
|
721 | - wp_set_object_terms( $id, sanitize_title( $continent_code ), 'continent', true ); |
|
720 | + }else { |
|
721 | + wp_set_object_terms($id, sanitize_title($continent_code), 'continent', true); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | } |
@@ -728,10 +728,10 @@ discard block |
||
728 | 728 | * Save the list of Accommodation into an option |
729 | 729 | */ |
730 | 730 | public function update_options() { |
731 | - $data = wp_remote_get( $this->url . '/List?' . $this->url_qs ); |
|
732 | - if ( ! empty( $data ) && isset( $data['response'] ) && isset( $data['response']['code'] ) && 200 === $data['response']['code'] ) { |
|
733 | - $accommodation = json_decode( $data['body'], true ); |
|
734 | - set_transient( 'lsx_ti_accommodation', $accommodation, 60 * 60 * 2 ); |
|
731 | + $data = wp_remote_get($this->url.'/List?'.$this->url_qs); |
|
732 | + if (!empty($data) && isset($data['response']) && isset($data['response']['code']) && 200 === $data['response']['code']) { |
|
733 | + $accommodation = json_decode($data['body'], true); |
|
734 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
735 | 735 | return true; |
736 | 736 | } |
737 | 737 | } |
@@ -740,11 +740,11 @@ discard block |
||
740 | 740 | * search_form |
741 | 741 | */ |
742 | 742 | public function update_options_form() { |
743 | - echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'lsx-wetu-importer' ) . '</h3>'; |
|
743 | + echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').'</h3>'; |
|
744 | 744 | |
745 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
745 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
746 | 746 | |
747 | - if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) { |
|
747 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
748 | 748 | $this->update_options(); |
749 | 749 | } |
750 | 750 | |
@@ -754,12 +754,12 @@ discard block |
||
754 | 754 | /** |
755 | 755 | * Save the list of Accommodation into an option |
756 | 756 | */ |
757 | - public function check_for_parent( $data = array() ) { |
|
757 | + public function check_for_parent($data = array()) { |
|
758 | 758 | global $wpdb; |
759 | 759 | |
760 | - if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) { |
|
761 | - $result = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array( $data[0]['position']['country_content_entity_id'] ) ) ); |
|
762 | - if ( ! empty( $result ) && '' !== $result && false !== $result ) { |
|
760 | + if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) { |
|
761 | + $result = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array($data[0]['position']['country_content_entity_id']))); |
|
762 | + if (!empty($result) && '' !== $result && false !== $result) { |
|
763 | 763 | return $result; |
764 | 764 | } |
765 | 765 | } |