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