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