@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $this->api_username = false; |
| 217 | 217 | $this->api_password = false; |
| 218 | 218 | |
| 219 | - if(!defined('WETU_API_KEY')) { |
|
| 219 | + if(!defined('WETU_API_KEY')) { |
|
| 220 | 220 | |
| 221 | 221 | if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) { |
| 222 | 222 | $this->api_key = $temp_options['api']['wetu_api_key']; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | }else{ |
| 231 | 231 | $this->api_key = WETU_API_KEY; |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | //Set the tab slug |
| 235 | 235 | if(isset($_GET['tab']) || isset($_POST['type'])) { |
@@ -245,22 +245,22 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | //Set the scaling options |
| 248 | - if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) { |
|
| 249 | - $this->scale_images = true; |
|
| 250 | - $width = '1024'; |
|
| 251 | - if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
| 252 | - $width = $this->options['width']; |
|
| 253 | - } |
|
| 254 | - $height = '768'; |
|
| 255 | - if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
| 256 | - $height = $this->options['height']; |
|
| 257 | - } |
|
| 258 | - $cropping = 'w'; |
|
| 259 | - if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
| 260 | - $cropping = $this->options['cropping']; |
|
| 261 | - } |
|
| 262 | - $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
| 263 | - } |
|
| 248 | + if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) { |
|
| 249 | + $this->scale_images = true; |
|
| 250 | + $width = '1024'; |
|
| 251 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
| 252 | + $width = $this->options['width']; |
|
| 253 | + } |
|
| 254 | + $height = '768'; |
|
| 255 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
| 256 | + $height = $this->options['height']; |
|
| 257 | + } |
|
| 258 | + $cropping = 'w'; |
|
| 259 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
| 260 | + $cropping = $this->options['cropping']; |
|
| 261 | + } |
|
| 262 | + $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -334,10 +334,10 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | // DISPLAY FUNCTIONS |
| 336 | 336 | |
| 337 | - /* |
|
| 337 | + /* |
|
| 338 | 338 | * Load the importer class you want to use |
| 339 | 339 | */ |
| 340 | - public function load_class(){ |
|
| 340 | + public function load_class(){ |
|
| 341 | 341 | |
| 342 | 342 | switch($this->tab_slug){ |
| 343 | 343 | case 'accommodation': |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | break; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - } |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | 363 | * Registers the admin page which will house the importer form. |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | <?php*/ |
| 414 | 414 | }else{ |
| 415 | 415 | $this->current_importer->display_page(); |
| 416 | - }; ?> |
|
| 416 | + }; ?> |
|
| 417 | 417 | </div> |
| 418 | 418 | <?php |
| 419 | 419 | } |
@@ -813,12 +813,12 @@ discard block |
||
| 813 | 813 | */ |
| 814 | 814 | public function set_featured_image($data,$id) { |
| 815 | 815 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
| 816 | - if('tour' === $this->tab_slug){ |
|
| 817 | - $key = array_rand($data[0]['content']['images']); |
|
| 818 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id); |
|
| 819 | - }else{ |
|
| 816 | + if('tour' === $this->tab_slug){ |
|
| 817 | + $key = array_rand($data[0]['content']['images']); |
|
| 818 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id); |
|
| 819 | + }else{ |
|
| 820 | 820 | $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
| 821 | - } |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | 823 | |
| 824 | 824 | if(false !== $this->featured_image){ |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | */ |
| 839 | 839 | public function set_banner_image($data,$id) { |
| 840 | 840 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
| 841 | - if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
| 841 | + if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
| 842 | 842 | $temp_banner = $this->attach_image($data[0]['destination_image'], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
| 843 | 843 | }else{ |
| 844 | 844 | if ('tour' === $this->tab_slug) { |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | } else { |
| 848 | 848 | $temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
| 849 | 849 | } |
| 850 | - } |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | 852 | |
| 853 | 853 | if(false !== $temp_banner){ |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | * Run through the accommodation grabbed from the DB. |
| 1060 | 1060 | */ |
| 1061 | 1061 | public function process_ajax_search() { |
| 1062 | - $this->current_importer->process_ajax_search(); |
|
| 1062 | + $this->current_importer->process_ajax_search(); |
|
| 1063 | 1063 | die(); |
| 1064 | 1064 | } |
| 1065 | 1065 | |
@@ -162,31 +162,31 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function __construct() { |
| 164 | 164 | |
| 165 | - add_action( 'admin_init', array( $this, 'compatible_version_check' ) ); |
|
| 165 | + add_action('admin_init', array($this, 'compatible_version_check')); |
|
| 166 | 166 | |
| 167 | 167 | // Don't run anything else in the plugin, if we're on an incompatible PHP version |
| 168 | - if ( ! self::compatible_version() ) { |
|
| 168 | + if (!self::compatible_version()) { |
|
| 169 | 169 | return; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $this->set_variables(); |
| 173 | 173 | |
| 174 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
| 175 | - add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 ); |
|
| 176 | - add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 ); |
|
| 174 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
| 175 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11); |
|
| 176 | + add_action('admin_menu', array($this, 'register_importer_page'), 20); |
|
| 177 | 177 | |
| 178 | 178 | require_once(WETU_IMPORTER_PATH.'classes/class-accommodation.php'); |
| 179 | 179 | require_once(WETU_IMPORTER_PATH.'classes/class-destination.php'); |
| 180 | 180 | require_once(WETU_IMPORTER_PATH.'classes/class-tours.php'); |
| 181 | 181 | |
| 182 | - add_action( 'init', array( $this, 'load_class' ) ); |
|
| 182 | + add_action('init', array($this, 'load_class')); |
|
| 183 | 183 | |
| 184 | - if('default' !== $this->tab_slug){ |
|
| 185 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
| 186 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
| 184 | + if ('default' !== $this->tab_slug) { |
|
| 185 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
| 186 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
| 187 | 187 | |
| 188 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
| 189 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
| 188 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
| 189 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
@@ -198,25 +198,25 @@ discard block |
||
| 198 | 198 | * @since 1.0.0 |
| 199 | 199 | */ |
| 200 | 200 | public function load_plugin_textdomain() { |
| 201 | - load_plugin_textdomain( 'wetu-importer', FALSE, basename( WETU_IMPORTER_PATH ) . '/languages'); |
|
| 201 | + load_plugin_textdomain('wetu-importer', FALSE, basename(WETU_IMPORTER_PATH).'/languages'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
| 205 | 205 | * Sets the variables used throughout the plugin. |
| 206 | 206 | */ |
| 207 | 207 | public function set_variables() { |
| 208 | - $this->post_types = array('accommodation','destination','tour'); |
|
| 209 | - $temp_options = get_option('_lsx-to_settings',false); |
|
| 208 | + $this->post_types = array('accommodation', 'destination', 'tour'); |
|
| 209 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 210 | 210 | |
| 211 | 211 | //Set the options. |
| 212 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug])) { |
|
| 212 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug])) { |
|
| 213 | 213 | $this->options = $temp_options[$this->plugin_slug]; |
| 214 | 214 | |
| 215 | 215 | $this->api_key = false; |
| 216 | 216 | $this->api_username = false; |
| 217 | 217 | $this->api_password = false; |
| 218 | 218 | |
| 219 | - if(!defined('WETU_API_KEY')) { |
|
| 219 | + if (!defined('WETU_API_KEY')) { |
|
| 220 | 220 | |
| 221 | 221 | if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) { |
| 222 | 222 | $this->api_key = $temp_options['api']['wetu_api_key']; |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) { |
| 228 | 228 | $this->api_password = $temp_options['api']['wetu_api_password']; |
| 229 | 229 | } |
| 230 | - }else{ |
|
| 230 | + }else { |
|
| 231 | 231 | $this->api_key = WETU_API_KEY; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | //Set the tab slug |
| 235 | - if(isset($_GET['tab']) || isset($_POST['type'])) { |
|
| 235 | + if (isset($_GET['tab']) || isset($_POST['type'])) { |
|
| 236 | 236 | if (isset($_GET['tab'])) { |
| 237 | 237 | $this->tab_slug = $_GET['tab']; |
| 238 | - } else { |
|
| 238 | + }else { |
|
| 239 | 239 | $this->tab_slug = $_POST['type']; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
| 260 | 260 | $cropping = $this->options['cropping']; |
| 261 | 261 | } |
| 262 | - $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
| 262 | + $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/'; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @since 1.0.0 |
| 283 | 283 | */ |
| 284 | 284 | public static function compatible_version() { |
| 285 | - if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { |
|
| 285 | + if (version_compare(PHP_VERSION, '5.6', '<')) { |
|
| 286 | 286 | return false; |
| 287 | 287 | } |
| 288 | 288 | |
@@ -296,13 +296,13 @@ discard block |
||
| 296 | 296 | * @since 1.0.0 |
| 297 | 297 | */ |
| 298 | 298 | public function compatible_version_check() { |
| 299 | - if ( ! self::compatible_version() ) { |
|
| 300 | - if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) { |
|
| 301 | - deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) ); |
|
| 302 | - add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) ); |
|
| 299 | + if (!self::compatible_version()) { |
|
| 300 | + if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) { |
|
| 301 | + deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE)); |
|
| 302 | + add_action('admin_notices', array($this, 'compatible_version_notice')); |
|
| 303 | 303 | |
| 304 | - if ( isset( $_GET['activate'] ) ) { |
|
| 305 | - unset( $_GET['activate'] ); |
|
| 304 | + if (isset($_GET['activate'])) { |
|
| 305 | + unset($_GET['activate']); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -315,8 +315,8 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public function compatible_version_notice() { |
| 317 | 317 | $class = 'notice notice-error'; |
| 318 | - $message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ); |
|
| 319 | - printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) ); |
|
| 318 | + $message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'); |
|
| 319 | + printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message)); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | * @since 1.0.0 |
| 327 | 327 | */ |
| 328 | 328 | public static function compatible_version_check_on_activation() { |
| 329 | - if ( ! self::compatible_version() ) { |
|
| 330 | - deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) ); |
|
| 331 | - wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) ); |
|
| 329 | + if (!self::compatible_version()) { |
|
| 330 | + deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE)); |
|
| 331 | + wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer')); |
|
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | |
@@ -337,9 +337,9 @@ discard block |
||
| 337 | 337 | /* |
| 338 | 338 | * Load the importer class you want to use |
| 339 | 339 | */ |
| 340 | - public function load_class(){ |
|
| 340 | + public function load_class() { |
|
| 341 | 341 | |
| 342 | - switch($this->tab_slug){ |
|
| 342 | + switch ($this->tab_slug) { |
|
| 343 | 343 | case 'accommodation': |
| 344 | 344 | $this->current_importer = new WETU_Importer_Accommodation(); |
| 345 | 345 | break; |
@@ -363,25 +363,25 @@ discard block |
||
| 363 | 363 | * Registers the admin page which will house the importer form. |
| 364 | 364 | */ |
| 365 | 365 | public function register_importer_page() { |
| 366 | - add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) ); |
|
| 366 | + add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page')); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
| 370 | 370 | * Enqueue the JS needed to contact wetu and return your result. |
| 371 | 371 | */ |
| 372 | 372 | public function admin_scripts() { |
| 373 | - if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { |
|
| 373 | + if (defined('WP_DEBUG') && true === WP_DEBUG) { |
|
| 374 | 374 | $min = ''; |
| 375 | - } else { |
|
| 375 | + }else { |
|
| 376 | 376 | $min = '.min'; |
| 377 | 377 | } |
| 378 | 378 | $min = ''; |
| 379 | 379 | |
| 380 | - if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){ |
|
| 381 | - wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true ); |
|
| 382 | - wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array( |
|
| 380 | + if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) { |
|
| 381 | + wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true); |
|
| 382 | + wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array( |
|
| 383 | 383 | 'ajax_url' => admin_url('admin-ajax.php'), |
| 384 | - ) ); |
|
| 384 | + )); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -393,14 +393,14 @@ discard block |
||
| 393 | 393 | <div class="wrap"> |
| 394 | 394 | <?php screen_icon(); ?> |
| 395 | 395 | |
| 396 | - <?php if(!is_object($this->current_importer)){ |
|
| 396 | + <?php if (!is_object($this->current_importer)) { |
|
| 397 | 397 | ?> |
| 398 | - <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2> |
|
| 398 | + <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2> |
|
| 399 | 399 | <p>If this is the first time you are running the import, then follow the steps below.</p> |
| 400 | 400 | <ul> |
| 401 | - <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> |
|
| 402 | - <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> |
|
| 403 | - <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> |
|
| 401 | + <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> |
|
| 402 | + <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> |
|
| 403 | + <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> |
|
| 404 | 404 | </ul> |
| 405 | 405 | |
| 406 | 406 | <?php /*<h3><?php _e('Additional Tools','wetu-importer'); ?></h3> |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | <?php } ?> |
| 412 | 412 | </ul> |
| 413 | 413 | <?php*/ |
| 414 | - }else{ |
|
| 414 | + }else { |
|
| 415 | 415 | $this->current_importer->display_page(); |
| 416 | 416 | }; ?> |
| 417 | 417 | </div> |
@@ -426,38 +426,38 @@ discard block |
||
| 426 | 426 | <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>"> |
| 427 | 427 | <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" /> |
| 428 | 428 | |
| 429 | - <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3> |
|
| 429 | + <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3> |
|
| 430 | 430 | |
| 431 | - <?php do_action('wetu_importer_search_form',$this); ?> |
|
| 431 | + <?php do_action('wetu_importer_search_form', $this); ?> |
|
| 432 | 432 | |
| 433 | 433 | <div class="normal-search"> |
| 434 | - <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'); ?>" /> |
|
| 434 | + <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'); ?>" /> |
|
| 435 | 435 | </div> |
| 436 | 436 | <div class="advanced-search hidden" style="display:none;"> |
| 437 | - <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p> |
|
| 437 | + <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p> |
|
| 438 | 438 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
| 439 | - <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
| 439 | + <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
| 440 | 440 | </div> |
| 441 | 441 | |
| 442 | 442 | <p> |
| 443 | - <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> | |
|
| 444 | - <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> | |
|
| 445 | - <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> | |
|
| 446 | - <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> |
|
| 447 | - |
|
| 448 | - <?php if('tour'===$this->tab_slug){ ?> |
|
| 449 | - | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a> |
|
| 450 | - <?php }else if(!empty($this->queued_imports)) { ?> |
|
| 451 | - | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU Queue','wetu-importer'); ?></a> |
|
| 443 | + <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> | |
|
| 444 | + <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> | |
|
| 445 | + <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> | |
|
| 446 | + <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> |
|
| 447 | + |
|
| 448 | + <?php if ('tour' === $this->tab_slug) { ?> |
|
| 449 | + | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a> |
|
| 450 | + <?php }else if (!empty($this->queued_imports)) { ?> |
|
| 451 | + | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU Queue', 'wetu-importer'); ?></a> |
|
| 452 | 452 | <?php } ?> |
| 453 | 453 | </p> |
| 454 | 454 | |
| 455 | 455 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
| 456 | - <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
| 456 | + <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
| 457 | 457 | </div> |
| 458 | 458 | |
| 459 | 459 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
| 460 | - <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
| 460 | + <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
| 461 | 461 | </div> |
| 462 | 462 | </form> |
| 463 | 463 | <?php |
@@ -506,15 +506,15 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @param $tab string |
| 508 | 508 | */ |
| 509 | - public function navigation($tab='') { |
|
| 509 | + public function navigation($tab = '') { |
|
| 510 | 510 | $post_types = array( |
| 511 | - 'tour' => esc_attr('Tours','wetu-importer'), |
|
| 512 | - 'accommodation' => esc_attr('Accommodation','wetu-importer'), |
|
| 513 | - 'destination' => esc_attr('Destinations','wetu-importer'), |
|
| 511 | + 'tour' => esc_attr('Tours', 'wetu-importer'), |
|
| 512 | + 'accommodation' => esc_attr('Accommodation', 'wetu-importer'), |
|
| 513 | + 'destination' => esc_attr('Destinations', 'wetu-importer'), |
|
| 514 | 514 | ); |
| 515 | - 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>'; |
|
| 516 | - foreach($post_types as $post_type => $label){ |
|
| 517 | - echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
| 515 | + 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>'; |
|
| 516 | + foreach ($post_types as $post_type => $label) { |
|
| 517 | + echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
| 518 | 518 | } |
| 519 | 519 | echo '</div><br clear="both"/></div>'; |
| 520 | 520 | } |
@@ -522,23 +522,23 @@ discard block |
||
| 522 | 522 | /** |
| 523 | 523 | * set_taxonomy with some terms |
| 524 | 524 | */ |
| 525 | - public function team_member_checkboxes($selected=array()) { |
|
| 526 | - if(post_type_exists('team')) { ?> |
|
| 525 | + public function team_member_checkboxes($selected = array()) { |
|
| 526 | + if (post_type_exists('team')) { ?> |
|
| 527 | 527 | <ul> |
| 528 | 528 | <?php |
| 529 | - $team_args=array( |
|
| 529 | + $team_args = array( |
|
| 530 | 530 | 'post_type' => 'team', |
| 531 | 531 | 'post_status' => 'publish', |
| 532 | 532 | 'nopagin' => true, |
| 533 | 533 | 'fields' => 'ids' |
| 534 | 534 | ); |
| 535 | 535 | $team_members = new WP_Query($team_args); |
| 536 | - if($team_members->have_posts()){ |
|
| 537 | - foreach($team_members->posts as $member){ ?> |
|
| 538 | - <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
|
| 536 | + if ($team_members->have_posts()) { |
|
| 537 | + foreach ($team_members->posts as $member) { ?> |
|
| 538 | + <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
|
| 539 | 539 | <?php } |
| 540 | - }else{ ?> |
|
| 541 | - <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li> |
|
| 540 | + }else { ?> |
|
| 541 | + <li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li> |
|
| 542 | 542 | <?php } |
| 543 | 543 | ?> |
| 544 | 544 | </ul> |
@@ -555,12 +555,12 @@ discard block |
||
| 555 | 555 | * @param $needle string |
| 556 | 556 | * @param $echo bool |
| 557 | 557 | */ |
| 558 | - public function checked($haystack=false,$needle='',$echo=true) { |
|
| 559 | - $return = $this->itemd($haystack,$needle,'checked'); |
|
| 560 | - if('' !== $return) { |
|
| 558 | + public function checked($haystack = false, $needle = '', $echo = true) { |
|
| 559 | + $return = $this->itemd($haystack, $needle, 'checked'); |
|
| 560 | + if ('' !== $return) { |
|
| 561 | 561 | if (true === $echo) { |
| 562 | 562 | echo $return; |
| 563 | - } else { |
|
| 563 | + }else { |
|
| 564 | 564 | return $return; |
| 565 | 565 | } |
| 566 | 566 | } |
@@ -573,12 +573,12 @@ discard block |
||
| 573 | 573 | * @param $needle string |
| 574 | 574 | * @param $echo bool |
| 575 | 575 | */ |
| 576 | - public function selected($haystack=false,$needle='',$echo=true) { |
|
| 577 | - $return = $this->itemd($haystack,$needle,'selected'); |
|
| 578 | - if('' !== $return) { |
|
| 576 | + public function selected($haystack = false, $needle = '', $echo = true) { |
|
| 577 | + $return = $this->itemd($haystack, $needle, 'selected'); |
|
| 578 | + if ('' !== $return) { |
|
| 579 | 579 | if (true === $echo) { |
| 580 | 580 | echo $return; |
| 581 | - } else { |
|
| 581 | + }else { |
|
| 582 | 582 | return $return; |
| 583 | 583 | } |
| 584 | 584 | } |
@@ -593,16 +593,16 @@ discard block |
||
| 593 | 593 | * @param $wrap bool |
| 594 | 594 | * @return $html string |
| 595 | 595 | */ |
| 596 | - public function itemd($haystack=false,$needle='',$type='',$wrap=true) { |
|
| 596 | + public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) { |
|
| 597 | 597 | $html = ''; |
| 598 | - if('' !== $type) { |
|
| 598 | + if ('' !== $type) { |
|
| 599 | 599 | if (!is_array($haystack)) { |
| 600 | 600 | $haystack = array($haystack); |
| 601 | 601 | } |
| 602 | 602 | if (in_array($needle, $haystack)) { |
| 603 | - if(true === $wrap || 'true' === $wrap) { |
|
| 604 | - $html = $type . '="' . $type . '"'; |
|
| 605 | - }else{ |
|
| 603 | + if (true === $wrap || 'true' === $wrap) { |
|
| 604 | + $html = $type.'="'.$type.'"'; |
|
| 605 | + }else { |
|
| 606 | 606 | $html = $type; |
| 607 | 607 | } |
| 608 | 608 | } |
@@ -614,9 +614,9 @@ discard block |
||
| 614 | 614 | /** |
| 615 | 615 | * grabs any attachments for the current item |
| 616 | 616 | */ |
| 617 | - public function find_attachments($id=false) { |
|
| 618 | - if(false !== $id){ |
|
| 619 | - if(empty($this->found_attachments)){ |
|
| 617 | + public function find_attachments($id = false) { |
|
| 618 | + if (false !== $id) { |
|
| 619 | + if (empty($this->found_attachments)) { |
|
| 620 | 620 | |
| 621 | 621 | $attachments_args = array( |
| 622 | 622 | 'post_parent' => $id, |
@@ -628,9 +628,9 @@ discard block |
||
| 628 | 628 | ); |
| 629 | 629 | |
| 630 | 630 | $attachments = new WP_Query($attachments_args); |
| 631 | - if($attachments->have_posts()){ |
|
| 632 | - foreach($attachments->posts as $attachment){ |
|
| 633 | - $this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
| 631 | + if ($attachments->have_posts()) { |
|
| 632 | + foreach ($attachments->posts as $attachment) { |
|
| 633 | + $this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
| 634 | 634 | $this->gallery_meta[] = $attachment->ID; |
| 635 | 635 | } |
| 636 | 636 | } |
@@ -644,18 +644,18 @@ discard block |
||
| 644 | 644 | /** |
| 645 | 645 | * Saves the room data |
| 646 | 646 | */ |
| 647 | - public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) { |
|
| 648 | - if(false !== $value){ |
|
| 649 | - if(false !== $decrease){ |
|
| 647 | + public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) { |
|
| 648 | + if (false !== $value) { |
|
| 649 | + if (false !== $decrease) { |
|
| 650 | 650 | $value = intval($value); |
| 651 | 651 | $value--; |
| 652 | 652 | } |
| 653 | - $prev = get_post_meta($id,$meta_key,true); |
|
| 653 | + $prev = get_post_meta($id, $meta_key, true); |
|
| 654 | 654 | |
| 655 | - if(false !== $id && '0' !== $id && false !== $prev && true === $unique){ |
|
| 656 | - update_post_meta($id,$meta_key,$value,$prev); |
|
| 657 | - }else{ |
|
| 658 | - add_post_meta($id,$meta_key,$value,$unique); |
|
| 655 | + if (false !== $id && '0' !== $id && false !== $prev && true === $unique) { |
|
| 656 | + update_post_meta($id, $meta_key, $value, $prev); |
|
| 657 | + }else { |
|
| 658 | + add_post_meta($id, $meta_key, $value, $unique); |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | } |
@@ -664,12 +664,12 @@ discard block |
||
| 664 | 664 | * Grabs the custom fields, and resaves an array of unique items. |
| 665 | 665 | */ |
| 666 | 666 | public function cleanup_posts() { |
| 667 | - if(!empty($this->cleanup_posts)){ |
|
| 668 | - foreach($this->cleanup_posts as $id => $key) { |
|
| 667 | + if (!empty($this->cleanup_posts)) { |
|
| 668 | + foreach ($this->cleanup_posts as $id => $key) { |
|
| 669 | 669 | $prev_items = get_post_meta($id, $key, false); |
| 670 | 670 | $new_items = array_unique($prev_items); |
| 671 | 671 | delete_post_meta($id, $key); |
| 672 | - foreach($new_items as $new_item) { |
|
| 672 | + foreach ($new_items as $new_item) { |
|
| 673 | 673 | add_post_meta($id, $key, $new_item, false); |
| 674 | 674 | } |
| 675 | 675 | } |
@@ -681,51 +681,51 @@ discard block |
||
| 681 | 681 | /** |
| 682 | 682 | * set_taxonomy with some terms |
| 683 | 683 | */ |
| 684 | - public function set_taxonomy($taxonomy,$terms,$id) { |
|
| 685 | - $result=array(); |
|
| 686 | - if(!empty($data)) |
|
| 684 | + public function set_taxonomy($taxonomy, $terms, $id) { |
|
| 685 | + $result = array(); |
|
| 686 | + if (!empty($data)) |
|
| 687 | 687 | { |
| 688 | - foreach($data as $k) |
|
| 688 | + foreach ($data as $k) |
|
| 689 | 689 | { |
| 690 | - if($id) |
|
| 690 | + if ($id) |
|
| 691 | 691 | { |
| 692 | - if(!$term = term_exists(trim($k), $tax)) |
|
| 692 | + if (!$term = term_exists(trim($k), $tax)) |
|
| 693 | 693 | { |
| 694 | 694 | $term = wp_insert_term(trim($k), $tax); |
| 695 | - if ( is_wp_error($term) ) |
|
| 695 | + if (is_wp_error($term)) |
|
| 696 | 696 | { |
| 697 | 697 | echo $term->get_error_message(); |
| 698 | 698 | } |
| 699 | 699 | else |
| 700 | 700 | { |
| 701 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
| 701 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 702 | 702 | } |
| 703 | 703 | } |
| 704 | 704 | else |
| 705 | 705 | { |
| 706 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
| 706 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 707 | 707 | } |
| 708 | 708 | } |
| 709 | 709 | else |
| 710 | 710 | { |
| 711 | - $result[]=trim($k); |
|
| 711 | + $result[] = trim($k); |
|
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | 714 | } |
| 715 | 715 | return $result; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - public function set_term($id=false,$name=false,$taxonomy=false,$parent=false){ |
|
| 719 | - if(!$term = term_exists($name, $taxonomy)) |
|
| 718 | + public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) { |
|
| 719 | + if (!$term = term_exists($name, $taxonomy)) |
|
| 720 | 720 | { |
| 721 | - if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
| 722 | - $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
| 723 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
| 724 | - else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
| 721 | + if (false !== $parent) { $parent = array('parent'=>$parent); } |
|
| 722 | + $term = wp_insert_term(trim($name), $taxonomy, $parent); |
|
| 723 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
| 724 | + else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); } |
|
| 725 | 725 | } |
| 726 | 726 | else |
| 727 | 727 | { |
| 728 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
| 728 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 729 | 729 | } |
| 730 | 730 | return $term['term_id']; |
| 731 | 731 | } |
@@ -733,18 +733,18 @@ discard block |
||
| 733 | 733 | /** |
| 734 | 734 | * set_taxonomy with some terms |
| 735 | 735 | */ |
| 736 | - public function taxonomy_checkboxes($taxonomy=false,$selected=array()) { |
|
| 736 | + public function taxonomy_checkboxes($taxonomy = false, $selected = array()) { |
|
| 737 | 737 | $return = ''; |
| 738 | - if(false !== $taxonomy){ |
|
| 738 | + if (false !== $taxonomy) { |
|
| 739 | 739 | $return .= '<ul>'; |
| 740 | - $terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false)); |
|
| 740 | + $terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false)); |
|
| 741 | 741 | |
| 742 | - if(!is_wp_error($terms)){ |
|
| 743 | - foreach($terms as $term){ |
|
| 744 | - $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
| 742 | + if (!is_wp_error($terms)) { |
|
| 743 | + foreach ($terms as $term) { |
|
| 744 | + $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
| 745 | 745 | } |
| 746 | - }else{ |
|
| 747 | - $return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>'; |
|
| 746 | + }else { |
|
| 747 | + $return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>'; |
|
| 748 | 748 | } |
| 749 | 749 | $return .= '</ul>'; |
| 750 | 750 | } |
@@ -755,53 +755,53 @@ discard block |
||
| 755 | 755 | /** |
| 756 | 756 | * Saves the longitude and lattitude, as well as sets the map marker. |
| 757 | 757 | */ |
| 758 | - public function set_map_data($data,$id,$zoom = '10') { |
|
| 758 | + public function set_map_data($data, $id, $zoom = '10') { |
|
| 759 | 759 | $longitude = $latitude = $address = false; |
| 760 | 760 | |
| 761 | - if(isset($data[0]['position'])){ |
|
| 761 | + if (isset($data[0]['position'])) { |
|
| 762 | 762 | |
| 763 | - if(isset($data[0]['position']['driving_latitude'])){ |
|
| 763 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
| 764 | 764 | $latitude = $data[0]['position']['driving_latitude']; |
| 765 | - }elseif(isset($data[0]['position']['latitude'])){ |
|
| 765 | + }elseif (isset($data[0]['position']['latitude'])) { |
|
| 766 | 766 | $latitude = $data[0]['position']['latitude']; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - if(isset($data[0]['position']['driving_longitude'])){ |
|
| 769 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
| 770 | 770 | $longitude = $data[0]['position']['driving_longitude']; |
| 771 | - }elseif(isset($data[0]['position']['longitude'])){ |
|
| 771 | + }elseif (isset($data[0]['position']['longitude'])) { |
|
| 772 | 772 | $longitude = $data[0]['position']['longitude']; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | } |
| 776 | - if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){ |
|
| 777 | - if(isset($data[0]['content']['contact_information']['address'])){ |
|
| 776 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
| 777 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
| 778 | 778 | $address = strip_tags($data[0]['content']['contact_information']['address']); |
| 779 | 779 | |
| 780 | - $address = explode("\n",$address); |
|
| 781 | - foreach($address as $bitkey => $bit){ |
|
| 780 | + $address = explode("\n", $address); |
|
| 781 | + foreach ($address as $bitkey => $bit) { |
|
| 782 | 782 | $bit = ltrim(rtrim($bit)); |
| 783 | - if(false === $bit || '' === $bit || null === $bit or empty($bit)){ |
|
| 783 | + if (false === $bit || '' === $bit || null === $bit or empty($bit)) { |
|
| 784 | 784 | unset($address[$bitkey]); |
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | - $address = implode(', ',$address); |
|
| 787 | + $address = implode(', ', $address); |
|
| 788 | 788 | $address = str_replace(', , ', ', ', $address); |
| 789 | 789 | } |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - if(false !== $longitude){ |
|
| 792 | + if (false !== $longitude) { |
|
| 793 | 793 | $location_data = array( |
| 794 | - 'address' => (string)$address, |
|
| 795 | - 'lat' => (string)$latitude, |
|
| 796 | - 'long' => (string)$longitude, |
|
| 797 | - 'zoom' => (string)$zoom, |
|
| 794 | + 'address' => (string) $address, |
|
| 795 | + 'lat' => (string) $latitude, |
|
| 796 | + 'long' => (string) $longitude, |
|
| 797 | + 'zoom' => (string) $zoom, |
|
| 798 | 798 | 'elevation' => '', |
| 799 | 799 | ); |
| 800 | - if(false !== $id && '0' !== $id){ |
|
| 801 | - $prev = get_post_meta($id,'location',true); |
|
| 802 | - update_post_meta($id,'location',$location_data,$prev); |
|
| 803 | - }else{ |
|
| 804 | - add_post_meta($id,'location',$location_data,true); |
|
| 800 | + if (false !== $id && '0' !== $id) { |
|
| 801 | + $prev = get_post_meta($id, 'location', true); |
|
| 802 | + update_post_meta($id, 'location', $location_data, $prev); |
|
| 803 | + }else { |
|
| 804 | + add_post_meta($id, 'location', $location_data, true); |
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | } |
@@ -811,22 +811,22 @@ discard block |
||
| 811 | 811 | /** |
| 812 | 812 | * Creates the main gallery data |
| 813 | 813 | */ |
| 814 | - public function set_featured_image($data,$id) { |
|
| 815 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
| 816 | - if('tour' === $this->tab_slug){ |
|
| 814 | + public function set_featured_image($data, $id) { |
|
| 815 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 816 | + if ('tour' === $this->tab_slug) { |
|
| 817 | 817 | $key = array_rand($data[0]['content']['images']); |
| 818 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id); |
|
| 819 | - }else{ |
|
| 820 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
| 818 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][$key], $id); |
|
| 819 | + }else { |
|
| 820 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id); |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | |
| 824 | - if(false !== $this->featured_image){ |
|
| 825 | - delete_post_meta($id,'_thumbnail_id'); |
|
| 826 | - add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
| 824 | + if (false !== $this->featured_image) { |
|
| 825 | + delete_post_meta($id, '_thumbnail_id'); |
|
| 826 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
| 827 | 827 | |
| 828 | - if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
| 829 | - add_post_meta($id,'gallery',$this->featured_image,false); |
|
| 828 | + if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) { |
|
| 829 | + add_post_meta($id, 'gallery', $this->featured_image, false); |
|
| 830 | 830 | $this->gallery_meta[] = $this->featured_image; |
| 831 | 831 | } |
| 832 | 832 | } |
@@ -836,29 +836,29 @@ discard block |
||
| 836 | 836 | /** |
| 837 | 837 | * Sets a banner image |
| 838 | 838 | */ |
| 839 | - public function set_banner_image($data,$id) { |
|
| 840 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
| 841 | - if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
| 839 | + public function set_banner_image($data, $id) { |
|
| 840 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 841 | + if (isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
| 842 | 842 | $temp_banner = $this->attach_image($data[0]['destination_image'], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
| 843 | - }else{ |
|
| 843 | + }else { |
|
| 844 | 844 | if ('tour' === $this->tab_slug) { |
| 845 | 845 | $key = array_rand($data[0]['content']['images']); |
| 846 | 846 | $temp_banner = $this->attach_image($data[0]['content']['images'][$key], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
| 847 | - } else { |
|
| 847 | + }else { |
|
| 848 | 848 | $temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
| 849 | 849 | } |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | |
| 853 | - if(false !== $temp_banner){ |
|
| 853 | + if (false !== $temp_banner) { |
|
| 854 | 854 | $this->banner_image = $temp_banner; |
| 855 | 855 | |
| 856 | - delete_post_meta($id,'image_group'); |
|
| 856 | + delete_post_meta($id, 'image_group'); |
|
| 857 | 857 | $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
| 858 | - add_post_meta($id,'image_group',$new_banner,true); |
|
| 858 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
| 859 | 859 | |
| 860 | - if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
| 861 | - add_post_meta($id,'gallery',$this->banner_image,false); |
|
| 860 | + if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) { |
|
| 861 | + add_post_meta($id, 'gallery', $this->banner_image, false); |
|
| 862 | 862 | $this->gallery_meta[] = $this->banner_image; |
| 863 | 863 | } |
| 864 | 864 | } |
@@ -868,24 +868,24 @@ discard block |
||
| 868 | 868 | /** |
| 869 | 869 | * Creates the main gallery data |
| 870 | 870 | */ |
| 871 | - public function create_main_gallery($data,$id) { |
|
| 871 | + public function create_main_gallery($data, $id) { |
|
| 872 | 872 | |
| 873 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
| 873 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 874 | 874 | $counter = 0; |
| 875 | - foreach($data[0]['content']['images'] as $image_data){ |
|
| 876 | - if($counter === 0 && false !== $this->featured_image){$counter++;continue;} |
|
| 877 | - if($counter === 1 && false !== $this->banner_image){$counter++;continue;} |
|
| 875 | + foreach ($data[0]['content']['images'] as $image_data) { |
|
| 876 | + if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; } |
|
| 877 | + if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; } |
|
| 878 | 878 | |
| 879 | - $this->gallery_meta[] = $this->attach_image($image_data,$id); |
|
| 879 | + $this->gallery_meta[] = $this->attach_image($image_data, $id); |
|
| 880 | 880 | $counter++; |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - if(!empty($this->gallery_meta)){ |
|
| 884 | - delete_post_meta($id,'gallery'); |
|
| 883 | + if (!empty($this->gallery_meta)) { |
|
| 884 | + delete_post_meta($id, 'gallery'); |
|
| 885 | 885 | $this->gallery_meta = array_unique($this->gallery_meta); |
| 886 | - foreach($this->gallery_meta as $gallery_id){ |
|
| 887 | - if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
| 888 | - add_post_meta($id,'gallery',$gallery_id,false); |
|
| 886 | + foreach ($this->gallery_meta as $gallery_id) { |
|
| 887 | + if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) { |
|
| 888 | + add_post_meta($id, 'gallery', $gallery_id, false); |
|
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | 891 | } |
@@ -895,27 +895,27 @@ discard block |
||
| 895 | 895 | /** |
| 896 | 896 | * search_form |
| 897 | 897 | */ |
| 898 | - public function get_scaling_url($args=array()) { |
|
| 898 | + public function get_scaling_url($args = array()) { |
|
| 899 | 899 | |
| 900 | 900 | $defaults = array( |
| 901 | 901 | 'width' => '1024', |
| 902 | 902 | 'height' => '768', |
| 903 | 903 | 'cropping' => 'w' |
| 904 | 904 | ); |
| 905 | - if(false !== $this->options){ |
|
| 906 | - if(isset($this->options['width']) && '' !== $this->options['width']){ |
|
| 905 | + if (false !== $this->options) { |
|
| 906 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
| 907 | 907 | $defaults['width'] = $this->options['width']; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - if(isset($this->options['height']) && '' !== $this->options['height']){ |
|
| 910 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
| 911 | 911 | $defaults['height'] = $this->options['height']; |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | - if(isset($this->options['cropping']) && '' !== $this->options['cropping']){ |
|
| 914 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
| 915 | 915 | $defaults['cropping'] = $this->options['cropping']; |
| 916 | 916 | } |
| 917 | 917 | } |
| 918 | - $args = wp_parse_args($args,$defaults); |
|
| 918 | + $args = wp_parse_args($args, $defaults); |
|
| 919 | 919 | |
| 920 | 920 | $cropping = $args['cropping']; |
| 921 | 921 | $width = $args['width']; |
@@ -927,43 +927,43 @@ discard block |
||
| 927 | 927 | /** |
| 928 | 928 | * Attaches 1 image |
| 929 | 929 | */ |
| 930 | - public function attach_image($v=false,$parent_id,$image_sizes=false){ |
|
| 931 | - if(false !== $v){ |
|
| 932 | - $temp_fragment = explode('/',$v['url_fragment']); |
|
| 933 | - $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
| 934 | - $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
| 930 | + public function attach_image($v = false, $parent_id, $image_sizes = false) { |
|
| 931 | + if (false !== $v) { |
|
| 932 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
| 933 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
| 934 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
| 935 | 935 | $url_filename = trim($url_filename); |
| 936 | - $url_filename = str_replace(" ",'_',$url_filename); |
|
| 936 | + $url_filename = str_replace(" ", '_', $url_filename); |
|
| 937 | 937 | |
| 938 | - if(in_array($url_filename,$this->found_attachments)){ |
|
| 939 | - return array_search($url_filename,$this->found_attachments); |
|
| 938 | + if (in_array($url_filename, $this->found_attachments)) { |
|
| 939 | + return array_search($url_filename, $this->found_attachments); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - $postdata=array(); |
|
| 943 | - if(empty($v['label'])) |
|
| 942 | + $postdata = array(); |
|
| 943 | + if (empty($v['label'])) |
|
| 944 | 944 | { |
| 945 | - $v['label']=''; |
|
| 945 | + $v['label'] = ''; |
|
| 946 | 946 | } |
| 947 | - if(!empty($v['description'])) |
|
| 947 | + if (!empty($v['description'])) |
|
| 948 | 948 | { |
| 949 | - $desc=wp_strip_all_tags($v['description']); |
|
| 950 | - $posdata=array('post_excerpt'=>$desc); |
|
| 949 | + $desc = wp_strip_all_tags($v['description']); |
|
| 950 | + $posdata = array('post_excerpt'=>$desc); |
|
| 951 | 951 | } |
| 952 | - if(!empty($v['section'])) |
|
| 952 | + if (!empty($v['section'])) |
|
| 953 | 953 | { |
| 954 | - $desc=wp_strip_all_tags($v['section']); |
|
| 955 | - $posdata=array('post_excerpt'=>$desc); |
|
| 954 | + $desc = wp_strip_all_tags($v['section']); |
|
| 955 | + $posdata = array('post_excerpt'=>$desc); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | - $attachID=NULL; |
|
| 958 | + $attachID = NULL; |
|
| 959 | 959 | //Resizor - add option to setting if required |
| 960 | - $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
| 960 | + $fragment = str_replace(' ', '%20', $v['url_fragment']); |
|
| 961 | 961 | $url = $this->get_scaling_url($image_sizes).$fragment; |
| 962 | 962 | |
| 963 | - $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
| 963 | + $attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata); |
|
| 964 | 964 | |
| 965 | 965 | //echo($attachID.' add image'); |
| 966 | - if($attachID!=NULL) |
|
| 966 | + if ($attachID != NULL) |
|
| 967 | 967 | { |
| 968 | 968 | return $attachID; |
| 969 | 969 | } |
@@ -971,13 +971,13 @@ discard block |
||
| 971 | 971 | return false; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
|
| 974 | + public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) { |
|
| 975 | 975 | |
| 976 | - if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
| 976 | + if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
| 977 | 977 | |
| 978 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 979 | - require_once(ABSPATH . 'wp-admin/includes/media.php'); |
|
| 980 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 978 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
| 979 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
| 980 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 981 | 981 | // Download file to temp location, returns full server path to temp file |
| 982 | 982 | //$tmp = download_url( $url ); |
| 983 | 983 | |
@@ -986,53 +986,53 @@ discard block |
||
| 986 | 986 | |
| 987 | 987 | $image = file_get_contents($url); |
| 988 | 988 | file_put_contents($tmp, $image); |
| 989 | - chmod($tmp,'777'); |
|
| 989 | + chmod($tmp, '777'); |
|
| 990 | 990 | |
| 991 | - 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 |
|
| 991 | + 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 |
|
| 992 | 992 | $url_filename = basename($matches[0]); |
| 993 | - $url_filename=str_replace('%20','_',$url_filename); |
|
| 993 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
| 994 | 994 | // extract filename from url for title |
| 995 | - $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
| 995 | + $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
| 996 | 996 | |
| 997 | 997 | // override filename if given, reconstruct server path |
| 998 | - if ( !empty( $filename ) && " " != $filename ) |
|
| 998 | + if (!empty($filename) && " " != $filename) |
|
| 999 | 999 | { |
| 1000 | 1000 | $filename = sanitize_file_name($filename); |
| 1001 | - $tmppath = pathinfo( $tmp ); |
|
| 1001 | + $tmppath = pathinfo($tmp); |
|
| 1002 | 1002 | |
| 1003 | 1003 | $extension = ''; |
| 1004 | - if(isset($tmppath['extension'])){ |
|
| 1004 | + if (isset($tmppath['extension'])) { |
|
| 1005 | 1005 | $extension = $tmppath['extension']; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - $new = $tmppath['dirname'] . "/". $filename . "." . $extension; |
|
| 1009 | - rename($tmp, $new); // renames temp file on server |
|
| 1010 | - $tmp = $new; // push new filename (in path) to be used in file array later |
|
| 1008 | + $new = $tmppath['dirname']."/".$filename.".".$extension; |
|
| 1009 | + rename($tmp, $new); // renames temp file on server |
|
| 1010 | + $tmp = $new; // push new filename (in path) to be used in file array later |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using) |
| 1014 | - $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 1014 | + $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 1015 | 1015 | |
| 1016 | - if ( !empty( $filename) && " " != $filename ) |
|
| 1016 | + if (!empty($filename) && " " != $filename) |
|
| 1017 | 1017 | { |
| 1018 | - $file_array['name'] = $filename . "." . $url_type['ext']; // user given filename for title, add original URL extension |
|
| 1018 | + $file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension |
|
| 1019 | 1019 | } |
| 1020 | 1020 | else |
| 1021 | 1021 | { |
| 1022 | - $file_array['name'] = $url_filename; // just use original URL filename |
|
| 1022 | + $file_array['name'] = $url_filename; // just use original URL filename |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | // set additional wp_posts columns |
| 1026 | - if ( empty( $post_data['post_title'] ) ) |
|
| 1026 | + if (empty($post_data['post_title'])) |
|
| 1027 | 1027 | { |
| 1028 | 1028 | |
| 1029 | - $url_filename=str_replace('%20',' ',$url_filename); |
|
| 1029 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
| 1030 | 1030 | |
| 1031 | - $post_data['post_title'] = basename($url_filename, "." . $url_type['ext']); // just use the original filename (no extension) |
|
| 1031 | + $post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension) |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | // make sure gets tied to parent |
| 1035 | - if ( empty( $post_data['post_parent'] ) ) |
|
| 1035 | + if (empty($post_data['post_parent'])) |
|
| 1036 | 1036 | { |
| 1037 | 1037 | $post_data['post_parent'] = $post_id; |
| 1038 | 1038 | } |
@@ -1040,12 +1040,12 @@ discard block |
||
| 1040 | 1040 | // required libraries for media_handle_sideload |
| 1041 | 1041 | |
| 1042 | 1042 | // do the validation and storage stuff |
| 1043 | - $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 |
|
| 1043 | + $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 |
|
| 1044 | 1044 | |
| 1045 | 1045 | // If error storing permanently, unlink |
| 1046 | - if ( is_wp_error($att_id) ) |
|
| 1046 | + if (is_wp_error($att_id)) |
|
| 1047 | 1047 | { |
| 1048 | - unlink($file_array['tmp_name']); // clean up |
|
| 1048 | + unlink($file_array['tmp_name']); // clean up |
|
| 1049 | 1049 | return false; // output wp_error |
| 1050 | 1050 | //return $att_id; // output wp_error |
| 1051 | 1051 | } |
@@ -1074,31 +1074,31 @@ discard block |
||
| 1074 | 1074 | /** |
| 1075 | 1075 | * Formats the row for the completed list. |
| 1076 | 1076 | */ |
| 1077 | - public function format_completed_row($response){ |
|
| 1077 | + public function format_completed_row($response) { |
|
| 1078 | 1078 | echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>'; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
| 1082 | 1082 | * Formats the error. |
| 1083 | 1083 | */ |
| 1084 | - public function format_error($response){ |
|
| 1084 | + public function format_error($response) { |
|
| 1085 | 1085 | echo '<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>'; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
| 1089 | 1089 | * Does a multine search |
| 1090 | 1090 | */ |
| 1091 | - public function multineedle_stripos($haystack, $needles, $offset=0) { |
|
| 1091 | + public function multineedle_stripos($haystack, $needles, $offset = 0) { |
|
| 1092 | 1092 | $found = false; |
| 1093 | 1093 | $needle_count = count($needles); |
| 1094 | - foreach($needles as $needle) { |
|
| 1095 | - if(false !== stripos($haystack, $needle, $offset)){ |
|
| 1094 | + foreach ($needles as $needle) { |
|
| 1095 | + if (false !== stripos($haystack, $needle, $offset)) { |
|
| 1096 | 1096 | $found[] = true; |
| 1097 | 1097 | } |
| 1098 | 1098 | } |
| 1099 | - if(false !== $found && $needle_count === count($found)){ |
|
| 1099 | + if (false !== $found && $needle_count === count($found)) { |
|
| 1100 | 1100 | return true; |
| 1101 | - }else{ |
|
| 1101 | + }else { |
|
| 1102 | 1102 | return false; |
| 1103 | 1103 | } |
| 1104 | 1104 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | /** |
| 1107 | 1107 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
| 1108 | 1108 | */ |
| 1109 | - public function find_current_accommodation($post_type='accommodation') { |
|
| 1109 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 1110 | 1110 | global $wpdb; |
| 1111 | 1111 | $return = array(); |
| 1112 | 1112 | |
@@ -1122,8 +1122,8 @@ discard block |
||
| 1122 | 1122 | |
| 1123 | 1123 | LIMIT 0,5000 |
| 1124 | 1124 | "); |
| 1125 | - if(null !== $current_accommodation && !empty($current_accommodation)){ |
|
| 1126 | - foreach($current_accommodation as $accom){ |
|
| 1125 | + if (null !== $current_accommodation && !empty($current_accommodation)) { |
|
| 1126 | + foreach ($current_accommodation as $accom) { |
|
| 1127 | 1127 | $return[$accom->meta_value] = $accom; |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
@@ -1133,31 +1133,31 @@ discard block |
||
| 1133 | 1133 | /** |
| 1134 | 1134 | * Set the Video date |
| 1135 | 1135 | */ |
| 1136 | - public function set_video_data($data,$id) { |
|
| 1137 | - if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){ |
|
| 1136 | + public function set_video_data($data, $id) { |
|
| 1137 | + if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) { |
|
| 1138 | 1138 | $videos = false; |
| 1139 | 1139 | |
| 1140 | - foreach($data[0]['content']['youtube_videos'] as $video){ |
|
| 1140 | + foreach ($data[0]['content']['youtube_videos'] as $video) { |
|
| 1141 | 1141 | $temp_video = array(); |
| 1142 | 1142 | |
| 1143 | - if(isset($video['label'])){ |
|
| 1143 | + if (isset($video['label'])) { |
|
| 1144 | 1144 | $temp_video['title'] = $video['label']; |
| 1145 | 1145 | } |
| 1146 | - if(isset($video['description'])){ |
|
| 1146 | + if (isset($video['description'])) { |
|
| 1147 | 1147 | $temp_video['description'] = strip_tags($video['description']); |
| 1148 | 1148 | } |
| 1149 | - if(isset($video['url'])){ |
|
| 1149 | + if (isset($video['url'])) { |
|
| 1150 | 1150 | $temp_video['url'] = $video['url']; |
| 1151 | 1151 | } |
| 1152 | 1152 | $temp_video['thumbnail'] = ''; |
| 1153 | 1153 | $videos[] = $temp_video; |
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | - if(false !== $id && '0' !== $id){ |
|
| 1156 | + if (false !== $id && '0' !== $id) { |
|
| 1157 | 1157 | delete_post_meta($id, 'videos'); |
| 1158 | 1158 | } |
| 1159 | - foreach($videos as $video){ |
|
| 1160 | - add_post_meta($id,'videos',$video,false); |
|
| 1159 | + foreach ($videos as $video) { |
|
| 1160 | + add_post_meta($id, 'videos', $video, false); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | } |
| 1163 | 1163 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) { |
| 228 | 228 | $this->api_password = $temp_options['api']['wetu_api_password']; |
| 229 | 229 | } |
| 230 | - }else{ |
|
| 230 | + } else{ |
|
| 231 | 231 | $this->api_key = WETU_API_KEY; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | <?php } ?> |
| 412 | 412 | </ul> |
| 413 | 413 | <?php*/ |
| 414 | - }else{ |
|
| 414 | + } else{ |
|
| 415 | 415 | $this->current_importer->display_page(); |
| 416 | 416 | }; ?> |
| 417 | 417 | </div> |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | <?php if('tour'===$this->tab_slug){ ?> |
| 449 | 449 | | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a> |
| 450 | - <?php }else if(!empty($this->queued_imports)) { ?> |
|
| 450 | + <?php } else if(!empty($this->queued_imports)) { ?> |
|
| 451 | 451 | | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU Queue','wetu-importer'); ?></a> |
| 452 | 452 | <?php } ?> |
| 453 | 453 | </p> |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | foreach($team_members->posts as $member){ ?> |
| 538 | 538 | <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
| 539 | 539 | <?php } |
| 540 | - }else{ ?> |
|
| 540 | + } else{ ?> |
|
| 541 | 541 | <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li> |
| 542 | 542 | <?php } |
| 543 | 543 | ?> |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | if (in_array($needle, $haystack)) { |
| 603 | 603 | if(true === $wrap || 'true' === $wrap) { |
| 604 | 604 | $html = $type . '="' . $type . '"'; |
| 605 | - }else{ |
|
| 605 | + } else{ |
|
| 606 | 606 | $html = $type; |
| 607 | 607 | } |
| 608 | 608 | } |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | if(false !== $id && '0' !== $id && false !== $prev && true === $unique){ |
| 656 | 656 | update_post_meta($id,$meta_key,$value,$prev); |
| 657 | - }else{ |
|
| 657 | + } else{ |
|
| 658 | 658 | add_post_meta($id,$meta_key,$value,$unique); |
| 659 | 659 | } |
| 660 | 660 | } |
@@ -695,18 +695,15 @@ discard block |
||
| 695 | 695 | if ( is_wp_error($term) ) |
| 696 | 696 | { |
| 697 | 697 | echo $term->get_error_message(); |
| 698 | - } |
|
| 699 | - else |
|
| 698 | + } else |
|
| 700 | 699 | { |
| 701 | 700 | wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
| 702 | 701 | } |
| 703 | - } |
|
| 704 | - else |
|
| 702 | + } else |
|
| 705 | 703 | { |
| 706 | 704 | wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
| 707 | 705 | } |
| 708 | - } |
|
| 709 | - else |
|
| 706 | + } else |
|
| 710 | 707 | { |
| 711 | 708 | $result[]=trim($k); |
| 712 | 709 | } |
@@ -720,10 +717,8 @@ discard block |
||
| 720 | 717 | { |
| 721 | 718 | if(false !== $parent){ $parent = array('parent'=>$parent); } |
| 722 | 719 | $term = wp_insert_term(trim($name), $taxonomy,$parent); |
| 723 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
| 724 | - else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
| 725 | - } |
|
| 726 | - else |
|
| 720 | + if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
| 721 | + } else |
|
| 727 | 722 | { |
| 728 | 723 | wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
| 729 | 724 | } |
@@ -743,7 +738,7 @@ discard block |
||
| 743 | 738 | foreach($terms as $term){ |
| 744 | 739 | $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
| 745 | 740 | } |
| 746 | - }else{ |
|
| 741 | + } else{ |
|
| 747 | 742 | $return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>'; |
| 748 | 743 | } |
| 749 | 744 | $return .= '</ul>'; |
@@ -762,13 +757,13 @@ discard block |
||
| 762 | 757 | |
| 763 | 758 | if(isset($data[0]['position']['driving_latitude'])){ |
| 764 | 759 | $latitude = $data[0]['position']['driving_latitude']; |
| 765 | - }elseif(isset($data[0]['position']['latitude'])){ |
|
| 760 | + } elseif(isset($data[0]['position']['latitude'])){ |
|
| 766 | 761 | $latitude = $data[0]['position']['latitude']; |
| 767 | 762 | } |
| 768 | 763 | |
| 769 | 764 | if(isset($data[0]['position']['driving_longitude'])){ |
| 770 | 765 | $longitude = $data[0]['position']['driving_longitude']; |
| 771 | - }elseif(isset($data[0]['position']['longitude'])){ |
|
| 766 | + } elseif(isset($data[0]['position']['longitude'])){ |
|
| 772 | 767 | $longitude = $data[0]['position']['longitude']; |
| 773 | 768 | } |
| 774 | 769 | |
@@ -800,7 +795,7 @@ discard block |
||
| 800 | 795 | if(false !== $id && '0' !== $id){ |
| 801 | 796 | $prev = get_post_meta($id,'location',true); |
| 802 | 797 | update_post_meta($id,'location',$location_data,$prev); |
| 803 | - }else{ |
|
| 798 | + } else{ |
|
| 804 | 799 | add_post_meta($id,'location',$location_data,true); |
| 805 | 800 | } |
| 806 | 801 | } |
@@ -816,7 +811,7 @@ discard block |
||
| 816 | 811 | if('tour' === $this->tab_slug){ |
| 817 | 812 | $key = array_rand($data[0]['content']['images']); |
| 818 | 813 | $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id); |
| 819 | - }else{ |
|
| 814 | + } else{ |
|
| 820 | 815 | $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
| 821 | 816 | } |
| 822 | 817 | |
@@ -840,7 +835,7 @@ discard block |
||
| 840 | 835 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
| 841 | 836 | if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
| 842 | 837 | $temp_banner = $this->attach_image($data[0]['destination_image'], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
| 843 | - }else{ |
|
| 838 | + } else{ |
|
| 844 | 839 | if ('tour' === $this->tab_slug) { |
| 845 | 840 | $key = array_rand($data[0]['content']['images']); |
| 846 | 841 | $temp_banner = $this->attach_image($data[0]['content']['images'][$key], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
@@ -1016,8 +1011,7 @@ discard block |
||
| 1016 | 1011 | if ( !empty( $filename) && " " != $filename ) |
| 1017 | 1012 | { |
| 1018 | 1013 | $file_array['name'] = $filename . "." . $url_type['ext']; // user given filename for title, add original URL extension |
| 1019 | - } |
|
| 1020 | - else |
|
| 1014 | + } else |
|
| 1021 | 1015 | { |
| 1022 | 1016 | $file_array['name'] = $url_filename; // just use original URL filename |
| 1023 | 1017 | } |
@@ -1098,7 +1092,7 @@ discard block |
||
| 1098 | 1092 | } |
| 1099 | 1093 | if(false !== $found && $needle_count === count($found)){ |
| 1100 | 1094 | return true; |
| 1101 | - }else{ |
|
| 1095 | + } else{ |
|
| 1102 | 1096 | return false; |
| 1103 | 1097 | } |
| 1104 | 1098 | } |