@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * @access private |
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | - add_filter( 'manage_tour_posts_columns', array( $this, 'register_tour_columns' ) ); |
|
| 33 | - add_action( 'manage_tour_posts_custom_column', array( $this, 'output_tour_ref_column' ), 10, 2 ); |
|
| 32 | + add_filter('manage_tour_posts_columns', array($this, 'register_tour_columns')); |
|
| 33 | + add_action('manage_tour_posts_custom_column', array($this, 'output_tour_ref_column'), 10, 2); |
|
| 34 | 34 | |
| 35 | 35 | // Sortables Columns, sorting needs to be fixed |
| 36 | 36 | // add_filter( 'manage_edit-tour_sortable_columns', array( $this, 'register_sortable_columns' ) ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public static function get_instance() { |
| 46 | 46 | // If the single instance hasn't been set, set it now. |
| 47 | - if ( ! isset( self::$instance ) ) { |
|
| 47 | + if (!isset(self::$instance)) { |
|
| 48 | 48 | self::$instance = new self(); |
| 49 | 49 | } |
| 50 | 50 | return self::$instance; |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | * @param array $columns |
| 64 | 64 | * @return array |
| 65 | 65 | */ |
| 66 | - public function register_tour_columns( $columns ) { |
|
| 66 | + public function register_tour_columns($columns) { |
|
| 67 | 67 | $new_columns = array( |
| 68 | 68 | 'cb' => $columns['cb'], |
| 69 | 69 | 'title' => $columns['title'], |
| 70 | - 'wetu_ref' => __( 'Ref', 'lsx-wetu-importer' ), |
|
| 70 | + 'wetu_ref' => __('Ref', 'lsx-wetu-importer'), |
|
| 71 | 71 | ); |
| 72 | - unset( $columns['cb'] ); |
|
| 73 | - unset( $columns['title'] ); |
|
| 74 | - foreach ( $columns as $column_key => $column_label ) { |
|
| 75 | - $new_columns[ $column_key ] = $column_label; |
|
| 72 | + unset($columns['cb']); |
|
| 73 | + unset($columns['title']); |
|
| 74 | + foreach ($columns as $column_key => $column_label) { |
|
| 75 | + $new_columns[$column_key] = $column_label; |
|
| 76 | 76 | } |
| 77 | 77 | $columns = $new_columns; |
| 78 | 78 | return $columns; |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | * @param string $post_id |
| 86 | 86 | * @return void |
| 87 | 87 | */ |
| 88 | - public function output_tour_ref_column( $column, $post_id ) { |
|
| 89 | - if ( 'wetu_ref' === $column ) { |
|
| 90 | - echo esc_attr( get_post_meta( $post_id, 'lsx_wetu_ref', true ) ); |
|
| 88 | + public function output_tour_ref_column($column, $post_id) { |
|
| 89 | + if ('wetu_ref' === $column) { |
|
| 90 | + echo esc_attr(get_post_meta($post_id, 'lsx_wetu_ref', true)); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param array $columns |
| 98 | 98 | * @return array |
| 99 | 99 | */ |
| 100 | - public function register_sortable_columns( $columns = array() ) { |
|
| 100 | + public function register_sortable_columns($columns = array()) { |
|
| 101 | 101 | $columns['wetu_ref'] = 'price_per_month'; |
| 102 | 102 | return $columns; |
| 103 | 103 | } |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | * @param object $query WP_Query() |
| 109 | 109 | * @return void |
| 110 | 110 | */ |
| 111 | - public function columns_posts_orderby( $query ) { |
|
| 112 | - if ( ! is_admin() || ! $query->is_main_query() ) { |
|
| 111 | + public function columns_posts_orderby($query) { |
|
| 112 | + if (!is_admin() || !$query->is_main_query()) { |
|
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | - if ( 'wetu_ref' === $query->get( 'orderby' ) ) { |
|
| 116 | - $query->set( 'orderby', 'meta_value' ); |
|
| 117 | - $query->set( 'meta_key', 'lsx_wetu_reference' ); |
|
| 115 | + if ('wetu_ref' === $query->get('orderby')) { |
|
| 116 | + $query->set('orderby', 'meta_value'); |
|
| 117 | + $query->set('meta_key', 'lsx_wetu_reference'); |
|
| 118 | 118 | } |
| 119 | 119 | /*if ( $query->is_search() && 'tour' === $query->get( 'post_type' ) ) { |
| 120 | 120 | $meta_query = array( |
@@ -197,38 +197,38 @@ discard block |
||
| 197 | 197 | * @access private |
| 198 | 198 | */ |
| 199 | 199 | public function __construct() { |
| 200 | - add_action( 'admin_init', array( $this, 'compatible_version_check' ) ); |
|
| 201 | - require_once LSX_WETU_IMPORTER_PATH . 'includes/helpers.php'; |
|
| 200 | + add_action('admin_init', array($this, 'compatible_version_check')); |
|
| 201 | + require_once LSX_WETU_IMPORTER_PATH.'includes/helpers.php'; |
|
| 202 | 202 | |
| 203 | 203 | // Don't run anything else in the plugin, if we're on an incompatible PHP version. |
| 204 | - if ( ! self::compatible_version() ) { |
|
| 204 | + if (!self::compatible_version()) { |
|
| 205 | 205 | return; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | $this->set_variables(); |
| 209 | 209 | |
| 210 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
| 211 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 11 ); |
|
| 212 | - add_action( 'admin_menu', array( $this, 'register_importer_page' ), 20 ); |
|
| 213 | - |
|
| 214 | - require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-welcome.php'; |
|
| 215 | - require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-accommodation.php'; |
|
| 216 | - require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-destination.php'; |
|
| 217 | - require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-tours.php'; |
|
| 218 | - require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-settings.php'; |
|
| 219 | - if ( isset( $this->options ) && isset( $this->options['enable_tour_ref_column'] ) && '' !== $this->options['enable_tour_ref_column'] ) { |
|
| 220 | - require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-post-columns.php'; |
|
| 210 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
| 211 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11); |
|
| 212 | + add_action('admin_menu', array($this, 'register_importer_page'), 20); |
|
| 213 | + |
|
| 214 | + require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-welcome.php'; |
|
| 215 | + require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-accommodation.php'; |
|
| 216 | + require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-destination.php'; |
|
| 217 | + require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-tours.php'; |
|
| 218 | + require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-settings.php'; |
|
| 219 | + if (isset($this->options) && isset($this->options['enable_tour_ref_column']) && '' !== $this->options['enable_tour_ref_column']) { |
|
| 220 | + require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-post-columns.php'; |
|
| 221 | 221 | $this->post_columns = LSX_WETU_Importer_Post_Columns::get_instance(); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - add_action( 'init', array( $this, 'load_class' ) ); |
|
| 224 | + add_action('init', array($this, 'load_class')); |
|
| 225 | 225 | |
| 226 | - if ( 'default' !== $this->tab_slug ) { |
|
| 227 | - add_action( 'wp_ajax_lsx_tour_importer', array( $this, 'process_ajax_search' ) ); |
|
| 228 | - add_action( 'wp_ajax_nopriv_lsx_tour_importer', array( $this, 'process_ajax_search' ) ); |
|
| 226 | + if ('default' !== $this->tab_slug) { |
|
| 227 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
| 228 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
| 229 | 229 | |
| 230 | - add_action( 'wp_ajax_lsx_import_items', array( $this, 'process_ajax_import' ) ); |
|
| 231 | - add_action( 'wp_ajax_nopriv_lsx_import_items', array( $this, 'process_ajax_import' ) ); |
|
| 230 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
| 231 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
@@ -240,21 +240,21 @@ discard block |
||
| 240 | 240 | * @since 1.0.0 |
| 241 | 241 | */ |
| 242 | 242 | public function load_plugin_textdomain() { |
| 243 | - load_plugin_textdomain( 'lsx-wetu-importer', false, basename( LSX_WETU_IMPORTER_PATH ) . '/languages' ); |
|
| 243 | + load_plugin_textdomain('lsx-wetu-importer', false, basename(LSX_WETU_IMPORTER_PATH).'/languages'); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | 247 | * Sets the variables used throughout the plugin. |
| 248 | 248 | */ |
| 249 | 249 | public function set_variables() { |
| 250 | - $this->post_types = array( 'accommodation', 'destination', 'tour' ); |
|
| 250 | + $this->post_types = array('accommodation', 'destination', 'tour'); |
|
| 251 | 251 | $options = lsx_wetu_get_options(); |
| 252 | 252 | |
| 253 | 253 | // Set the options. |
| 254 | 254 | $this->options = $options; |
| 255 | 255 | |
| 256 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
| 257 | - if ( false !== $temp_options ) { |
|
| 256 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 257 | + if (false !== $temp_options) { |
|
| 258 | 258 | $this->accommodation_settings = $temp_options['accommodation']; |
| 259 | 259 | $this->tour_settings = $temp_options['tour']; |
| 260 | 260 | $this->destination_settings = $temp_options['destination']; |
@@ -262,51 +262,51 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | $this->api_key = false; |
| 264 | 264 | |
| 265 | - if ( ! defined( 'WETU_API_KEY' ) ) { |
|
| 266 | - if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) { |
|
| 265 | + if (!defined('WETU_API_KEY')) { |
|
| 266 | + if (isset($options['api_key']) && '' !== $options['api_key']) { |
|
| 267 | 267 | $this->api_key = $options['api_key']; |
| 268 | 268 | } |
| 269 | - } else { |
|
| 269 | + }else { |
|
| 270 | 270 | $this->api_key = WETU_API_KEY; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // Set the tab slug. |
| 274 | 274 | // @codingStandardsIgnoreLine |
| 275 | - if ( isset( $_GET['tab'] ) || ( defined( 'DOING_AJAX' ) && isset( $_POST['type'] ) ) ) { |
|
| 276 | - if ( isset( $_GET['tab'] ) ) { |
|
| 277 | - $this->tab_slug = sanitize_text_field( $_GET['tab'] ); |
|
| 278 | - } else { |
|
| 275 | + if (isset($_GET['tab']) || (defined('DOING_AJAX') && isset($_POST['type']))) { |
|
| 276 | + if (isset($_GET['tab'])) { |
|
| 277 | + $this->tab_slug = sanitize_text_field($_GET['tab']); |
|
| 278 | + }else { |
|
| 279 | 279 | // @codingStandardsIgnoreLine |
| 280 | - $this->tab_slug = sanitize_text_field( $_POST['type'] ); |
|
| 280 | + $this->tab_slug = sanitize_text_field($_POST['type']); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | // If any tours were queued. |
| 285 | - $this->queued_imports = get_option( 'lsx_wetu_importer_que', array() ); |
|
| 285 | + $this->queued_imports = get_option('lsx_wetu_importer_que', array()); |
|
| 286 | 286 | |
| 287 | 287 | // Set the scaling options. |
| 288 | - if ( isset( $this->options ) && isset( $this->options['image_scaling'] ) ) { |
|
| 288 | + if (isset($this->options) && isset($this->options['image_scaling'])) { |
|
| 289 | 289 | $this->scale_images = true; |
| 290 | 290 | |
| 291 | 291 | $width = '1024'; |
| 292 | - if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) { |
|
| 292 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
| 293 | 293 | $width = $this->options['width']; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $height = '768'; |
| 297 | - if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) { |
|
| 297 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
| 298 | 298 | $height = $this->options['height']; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | $cropping = 'w'; |
| 302 | - if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) { |
|
| 302 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
| 303 | 303 | $cropping = $this->options['cropping']; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
| 306 | + $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/'; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if ( isset( $this->options ) && isset( $this->options['image_limit'] ) && '' !== $this->options['image_limit'] ) { |
|
| 309 | + if (isset($this->options) && isset($this->options['image_limit']) && '' !== $this->options['image_limit']) { |
|
| 310 | 310 | $this->image_limit = $this->options['image_limit']; |
| 311 | 311 | } |
| 312 | 312 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * @since 1.0.0 |
| 329 | 329 | */ |
| 330 | 330 | public static function compatible_version() { |
| 331 | - if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { |
|
| 331 | + if (version_compare(PHP_VERSION, '5.6', '<')) { |
|
| 332 | 332 | return false; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -342,13 +342,13 @@ discard block |
||
| 342 | 342 | * @since 1.0.0 |
| 343 | 343 | */ |
| 344 | 344 | public function compatible_version_check() { |
| 345 | - if ( ! self::compatible_version() ) { |
|
| 346 | - if ( is_plugin_active( plugin_basename( LSX_WETU_IMPORTER_CORE ) ) ) { |
|
| 347 | - deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) ); |
|
| 348 | - add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) ); |
|
| 345 | + if (!self::compatible_version()) { |
|
| 346 | + if (is_plugin_active(plugin_basename(LSX_WETU_IMPORTER_CORE))) { |
|
| 347 | + deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE)); |
|
| 348 | + add_action('admin_notices', array($this, 'compatible_version_notice')); |
|
| 349 | 349 | |
| 350 | - if ( isset( $_GET['activate'] ) ) { |
|
| 351 | - unset( $_GET['activate'] ); |
|
| 350 | + if (isset($_GET['activate'])) { |
|
| 351 | + unset($_GET['activate']); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -361,8 +361,8 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | public function compatible_version_notice() { |
| 363 | 363 | $class = 'notice notice-error'; |
| 364 | - $message = esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' ); |
|
| 365 | - printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) ); |
|
| 364 | + $message = esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer'); |
|
| 365 | + printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message)); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -372,9 +372,9 @@ discard block |
||
| 372 | 372 | * @since 1.0.0 |
| 373 | 373 | */ |
| 374 | 374 | public static function compatible_version_check_on_activation() { |
| 375 | - if ( ! self::compatible_version() ) { |
|
| 376 | - deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) ); |
|
| 377 | - wp_die( esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' ) ); |
|
| 375 | + if (!self::compatible_version()) { |
|
| 376 | + deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE)); |
|
| 377 | + wp_die(esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer')); |
|
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * Load the importer class you want to use |
| 385 | 385 | */ |
| 386 | 386 | public function load_class() { |
| 387 | - switch ( $this->tab_slug ) { |
|
| 387 | + switch ($this->tab_slug) { |
|
| 388 | 388 | case 'accommodation': |
| 389 | 389 | $this->current_importer = new LSX_WETU_Importer_Accommodation(); |
| 390 | 390 | break; |
@@ -411,36 +411,36 @@ discard block |
||
| 411 | 411 | * Registers the admin page which will house the importer form. |
| 412 | 412 | */ |
| 413 | 413 | public function register_importer_page() { |
| 414 | - add_submenu_page( 'tour-operator', esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'lsx-wetu-importer', array( $this, 'display_page' ) ); |
|
| 414 | + add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'lsx-wetu-importer', array($this, 'display_page')); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
| 418 | 418 | * Enqueue the JS needed to contact wetu and return your result. |
| 419 | 419 | */ |
| 420 | 420 | public function admin_scripts() { |
| 421 | - if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { |
|
| 421 | + if (defined('WP_DEBUG') && true === WP_DEBUG) { |
|
| 422 | 422 | $min = ''; |
| 423 | - } else { |
|
| 423 | + }else { |
|
| 424 | 424 | $min = '.min'; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | $min = ''; |
| 428 | 428 | |
| 429 | - if ( is_admin() && isset( $_GET['page'] ) && $this->plugin_slug === $_GET['page'] ) { |
|
| 429 | + if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) { |
|
| 430 | 430 | |
| 431 | 431 | //wp_enqueue_style( 'datatables', LSX_WETU_IMPORTER_URL . 'assets/css/datatables' . $min . '.css', LSX_WETU_IMPORTER_VER, true ); |
| 432 | - wp_enqueue_style( 'lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL . 'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true ); |
|
| 432 | + wp_enqueue_style('lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL.'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true); |
|
| 433 | 433 | |
| 434 | - if ( isset( $_GET['tab'] ) ) { |
|
| 435 | - wp_enqueue_script( 'datatables', LSX_WETU_IMPORTER_URL . 'assets/js/datatables' . $min . '.js', array( 'jquery' ), LSX_WETU_IMPORTER_VER, true ); |
|
| 436 | - wp_enqueue_script( 'lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL . 'assets/js/lsx-wetu-importer' . $min . '.js', array( 'jquery', 'datatables' ), LSX_WETU_IMPORTER_VER, true ); |
|
| 434 | + if (isset($_GET['tab'])) { |
|
| 435 | + wp_enqueue_script('datatables', LSX_WETU_IMPORTER_URL.'assets/js/datatables'.$min.'.js', array('jquery'), LSX_WETU_IMPORTER_VER, true); |
|
| 436 | + wp_enqueue_script('lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL.'assets/js/lsx-wetu-importer'.$min.'.js', array('jquery', 'datatables'), LSX_WETU_IMPORTER_VER, true); |
|
| 437 | 437 | |
| 438 | 438 | wp_localize_script( |
| 439 | 439 | 'lsx-wetu-importers-script', |
| 440 | 440 | 'lsx_tour_importer_params', |
| 441 | 441 | array( |
| 442 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 443 | - 'ajax_nonce' => wp_create_nonce( 'lsx_wetu_ajax_action' ), |
|
| 442 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 443 | + 'ajax_nonce' => wp_create_nonce('lsx_wetu_ajax_action'), |
|
| 444 | 444 | ) |
| 445 | 445 | ); |
| 446 | 446 | } |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | ?> |
| 455 | 455 | <div class="wrap"> |
| 456 | 456 | <?php |
| 457 | - $this->navigation( $this->tab_slug ); |
|
| 458 | - if ( 'default' !== $this->tab_slug && 'settings' !== $this->tab_slug ) { |
|
| 457 | + $this->navigation($this->tab_slug); |
|
| 458 | + if ('default' !== $this->tab_slug && 'settings' !== $this->tab_slug) { |
|
| 459 | 459 | $this->wetu_status(); |
| 460 | 460 | $this->post_status_navigation(); |
| 461 | 461 | } |
@@ -473,15 +473,15 @@ discard block |
||
| 473 | 473 | public function post_status_navigation() { |
| 474 | 474 | ?> |
| 475 | 475 | <ul class="subsubsub"> |
| 476 | - <li class="searchform"><a class="current" href="#search"><?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?></a> | </li> |
|
| 477 | - <li class="publish"><a href="#publish"><?php esc_attr_e( 'Published', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_post_count( $this->tab_slug, 'publish ' ) ); ?>)</span></a> | </li> |
|
| 478 | - <li class="pending"><a href="#pending"><?php esc_attr_e( 'Pending', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_post_count( $this->tab_slug, 'pending ' ) ); ?>)</span></a>| </li> |
|
| 479 | - <li class="draft"><a href="#draft"><?php esc_attr_e( 'Draft', 'lsx-wetu-importer' ); ?></a> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_post_count( $this->tab_slug, 'draft ' ) ); ?>)</span></li> |
|
| 480 | - |
|
| 481 | - <?php if ( 'tour' === $this->tab_slug ) { ?> |
|
| 482 | - <li class="import"> | <a class="import search-toggle" href="#import"><?php esc_attr_e( 'WETU', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_tour_count() ); ?>)</span></a></li> |
|
| 483 | - <?php } else if ( ! empty( $this->queued_imports ) ) { ?> |
|
| 484 | - <li class="import"> | <a class="import search-toggle" href="#import"><?php esc_attr_e( 'WETU Queue', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_queue_count( $this->tab_slug ) ); ?>)</span></a></li> |
|
| 476 | + <li class="searchform"><a class="current" href="#search"><?php esc_attr_e('Search', 'lsx-wetu-importer'); ?></a> | </li> |
|
| 477 | + <li class="publish"><a href="#publish"><?php esc_attr_e('Published', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_post_count($this->tab_slug, 'publish ')); ?>)</span></a> | </li> |
|
| 478 | + <li class="pending"><a href="#pending"><?php esc_attr_e('Pending', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_post_count($this->tab_slug, 'pending ')); ?>)</span></a>| </li> |
|
| 479 | + <li class="draft"><a href="#draft"><?php esc_attr_e('Draft', 'lsx-wetu-importer'); ?></a> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_post_count($this->tab_slug, 'draft ')); ?>)</span></li> |
|
| 480 | + |
|
| 481 | + <?php if ('tour' === $this->tab_slug) { ?> |
|
| 482 | + <li class="import"> | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_tour_count()); ?>)</span></a></li> |
|
| 483 | + <?php }else if (!empty($this->queued_imports)) { ?> |
|
| 484 | + <li class="import"> | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU Queue', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_queue_count($this->tab_slug)); ?>)</span></a></li> |
|
| 485 | 485 | <?php } ?> |
| 486 | 486 | </ul> |
| 487 | 487 | <?php |
@@ -492,29 +492,29 @@ discard block |
||
| 492 | 492 | */ |
| 493 | 493 | public function search_form() { |
| 494 | 494 | ?> |
| 495 | - <form class="ajax-form" id="<?php echo esc_attr( $this->plugin_slug ); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr( $this->tab_slug ); ?>"> |
|
| 496 | - <input type="hidden" name="page" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 495 | + <form class="ajax-form" id="<?php echo esc_attr($this->plugin_slug); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr($this->tab_slug); ?>"> |
|
| 496 | + <input type="hidden" name="page" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 497 | 497 | |
| 498 | - <?php do_action( 'lsx_wetu_importer_search_form',$this ); ?> |
|
| 498 | + <?php do_action('lsx_wetu_importer_search_form', $this); ?> |
|
| 499 | 499 | |
| 500 | 500 | <div class="normal-search"> |
| 501 | - <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e( 'Search', 'lsx-wetu-importer' ); ?>" /> |
|
| 501 | + <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e('Search', 'lsx-wetu-importer'); ?>" /> |
|
| 502 | 502 | </div> |
| 503 | 503 | |
| 504 | 504 | <div class="advanced-search hidden" style="display:none;"> |
| 505 | 505 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
| 506 | - <input class="button button-primary submit" type="submit" value="<?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?>" /> |
|
| 506 | + <input class="button button-primary submit" type="submit" value="<?php esc_attr_e('Search', 'lsx-wetu-importer'); ?>" /> |
|
| 507 | 507 | </div> |
| 508 | 508 | |
| 509 | 509 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
| 510 | - <img style="width:64px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
|
| 510 | + <img style="width:64px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" /> |
|
| 511 | 511 | </div> |
| 512 | 512 | |
| 513 | 513 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
| 514 | - <img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
|
| 514 | + <img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" /> |
|
| 515 | 515 | </div> |
| 516 | 516 | |
| 517 | - <a class="button advanced-search-toggle" href="#"><?php esc_html_e( 'Bulk Search', 'lsx-wetu-importer' ); ?></a> |
|
| 517 | + <a class="button advanced-search-toggle" href="#"><?php esc_html_e('Bulk Search', 'lsx-wetu-importer'); ?></a> |
|
| 518 | 518 | </form> |
| 519 | 519 | <?php |
| 520 | 520 | } |
@@ -527,12 +527,12 @@ discard block |
||
| 527 | 527 | <thead> |
| 528 | 528 | <tr> |
| 529 | 529 | <th style="" class="manage-column column-cb check-column no-sort" id="cb" scope="col"> |
| 530 | - <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label> |
|
| 530 | + <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label> |
|
| 531 | 531 | <input type="checkbox" id="cb-select-all-1"> |
| 532 | 532 | </th> |
| 533 | - <th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th> |
|
| 534 | - <th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th> |
|
| 535 | - <th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th> |
|
| 533 | + <th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th> |
|
| 534 | + <th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th> |
|
| 535 | + <th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th> |
|
| 536 | 536 | </tr> |
| 537 | 537 | </thead> |
| 538 | 538 | <?php |
@@ -562,43 +562,43 @@ discard block |
||
| 562 | 562 | * |
| 563 | 563 | * @param $tab string |
| 564 | 564 | */ |
| 565 | - public function navigation( $tab = '' ) { |
|
| 565 | + public function navigation($tab = '') { |
|
| 566 | 566 | $post_types = array( |
| 567 | - 'tour' => esc_attr( 'Tours', 'lsx-wetu-importer' ), |
|
| 568 | - 'accommodation' => esc_attr( 'Accommodation', 'lsx-wetu-importer' ), |
|
| 569 | - 'destination' => esc_attr( 'Destinations', 'lsx-wetu-importer' ), |
|
| 567 | + 'tour' => esc_attr('Tours', 'lsx-wetu-importer'), |
|
| 568 | + 'accommodation' => esc_attr('Accommodation', 'lsx-wetu-importer'), |
|
| 569 | + 'destination' => esc_attr('Destinations', 'lsx-wetu-importer'), |
|
| 570 | 570 | ); |
| 571 | 571 | |
| 572 | - echo wp_kses_post( '<div class="wp-filter">' ); |
|
| 573 | - echo wp_kses_post( '<ul class="filter-links">' ); |
|
| 574 | - echo wp_kses_post( '<li><a class="' . $this->itemd( $tab, 'default', 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '">' . esc_attr__( 'Home', 'lsx-wetu-importer' ) . '</a></li>' ); |
|
| 572 | + echo wp_kses_post('<div class="wp-filter">'); |
|
| 573 | + echo wp_kses_post('<ul class="filter-links">'); |
|
| 574 | + echo wp_kses_post('<li><a class="'.$this->itemd($tab, 'default', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr__('Home', 'lsx-wetu-importer').'</a></li>'); |
|
| 575 | 575 | |
| 576 | - foreach ( $post_types as $post_type => $label ) { |
|
| 577 | - echo wp_kses_post( ' | <li><a class="' . $this->itemd( $tab, $post_type, 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '&tab=' . $post_type . '">' . $label . '</a></li>' ); |
|
| 576 | + foreach ($post_types as $post_type => $label) { |
|
| 577 | + echo wp_kses_post(' | <li><a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a></li>'); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - echo wp_kses_post( ' | <li><a class="' . $this->itemd( $tab, 'settings', 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '&tab=settings">' . esc_attr__( 'Settings', 'lsx-wetu-importer' ) . '</a></li>' ); |
|
| 581 | - echo wp_kses_post( '</ul> </div>' ); |
|
| 580 | + echo wp_kses_post(' | <li><a class="'.$this->itemd($tab, 'settings', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=settings">'.esc_attr__('Settings', 'lsx-wetu-importer').'</a></li>'); |
|
| 581 | + echo wp_kses_post('</ul> </div>'); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
| 585 | 585 | * Wetu Status Bar. |
| 586 | 586 | */ |
| 587 | 587 | public function wetu_status() { |
| 588 | - $tours = get_transient( 'lsx_ti_tours' ); |
|
| 589 | - echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status','lsx-wetu-importer' ) . ' - '; |
|
| 588 | + $tours = get_transient('lsx_ti_tours'); |
|
| 589 | + echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').' - '; |
|
| 590 | 590 | |
| 591 | - if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) { |
|
| 591 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
| 592 | 592 | $result = $this->update_options(); |
| 593 | 593 | |
| 594 | - if ( true === $result ) { |
|
| 595 | - echo '<span style="color:green;">' . esc_attr( 'Connected','lsx-wetu-importer' ) . '</span>'; |
|
| 596 | - echo ' - <small><a href="#">' . esc_attr( 'Refresh','lsx-wetu-importer' ) . '</a></small>'; |
|
| 597 | - } else { |
|
| 598 | - echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>'; |
|
| 594 | + if (true === $result) { |
|
| 595 | + echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span>'; |
|
| 596 | + echo ' - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>'; |
|
| 597 | + }else { |
|
| 598 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
| 599 | 599 | } |
| 600 | - } else { |
|
| 601 | - echo '<span style="color:green;">' . esc_attr( 'Connected','lsx-wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh','lsx-wetu-importer' ) . '</a></small>'; |
|
| 600 | + }else { |
|
| 601 | + echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>'; |
|
| 602 | 602 | } |
| 603 | 603 | echo '</h3>'; |
| 604 | 604 | echo '</div>'; |
@@ -607,8 +607,8 @@ discard block |
||
| 607 | 607 | /** |
| 608 | 608 | * Set_taxonomy with some terms |
| 609 | 609 | */ |
| 610 | - public function team_member_checkboxes( $selected = array() ) { |
|
| 611 | - if ( post_type_exists( 'team' ) ) { ?> |
|
| 610 | + public function team_member_checkboxes($selected = array()) { |
|
| 611 | + if (post_type_exists('team')) { ?> |
|
| 612 | 612 | <ul> |
| 613 | 613 | <?php |
| 614 | 614 | $team_args = array( |
@@ -618,16 +618,16 @@ discard block |
||
| 618 | 618 | 'fields' => 'ids', |
| 619 | 619 | ); |
| 620 | 620 | |
| 621 | - $team_members = new WP_Query( $team_args ); |
|
| 621 | + $team_members = new WP_Query($team_args); |
|
| 622 | 622 | |
| 623 | - if ( $team_members->have_posts() ) { |
|
| 624 | - foreach ( $team_members->posts as $member ) { |
|
| 623 | + if ($team_members->have_posts()) { |
|
| 624 | + foreach ($team_members->posts as $member) { |
|
| 625 | 625 | ?> |
| 626 | - <li><input class="team" <?php $this->checked( $selected, $member ); ?> type="checkbox" value="<?php echo esc_attr( $member ); ?>" /> <?php echo wp_kses_post( get_the_title( $member ) ); ?></li> |
|
| 626 | + <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo esc_attr($member); ?>" /> <?php echo wp_kses_post(get_the_title($member)); ?></li> |
|
| 627 | 627 | <?php |
| 628 | 628 | } |
| 629 | - } else { ?> |
|
| 630 | - <li><input class="team" type="checkbox" value="0" /> <?php esc_html_e( 'None', 'lsx-wetu-importer' ); ?></li> |
|
| 629 | + }else { ?> |
|
| 630 | + <li><input class="team" type="checkbox" value="0" /> <?php esc_html_e('None', 'lsx-wetu-importer'); ?></li> |
|
| 631 | 631 | <?php } |
| 632 | 632 | ?> |
| 633 | 633 | </ul> |
@@ -644,13 +644,13 @@ discard block |
||
| 644 | 644 | * @param $needle string |
| 645 | 645 | * @param $echo bool |
| 646 | 646 | */ |
| 647 | - public function checked( $haystack = false, $needle = '', $echo = true ) { |
|
| 648 | - $return = $this->itemd( $haystack,$needle, 'checked' ); |
|
| 647 | + public function checked($haystack = false, $needle = '', $echo = true) { |
|
| 648 | + $return = $this->itemd($haystack, $needle, 'checked'); |
|
| 649 | 649 | |
| 650 | - if ( '' !== $return ) { |
|
| 651 | - if ( true === $echo ) { |
|
| 652 | - echo wp_kses_post( $return ); |
|
| 653 | - } else { |
|
| 650 | + if ('' !== $return) { |
|
| 651 | + if (true === $echo) { |
|
| 652 | + echo wp_kses_post($return); |
|
| 653 | + }else { |
|
| 654 | 654 | return $return; |
| 655 | 655 | } |
| 656 | 656 | } |
@@ -663,13 +663,13 @@ discard block |
||
| 663 | 663 | * @param $needle string |
| 664 | 664 | * @param $echo bool |
| 665 | 665 | */ |
| 666 | - public function selected( $haystack = false, $needle = '', $echo = true ) { |
|
| 667 | - $return = $this->itemd( $haystack, $needle, 'selected' ); |
|
| 666 | + public function selected($haystack = false, $needle = '', $echo = true) { |
|
| 667 | + $return = $this->itemd($haystack, $needle, 'selected'); |
|
| 668 | 668 | |
| 669 | - if ( '' !== $return ) { |
|
| 670 | - if ( true === $echo ) { |
|
| 671 | - echo wp_kses_post( $return ); |
|
| 672 | - } else { |
|
| 669 | + if ('' !== $return) { |
|
| 670 | + if (true === $echo) { |
|
| 671 | + echo wp_kses_post($return); |
|
| 672 | + }else { |
|
| 673 | 673 | return $return; |
| 674 | 674 | } |
| 675 | 675 | } |
@@ -684,17 +684,17 @@ discard block |
||
| 684 | 684 | * @param $wrap bool |
| 685 | 685 | * @return $html string |
| 686 | 686 | */ |
| 687 | - public function itemd( $haystack = false, $needle = '', $type = '', $wrap = true ) { |
|
| 687 | + public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) { |
|
| 688 | 688 | $html = ''; |
| 689 | 689 | |
| 690 | - if ( '' !== $type ) { |
|
| 691 | - if ( ! is_array( $haystack ) ) { |
|
| 692 | - $haystack = array( $haystack ); |
|
| 690 | + if ('' !== $type) { |
|
| 691 | + if (!is_array($haystack)) { |
|
| 692 | + $haystack = array($haystack); |
|
| 693 | 693 | } |
| 694 | - if ( in_array( $needle, $haystack ) ) { |
|
| 695 | - if ( true === $wrap || 'true' === $wrap ) { |
|
| 696 | - $html = $type . '="' . $type . '"'; |
|
| 697 | - } else { |
|
| 694 | + if (in_array($needle, $haystack)) { |
|
| 695 | + if (true === $wrap || 'true' === $wrap) { |
|
| 696 | + $html = $type.'="'.$type.'"'; |
|
| 697 | + }else { |
|
| 698 | 698 | $html = $type; |
| 699 | 699 | } |
| 700 | 700 | } |
@@ -706,9 +706,9 @@ discard block |
||
| 706 | 706 | /** |
| 707 | 707 | * Grabs any attachments for the current item |
| 708 | 708 | */ |
| 709 | - public function find_attachments( $id = false ) { |
|
| 710 | - if ( false !== $id ) { |
|
| 711 | - if ( empty( $this->found_attachments ) ) { |
|
| 709 | + public function find_attachments($id = false) { |
|
| 710 | + if (false !== $id) { |
|
| 711 | + if (empty($this->found_attachments)) { |
|
| 712 | 712 | $attachments_args = array( |
| 713 | 713 | 'post_parent' => $id, |
| 714 | 714 | 'post_status' => 'inherit', |
@@ -718,11 +718,11 @@ discard block |
||
| 718 | 718 | 'posts_per_page' => '-1', |
| 719 | 719 | ); |
| 720 | 720 | |
| 721 | - $attachments = new WP_Query( $attachments_args ); |
|
| 721 | + $attachments = new WP_Query($attachments_args); |
|
| 722 | 722 | |
| 723 | - if ( $attachments->have_posts() ) { |
|
| 724 | - foreach ( $attachments->posts as $attachment ) { |
|
| 725 | - $this->found_attachments[ $attachment->ID ] = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $attachment->post_title ); |
|
| 723 | + if ($attachments->have_posts()) { |
|
| 724 | + foreach ($attachments->posts as $attachment) { |
|
| 725 | + $this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | } |
@@ -734,19 +734,19 @@ discard block |
||
| 734 | 734 | /** |
| 735 | 735 | * Saves the room data |
| 736 | 736 | */ |
| 737 | - public function save_custom_field( $value = false, $meta_key, $id, $decrease = false, $unique = true ) { |
|
| 738 | - if ( false !== $value ) { |
|
| 739 | - if ( false !== $decrease ) { |
|
| 740 | - $value = intval( $value ); |
|
| 737 | + public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) { |
|
| 738 | + if (false !== $value) { |
|
| 739 | + if (false !== $decrease) { |
|
| 740 | + $value = intval($value); |
|
| 741 | 741 | $value--; |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - $prev = get_post_meta( $id, $meta_key, true ); |
|
| 744 | + $prev = get_post_meta($id, $meta_key, true); |
|
| 745 | 745 | |
| 746 | - if ( false !== $id && '0' !== $id && false !== $prev && true === $unique ) { |
|
| 747 | - update_post_meta( $id, $meta_key, $value, $prev ); |
|
| 748 | - } else { |
|
| 749 | - add_post_meta( $id, $meta_key, $value, $unique ); |
|
| 746 | + if (false !== $id && '0' !== $id && false !== $prev && true === $unique) { |
|
| 747 | + update_post_meta($id, $meta_key, $value, $prev); |
|
| 748 | + }else { |
|
| 749 | + add_post_meta($id, $meta_key, $value, $unique); |
|
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | } |
@@ -755,15 +755,15 @@ discard block |
||
| 755 | 755 | * Grabs the custom fields, and resaves an array of unique items. |
| 756 | 756 | */ |
| 757 | 757 | public function cleanup_posts() { |
| 758 | - if ( ! empty( $this->cleanup_posts ) ) { |
|
| 758 | + if (!empty($this->cleanup_posts)) { |
|
| 759 | 759 | |
| 760 | - foreach ( $this->cleanup_posts as $id => $key ) { |
|
| 761 | - $prev_items = get_post_meta( $id, $key, false ); |
|
| 762 | - $new_items = array_unique( $prev_items ); |
|
| 763 | - delete_post_meta( $id, $key ); |
|
| 760 | + foreach ($this->cleanup_posts as $id => $key) { |
|
| 761 | + $prev_items = get_post_meta($id, $key, false); |
|
| 762 | + $new_items = array_unique($prev_items); |
|
| 763 | + delete_post_meta($id, $key); |
|
| 764 | 764 | |
| 765 | - foreach ( $new_items as $new_item ) { |
|
| 766 | - add_post_meta( $id, $key, $new_item, false ); |
|
| 765 | + foreach ($new_items as $new_item) { |
|
| 766 | + add_post_meta($id, $key, $new_item, false); |
|
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | } |
@@ -774,26 +774,26 @@ discard block |
||
| 774 | 774 | /** |
| 775 | 775 | * Set_taxonomy with some terms |
| 776 | 776 | */ |
| 777 | - public function set_taxonomy( $taxonomy, $terms, $id ) { |
|
| 777 | + public function set_taxonomy($taxonomy, $terms, $id) { |
|
| 778 | 778 | $result = array(); |
| 779 | 779 | |
| 780 | - if ( ! empty( $data ) ) { |
|
| 781 | - foreach ( $data as $k ) { |
|
| 782 | - if ( $id ) { |
|
| 783 | - $term = term_exists( trim( $k ), $tax ); |
|
| 784 | - if ( ! $term ) { |
|
| 785 | - $term = wp_insert_term( trim( $k ), $tax ); |
|
| 786 | - |
|
| 787 | - if ( is_wp_error( $term ) ) { |
|
| 788 | - echo wp_kses_post( $term->get_error_message() ); |
|
| 789 | - } else { |
|
| 790 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 780 | + if (!empty($data)) { |
|
| 781 | + foreach ($data as $k) { |
|
| 782 | + if ($id) { |
|
| 783 | + $term = term_exists(trim($k), $tax); |
|
| 784 | + if (!$term) { |
|
| 785 | + $term = wp_insert_term(trim($k), $tax); |
|
| 786 | + |
|
| 787 | + if (is_wp_error($term)) { |
|
| 788 | + echo wp_kses_post($term->get_error_message()); |
|
| 789 | + }else { |
|
| 790 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 791 | 791 | } |
| 792 | - } else { |
|
| 793 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 792 | + }else { |
|
| 793 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 794 | 794 | } |
| 795 | - } else { |
|
| 796 | - $result[] = trim( $k ); |
|
| 795 | + }else { |
|
| 796 | + $result[] = trim($k); |
|
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | } |
@@ -809,23 +809,23 @@ discard block |
||
| 809 | 809 | * @param boolean $parent |
| 810 | 810 | * @return void |
| 811 | 811 | */ |
| 812 | - public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) { |
|
| 813 | - $term = term_exists( $name, $taxonomy ); |
|
| 814 | - if ( ! $term ) { |
|
| 815 | - if ( false !== $parent ) { |
|
| 812 | + public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) { |
|
| 813 | + $term = term_exists($name, $taxonomy); |
|
| 814 | + if (!$term) { |
|
| 815 | + if (false !== $parent) { |
|
| 816 | 816 | $parent = array( |
| 817 | 817 | 'parent' => $parent, |
| 818 | 818 | ); |
| 819 | 819 | } |
| 820 | - $term = wp_insert_term( trim( $name ), $taxonomy,$parent ); |
|
| 820 | + $term = wp_insert_term(trim($name), $taxonomy, $parent); |
|
| 821 | 821 | |
| 822 | - if ( is_wp_error( $term ) ) { |
|
| 823 | - echo wp_kses_post( $term->get_error_message() ); |
|
| 824 | - } else { |
|
| 825 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 822 | + if (is_wp_error($term)) { |
|
| 823 | + echo wp_kses_post($term->get_error_message()); |
|
| 824 | + }else { |
|
| 825 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 826 | 826 | } |
| 827 | - } else { |
|
| 828 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 827 | + }else { |
|
| 828 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | return $term['term_id']; |
@@ -834,22 +834,22 @@ discard block |
||
| 834 | 834 | /** |
| 835 | 835 | * set_taxonomy with some terms |
| 836 | 836 | */ |
| 837 | - public function taxonomy_checkboxes( $taxonomy = false, $selected = array() ) { |
|
| 837 | + public function taxonomy_checkboxes($taxonomy = false, $selected = array()) { |
|
| 838 | 838 | $return = ''; |
| 839 | 839 | |
| 840 | - if ( false !== $taxonomy ) { |
|
| 840 | + if (false !== $taxonomy) { |
|
| 841 | 841 | $return .= '<ul>'; |
| 842 | - $terms = get_terms( array( |
|
| 842 | + $terms = get_terms(array( |
|
| 843 | 843 | 'taxonomy' => $taxonomy, |
| 844 | 844 | 'hide_empty' => false, |
| 845 | - ) ); |
|
| 845 | + )); |
|
| 846 | 846 | |
| 847 | - if ( ! is_wp_error( $terms ) ) { |
|
| 848 | - foreach ( $terms as $term ) { |
|
| 849 | - $return .= '<li><input class="' . $taxonomy . '" ' . $this->checked( $selected,$term->term_id,false ) . ' type="checkbox" value="' . $term->term_id . '" /> ' . $term->name . '</li>'; |
|
| 847 | + if (!is_wp_error($terms)) { |
|
| 848 | + foreach ($terms as $term) { |
|
| 849 | + $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
| 850 | 850 | } |
| 851 | - } else { |
|
| 852 | - $return .= '<li><input type="checkbox" value="" /> ' . __( 'None', 'lsx-wetu-importer' ) . '</li>'; |
|
| 851 | + }else { |
|
| 852 | + $return .= '<li><input type="checkbox" value="" /> '.__('None', 'lsx-wetu-importer').'</li>'; |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | $return .= '</ul>'; |
@@ -863,44 +863,44 @@ discard block |
||
| 863 | 863 | /** |
| 864 | 864 | * Saves the longitude and lattitude, as well as sets the map marker. |
| 865 | 865 | */ |
| 866 | - public function set_map_data( $data, $id, $zoom = '10' ) { |
|
| 866 | + public function set_map_data($data, $id, $zoom = '10') { |
|
| 867 | 867 | $longitude = false; |
| 868 | 868 | $latitude = false; |
| 869 | 869 | $address = false; |
| 870 | 870 | |
| 871 | - if ( isset( $data[0]['position'] ) ) { |
|
| 872 | - if ( isset( $data[0]['position']['driving_latitude'] ) ) { |
|
| 871 | + if (isset($data[0]['position'])) { |
|
| 872 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
| 873 | 873 | $latitude = $data[0]['position']['driving_latitude']; |
| 874 | - } elseif ( isset( $data[0]['position']['latitude'] ) ) { |
|
| 874 | + } elseif (isset($data[0]['position']['latitude'])) { |
|
| 875 | 875 | $latitude = $data[0]['position']['latitude']; |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - if ( isset( $data[0]['position']['driving_longitude'] ) ) { |
|
| 878 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
| 879 | 879 | $longitude = $data[0]['position']['driving_longitude']; |
| 880 | - } elseif ( isset( $data[0]['position']['longitude'] ) ) { |
|
| 880 | + } elseif (isset($data[0]['position']['longitude'])) { |
|
| 881 | 881 | $longitude = $data[0]['position']['longitude']; |
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - if ( isset( $data[0]['content'] ) && isset( $data[0]['content']['contact_information'] ) ) { |
|
| 886 | - if ( isset( $data[0]['content']['contact_information']['address'] ) ) { |
|
| 887 | - $address = strip_tags( $data[0]['content']['contact_information']['address'] ); |
|
| 888 | - $address = explode( "\n", $address ); |
|
| 885 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
| 886 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
| 887 | + $address = strip_tags($data[0]['content']['contact_information']['address']); |
|
| 888 | + $address = explode("\n", $address); |
|
| 889 | 889 | |
| 890 | - foreach ( $address as $bitkey => $bit ) { |
|
| 891 | - $bit = ltrim( rtrim( $bit ) ); |
|
| 890 | + foreach ($address as $bitkey => $bit) { |
|
| 891 | + $bit = ltrim(rtrim($bit)); |
|
| 892 | 892 | |
| 893 | - if ( false === $bit || '' === $bit || null === $bit || empty( $bit ) ) { |
|
| 894 | - unset( $address[ $bitkey ] ); |
|
| 893 | + if (false === $bit || '' === $bit || null === $bit || empty($bit)) { |
|
| 894 | + unset($address[$bitkey]); |
|
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - $address = implode( ', ',$address ); |
|
| 899 | - $address = str_replace( ', , ', ', ', $address ); |
|
| 898 | + $address = implode(', ', $address); |
|
| 899 | + $address = str_replace(', , ', ', ', $address); |
|
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - if ( false !== $longitude ) { |
|
| 903 | + if (false !== $longitude) { |
|
| 904 | 904 | $location_data = array( |
| 905 | 905 | 'address' => (string) $address, |
| 906 | 906 | 'lat' => (string) $latitude, |
@@ -909,11 +909,11 @@ discard block |
||
| 909 | 909 | 'elevation' => '', |
| 910 | 910 | ); |
| 911 | 911 | |
| 912 | - if ( false !== $id && '0' !== $id ) { |
|
| 913 | - $prev = get_post_meta( $id,'location',true ); |
|
| 914 | - update_post_meta( $id,'location',$location_data,$prev ); |
|
| 915 | - } else { |
|
| 916 | - add_post_meta( $id,'location',$location_data,true ); |
|
| 912 | + if (false !== $id && '0' !== $id) { |
|
| 913 | + $prev = get_post_meta($id, 'location', true); |
|
| 914 | + update_post_meta($id, 'location', $location_data, $prev); |
|
| 915 | + }else { |
|
| 916 | + add_post_meta($id, 'location', $location_data, true); |
|
| 917 | 917 | } |
| 918 | 918 | } |
| 919 | 919 | } |
@@ -923,17 +923,17 @@ discard block |
||
| 923 | 923 | /** |
| 924 | 924 | * Creates the main gallery data |
| 925 | 925 | */ |
| 926 | - public function set_featured_image( $data, $id ) { |
|
| 927 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 928 | - $this->featured_image = $this->attach_image( $data[0]['content']['images'][0], $id, array( |
|
| 926 | + public function set_featured_image($data, $id) { |
|
| 927 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 928 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id, array( |
|
| 929 | 929 | 'width' => '800', |
| 930 | 930 | 'height' => '600', |
| 931 | 931 | 'cropping' => 'h', |
| 932 | - ) ); |
|
| 932 | + )); |
|
| 933 | 933 | |
| 934 | - if ( false !== $this->featured_image ) { |
|
| 935 | - delete_post_meta( $id,'_thumbnail_id' ); |
|
| 936 | - add_post_meta( $id,'_thumbnail_id',$this->featured_image,true ); |
|
| 934 | + if (false !== $this->featured_image) { |
|
| 935 | + delete_post_meta($id, '_thumbnail_id'); |
|
| 936 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | 939 | } |
@@ -941,26 +941,26 @@ discard block |
||
| 941 | 941 | /** |
| 942 | 942 | * Sets a banner image |
| 943 | 943 | */ |
| 944 | - public function set_banner_image( $data, $id, $content = array( 'none' ) ) { |
|
| 945 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 946 | - if ( in_array( 'unique_banner_image', $content ) && isset( $data[0]['destination_image'] ) && is_array( $data[0]['destination_image'] ) ) { |
|
| 947 | - $temp_banner = $this->attach_image( $data[0]['destination_image'], $id, array( |
|
| 944 | + public function set_banner_image($data, $id, $content = array('none')) { |
|
| 945 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 946 | + if (in_array('unique_banner_image', $content) && isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
| 947 | + $temp_banner = $this->attach_image($data[0]['destination_image'], $id, array( |
|
| 948 | 948 | 'width' => '1920', |
| 949 | 949 | 'height' => '600', |
| 950 | 950 | 'cropping' => 'c', |
| 951 | 951 | )); |
| 952 | - } else { |
|
| 953 | - $temp_banner = $this->attach_image( $data[0]['content']['images'][1], $id, array( |
|
| 952 | + }else { |
|
| 953 | + $temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array( |
|
| 954 | 954 | 'width' => '1920', |
| 955 | 955 | 'height' => '600', |
| 956 | 956 | 'cropping' => 'c', |
| 957 | 957 | )); |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - if ( false !== $temp_banner ) { |
|
| 960 | + if (false !== $temp_banner) { |
|
| 961 | 961 | $this->banner_image = $temp_banner; |
| 962 | 962 | |
| 963 | - delete_post_meta( $id,'image_group' ); |
|
| 963 | + delete_post_meta($id, 'image_group'); |
|
| 964 | 964 | |
| 965 | 965 | $new_banner = array( |
| 966 | 966 | 'banner_image' => array( |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | ), |
| 969 | 969 | ); |
| 970 | 970 | |
| 971 | - add_post_meta( $id,'image_group',$new_banner,true ); |
|
| 971 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
| 972 | 972 | } |
| 973 | 973 | } |
| 974 | 974 | } |
@@ -976,17 +976,17 @@ discard block |
||
| 976 | 976 | /** |
| 977 | 977 | * Creates the main gallery data |
| 978 | 978 | */ |
| 979 | - public function create_main_gallery( $data, $id ) { |
|
| 980 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 981 | - if ( isset( $this->options['image_replacing'] ) && 'on' === $this->options['image_replacing'] ) { |
|
| 982 | - $current_gallery = get_post_meta( $id, 'gallery', false ); |
|
| 979 | + public function create_main_gallery($data, $id) { |
|
| 980 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 981 | + if (isset($this->options['image_replacing']) && 'on' === $this->options['image_replacing']) { |
|
| 982 | + $current_gallery = get_post_meta($id, 'gallery', false); |
|
| 983 | 983 | |
| 984 | - if ( false !== $current_gallery && ! empty( $current_gallery ) ) { |
|
| 985 | - foreach ( $current_gallery as $g ) { |
|
| 986 | - delete_post_meta( $id,'gallery', $g ); |
|
| 984 | + if (false !== $current_gallery && !empty($current_gallery)) { |
|
| 985 | + foreach ($current_gallery as $g) { |
|
| 986 | + delete_post_meta($id, 'gallery', $g); |
|
| 987 | 987 | |
| 988 | - if ( 'attachment' === get_post_type( $g ) ) { |
|
| 989 | - wp_delete_attachment( $g, true ); |
|
| 988 | + if ('attachment' === get_post_type($g)) { |
|
| 989 | + wp_delete_attachment($g, true); |
|
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | } |
@@ -994,32 +994,32 @@ discard block |
||
| 994 | 994 | |
| 995 | 995 | $counter = 0; |
| 996 | 996 | |
| 997 | - foreach ( $data[0]['content']['images'] as $image_data ) { |
|
| 998 | - if ( ( 0 === $counter && false !== $this->featured_image ) || ( 1 === $counter && false !== $this->banner_image ) ) { |
|
| 997 | + foreach ($data[0]['content']['images'] as $image_data) { |
|
| 998 | + if ((0 === $counter && false !== $this->featured_image) || (1 === $counter && false !== $this->banner_image)) { |
|
| 999 | 999 | $counter++; |
| 1000 | 1000 | |
| 1001 | - if ( false !== $this->image_limit && false !== $this->image_limit ) { |
|
| 1001 | + if (false !== $this->image_limit && false !== $this->image_limit) { |
|
| 1002 | 1002 | $this->image_limit++; |
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | continue; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - if ( false !== $this->image_limit && $counter >= $this->image_limit ) { |
|
| 1008 | + if (false !== $this->image_limit && $counter >= $this->image_limit) { |
|
| 1009 | 1009 | continue; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - $this->gallery_meta[] = $this->attach_image( $image_data,$id ); |
|
| 1012 | + $this->gallery_meta[] = $this->attach_image($image_data, $id); |
|
| 1013 | 1013 | $counter++; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | - if ( ! empty( $this->gallery_meta ) ) { |
|
| 1017 | - delete_post_meta( $id,'gallery' ); |
|
| 1018 | - $this->gallery_meta = array_unique( $this->gallery_meta ); |
|
| 1016 | + if (!empty($this->gallery_meta)) { |
|
| 1017 | + delete_post_meta($id, 'gallery'); |
|
| 1018 | + $this->gallery_meta = array_unique($this->gallery_meta); |
|
| 1019 | 1019 | |
| 1020 | - foreach ( $this->gallery_meta as $gallery_id ) { |
|
| 1021 | - if ( false !== $gallery_id && '' !== $gallery_id && ! is_array( $gallery_id ) ) { |
|
| 1022 | - add_post_meta( $id,'gallery',$gallery_id,false ); |
|
| 1020 | + foreach ($this->gallery_meta as $gallery_id) { |
|
| 1021 | + if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) { |
|
| 1022 | + add_post_meta($id, 'gallery', $gallery_id, false); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | } |
| 1025 | 1025 | } |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | /** |
| 1030 | 1030 | * search_form |
| 1031 | 1031 | */ |
| 1032 | - public function get_scaling_url( $args = array() ) { |
|
| 1032 | + public function get_scaling_url($args = array()) { |
|
| 1033 | 1033 | $defaults = array( |
| 1034 | 1034 | 'width' => '1024', |
| 1035 | 1035 | 'height' => '768', |
@@ -1037,59 +1037,59 @@ discard block |
||
| 1037 | 1037 | 'cropping' => 'h', |
| 1038 | 1038 | ); |
| 1039 | 1039 | |
| 1040 | - if ( false !== $this->options ) { |
|
| 1041 | - if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) { |
|
| 1040 | + if (false !== $this->options) { |
|
| 1041 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
| 1042 | 1042 | $defaults['width'] = $this->options['width']; |
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | - if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) { |
|
| 1045 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
| 1046 | 1046 | $defaults['height'] = $this->options['height']; |
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | - if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) { |
|
| 1049 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
| 1050 | 1050 | $defaults['cropping'] = $this->options['cropping']; |
| 1051 | 1051 | } |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1054 | + $args = wp_parse_args($args, $defaults); |
|
| 1055 | 1055 | $cropping = $args['cropping']; |
| 1056 | 1056 | $width = $args['width']; |
| 1057 | 1057 | $height = $args['height']; |
| 1058 | 1058 | |
| 1059 | - return 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
| 1059 | + return 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/'; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | /** |
| 1063 | 1063 | * Attaches 1 image |
| 1064 | 1064 | */ |
| 1065 | - public function attach_image( $v = false, $parent_id, $image_sizes = false, $banner = false ) { |
|
| 1066 | - if ( false !== $v ) { |
|
| 1067 | - $temp_fragment = explode( '/',$v['url_fragment'] ); |
|
| 1068 | - $url_filename = $temp_fragment[ count( $temp_fragment ) -1 ]; |
|
| 1069 | - $url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename ); |
|
| 1070 | - $url_filename = trim( $url_filename ); |
|
| 1065 | + public function attach_image($v = false, $parent_id, $image_sizes = false, $banner = false) { |
|
| 1066 | + if (false !== $v) { |
|
| 1067 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
| 1068 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
| 1069 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
| 1070 | + $url_filename = trim($url_filename); |
|
| 1071 | 1071 | $title = $url_filename; |
| 1072 | - $url_filename = str_replace( ' ','_',$url_filename ); |
|
| 1072 | + $url_filename = str_replace(' ', '_', $url_filename); |
|
| 1073 | 1073 | |
| 1074 | - if ( ! isset( $this->options['image_replacing'] ) && in_array( $url_filename, $this->found_attachments ) ) { |
|
| 1075 | - return array_search( $url_filename,$this->found_attachments ); |
|
| 1074 | + if (!isset($this->options['image_replacing']) && in_array($url_filename, $this->found_attachments)) { |
|
| 1075 | + return array_search($url_filename, $this->found_attachments); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | $postdata = array(); |
| 1079 | 1079 | |
| 1080 | - if ( empty( $v['label'] ) ) { |
|
| 1080 | + if (empty($v['label'])) { |
|
| 1081 | 1081 | $v['label'] = ''; |
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | - if ( ! empty( $v['description'] ) ) { |
|
| 1085 | - $desc = wp_strip_all_tags( $v['description'] ); |
|
| 1084 | + if (!empty($v['description'])) { |
|
| 1085 | + $desc = wp_strip_all_tags($v['description']); |
|
| 1086 | 1086 | $posdata = array( |
| 1087 | 1087 | 'post_excerpt' => $desc, |
| 1088 | 1088 | ); |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - if ( ! empty( $v['section'] ) ) { |
|
| 1092 | - $desc = wp_strip_all_tags( $v['section'] ); |
|
| 1091 | + if (!empty($v['section'])) { |
|
| 1092 | + $desc = wp_strip_all_tags($v['section']); |
|
| 1093 | 1093 | $posdata = array( |
| 1094 | 1094 | 'post_excerpt' => $desc, |
| 1095 | 1095 | ); |
@@ -1097,85 +1097,85 @@ discard block |
||
| 1097 | 1097 | |
| 1098 | 1098 | $attach_id = null; |
| 1099 | 1099 | //Resizor - add option to setting if required |
| 1100 | - $fragment = str_replace( ' ','%20',$v['url_fragment'] ); |
|
| 1101 | - $url = $this->get_scaling_url( $image_sizes ) . $fragment; |
|
| 1100 | + $fragment = str_replace(' ', '%20', $v['url_fragment']); |
|
| 1101 | + $url = $this->get_scaling_url($image_sizes).$fragment; |
|
| 1102 | 1102 | |
| 1103 | - $attach_id = $this->attach_external_image2( $url,$parent_id,'',$v['label'],$postdata ); |
|
| 1103 | + $attach_id = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata); |
|
| 1104 | 1104 | |
| 1105 | - $this->found_attachments[ $attach_id ] = $url_filename; |
|
| 1105 | + $this->found_attachments[$attach_id] = $url_filename; |
|
| 1106 | 1106 | |
| 1107 | 1107 | //echo($attach_id.' add image'); |
| 1108 | - if ( ! empty( $attach_id ) ) { |
|
| 1108 | + if (!empty($attach_id)) { |
|
| 1109 | 1109 | return $attach_id; |
| 1110 | 1110 | } |
| 1111 | 1111 | } |
| 1112 | 1112 | return false; |
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | - public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
|
| 1116 | - if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); } |
|
| 1115 | + public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) { |
|
| 1116 | + if (!$url || !$post_id) { return new WP_Error('missing', 'Need a valid URL and post ID...'); } |
|
| 1117 | 1117 | $att_id = false; |
| 1118 | 1118 | |
| 1119 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
| 1120 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
| 1121 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
| 1119 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
| 1120 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
| 1121 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 1122 | 1122 | // Download file to temp location, returns full server path to temp file. |
| 1123 | 1123 | |
| 1124 | - $tmp = tempnam( '/tmp', 'FOO' ); |
|
| 1125 | - $image = wp_remote_get( $url ); |
|
| 1126 | - if ( ! empty( $image ) && isset( $image['response'] ) && isset( $image['response']['code'] ) && 200 === $image['response']['code'] ) { |
|
| 1127 | - file_put_contents( $tmp, $image['body'] ); |
|
| 1128 | - chmod( $tmp,'777' ); |
|
| 1124 | + $tmp = tempnam('/tmp', 'FOO'); |
|
| 1125 | + $image = wp_remote_get($url); |
|
| 1126 | + if (!empty($image) && isset($image['response']) && isset($image['response']['code']) && 200 === $image['response']['code']) { |
|
| 1127 | + file_put_contents($tmp, $image['body']); |
|
| 1128 | + chmod($tmp, '777'); |
|
| 1129 | 1129 | |
| 1130 | - 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 |
|
| 1131 | - $url_filename = basename( $matches[0] ); |
|
| 1132 | - $url_filename = str_replace( '%20','_',$url_filename ); |
|
| 1130 | + 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 |
|
| 1131 | + $url_filename = basename($matches[0]); |
|
| 1132 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
| 1133 | 1133 | // extract filename from url for title |
| 1134 | - $url_type = wp_check_filetype( $url_filename ); // determine file type (ext and mime/type) |
|
| 1134 | + $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
| 1135 | 1135 | |
| 1136 | 1136 | // override filename if given, reconstruct server path. |
| 1137 | - if ( ! empty( $filename ) && ' ' != $filename ) { |
|
| 1138 | - $filename = sanitize_file_name( $filename ); |
|
| 1139 | - $tmppath = pathinfo( $tmp ); |
|
| 1137 | + if (!empty($filename) && ' ' != $filename) { |
|
| 1138 | + $filename = sanitize_file_name($filename); |
|
| 1139 | + $tmppath = pathinfo($tmp); |
|
| 1140 | 1140 | |
| 1141 | 1141 | $extension = ''; |
| 1142 | - if ( isset( $tmppath['extension'] ) ) { |
|
| 1142 | + if (isset($tmppath['extension'])) { |
|
| 1143 | 1143 | $extension = $tmppath['extension']; |
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | - $new = $tmppath['dirname'] . '/' . $filename . '.' . $extension; |
|
| 1147 | - rename( $tmp, $new ); // renames temp file on server |
|
| 1148 | - $tmp = $new; // push new filename (in path) to be used in file array later |
|
| 1146 | + $new = $tmppath['dirname'].'/'.$filename.'.'.$extension; |
|
| 1147 | + rename($tmp, $new); // renames temp file on server |
|
| 1148 | + $tmp = $new; // push new filename (in path) to be used in file array later |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using). |
| 1152 | - $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 1152 | + $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 1153 | 1153 | |
| 1154 | - if ( ! empty( $filename ) && ' ' != $filename ) { |
|
| 1155 | - $file_array['name'] = $filename . '.' . $url_type['ext']; // user given filename for title, add original URL extension |
|
| 1156 | - } else { |
|
| 1157 | - $file_array['name'] = $url_filename; // just use original URL filename |
|
| 1154 | + if (!empty($filename) && ' ' != $filename) { |
|
| 1155 | + $file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension |
|
| 1156 | + }else { |
|
| 1157 | + $file_array['name'] = $url_filename; // just use original URL filename |
|
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | // set additional wp_posts columns. |
| 1161 | - if ( empty( $post_data['post_title'] ) ) { |
|
| 1161 | + if (empty($post_data['post_title'])) { |
|
| 1162 | 1162 | |
| 1163 | - $url_filename = str_replace( '%20',' ', $url_filename ); |
|
| 1163 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
| 1164 | 1164 | |
| 1165 | - $post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] ); // just use the original filename (no extension) |
|
| 1165 | + $post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension) |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | // make sure gets tied to parent. |
| 1169 | - if ( empty( $post_data['post_parent'] ) ) { |
|
| 1169 | + if (empty($post_data['post_parent'])) { |
|
| 1170 | 1170 | $post_data['post_parent'] = $post_id; |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | // do the validation and storage stuff. |
| 1174 | - $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 |
|
| 1174 | + $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 |
|
| 1175 | 1175 | |
| 1176 | 1176 | // If error storing permanently, unlink. |
| 1177 | - if ( is_wp_error( $att_id ) ) { |
|
| 1178 | - unlink( $file_array['tmp_name'] ); |
|
| 1177 | + if (is_wp_error($att_id)) { |
|
| 1178 | + unlink($file_array['tmp_name']); |
|
| 1179 | 1179 | return false; |
| 1180 | 1180 | } |
| 1181 | 1181 | } |
@@ -1202,33 +1202,33 @@ discard block |
||
| 1202 | 1202 | /** |
| 1203 | 1203 | * Formats the row for the completed list. |
| 1204 | 1204 | */ |
| 1205 | - public function format_completed_row( $response ) { |
|
| 1206 | - echo wp_kses_post( '<li class="post-' . $response . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $response ) . '">' . get_the_title( $response ) . '</a></li>' ); |
|
| 1205 | + public function format_completed_row($response) { |
|
| 1206 | + echo wp_kses_post('<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>'); |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | /** |
| 1210 | 1210 | * Formats the error. |
| 1211 | 1211 | */ |
| 1212 | - public function format_error( $response ) { |
|
| 1213 | - echo wp_kses_post( '<li class="post-error"><span class="dashicons dashicons-no"></span>' . $response . '</li>' ); |
|
| 1212 | + public function format_error($response) { |
|
| 1213 | + echo wp_kses_post('<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>'); |
|
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | 1216 | /** |
| 1217 | 1217 | * Does a multine search |
| 1218 | 1218 | */ |
| 1219 | - public function multineedle_stripos( $haystack, $needles, $offset = 0 ) { |
|
| 1219 | + public function multineedle_stripos($haystack, $needles, $offset = 0) { |
|
| 1220 | 1220 | $found = false; |
| 1221 | - $needle_count = count( $needles ); |
|
| 1221 | + $needle_count = count($needles); |
|
| 1222 | 1222 | |
| 1223 | - foreach ( $needles as $needle ) { |
|
| 1224 | - if ( false !== stripos( $haystack, $needle, $offset ) ) { |
|
| 1223 | + foreach ($needles as $needle) { |
|
| 1224 | + if (false !== stripos($haystack, $needle, $offset)) { |
|
| 1225 | 1225 | $found[] = true; |
| 1226 | 1226 | } |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | - if ( false !== $found && count( $found ) === $needle_count ) { |
|
| 1229 | + if (false !== $found && count($found) === $needle_count) { |
|
| 1230 | 1230 | return true; |
| 1231 | - } else { |
|
| 1231 | + }else { |
|
| 1232 | 1232 | return false; |
| 1233 | 1233 | } |
| 1234 | 1234 | } |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | /** |
| 1237 | 1237 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
| 1238 | 1238 | */ |
| 1239 | - public function find_current_accommodation( $post_type = 'accommodation' ) { |
|
| 1239 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 1240 | 1240 | global $wpdb; |
| 1241 | 1241 | $return = array(); |
| 1242 | 1242 | |
@@ -1255,9 +1255,9 @@ discard block |
||
| 1255 | 1255 | "); |
| 1256 | 1256 | // @codingStandardsIgnoreEnd |
| 1257 | 1257 | |
| 1258 | - if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) { |
|
| 1259 | - foreach ( $current_accommodation as $accom ) { |
|
| 1260 | - $return[ $accom->meta_value ] = $accom; |
|
| 1258 | + if (null !== $current_accommodation && !empty($current_accommodation)) { |
|
| 1259 | + foreach ($current_accommodation as $accom) { |
|
| 1260 | + $return[$accom->meta_value] = $accom; |
|
| 1261 | 1261 | } |
| 1262 | 1262 | } |
| 1263 | 1263 | |
@@ -1267,20 +1267,20 @@ discard block |
||
| 1267 | 1267 | /** |
| 1268 | 1268 | * Set the Video date |
| 1269 | 1269 | */ |
| 1270 | - public function set_video_data( $data, $id ) { |
|
| 1271 | - if ( ! empty( $data[0]['content']['youtube_videos'] ) && is_array( $data[0]['content']['youtube_videos'] ) ) { |
|
| 1270 | + public function set_video_data($data, $id) { |
|
| 1271 | + if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) { |
|
| 1272 | 1272 | $videos = false; |
| 1273 | 1273 | |
| 1274 | - foreach ( $data[0]['content']['youtube_videos'] as $video ) { |
|
| 1274 | + foreach ($data[0]['content']['youtube_videos'] as $video) { |
|
| 1275 | 1275 | $temp_video = array(); |
| 1276 | 1276 | |
| 1277 | - if ( isset( $video['label'] ) ) { |
|
| 1277 | + if (isset($video['label'])) { |
|
| 1278 | 1278 | $temp_video['title'] = $video['label']; |
| 1279 | 1279 | } |
| 1280 | - if ( isset( $video['description'] ) ) { |
|
| 1281 | - $temp_video['description'] = strip_tags( $video['description'] ); |
|
| 1280 | + if (isset($video['description'])) { |
|
| 1281 | + $temp_video['description'] = strip_tags($video['description']); |
|
| 1282 | 1282 | } |
| 1283 | - if ( isset( $video['url'] ) ) { |
|
| 1283 | + if (isset($video['url'])) { |
|
| 1284 | 1284 | $temp_video['url'] = $video['url']; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
@@ -1288,24 +1288,24 @@ discard block |
||
| 1288 | 1288 | $videos[] = $temp_video; |
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | - if ( false !== $id && '0' !== $id ) { |
|
| 1292 | - delete_post_meta( $id, 'videos' ); |
|
| 1291 | + if (false !== $id && '0' !== $id) { |
|
| 1292 | + delete_post_meta($id, 'videos'); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | - foreach ( $videos as $video ) { |
|
| 1296 | - add_post_meta( $id,'videos',$video,false ); |
|
| 1295 | + foreach ($videos as $video) { |
|
| 1296 | + add_post_meta($id, 'videos', $video, false); |
|
| 1297 | 1297 | } |
| 1298 | 1298 | } |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | - public function shuffle_assoc( &$array ) { |
|
| 1301 | + public function shuffle_assoc(&$array) { |
|
| 1302 | 1302 | $new = array(); |
| 1303 | - $keys = array_keys( $array ); |
|
| 1303 | + $keys = array_keys($array); |
|
| 1304 | 1304 | |
| 1305 | - shuffle( $keys ); |
|
| 1305 | + shuffle($keys); |
|
| 1306 | 1306 | |
| 1307 | - foreach ( $keys as $key ) { |
|
| 1308 | - $new[ $key ] = $array[ $key ]; |
|
| 1307 | + foreach ($keys as $key) { |
|
| 1308 | + $new[$key] = $array[$key]; |
|
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | 1311 | $array = $new; |
@@ -1319,29 +1319,29 @@ discard block |
||
| 1319 | 1319 | public function update_options() { |
| 1320 | 1320 | $own = ''; |
| 1321 | 1321 | $options = array(); |
| 1322 | - delete_option( 'lsx_ti_tours_api_options' ); |
|
| 1322 | + delete_option('lsx_ti_tours_api_options'); |
|
| 1323 | 1323 | |
| 1324 | - if ( isset( $_GET['own'] ) ) { |
|
| 1324 | + if (isset($_GET['own'])) { |
|
| 1325 | 1325 | $this->current_importer->url_qs .= '&own=true'; |
| 1326 | 1326 | $options[] = 'own'; |
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | - if ( isset( $_GET['type'] ) && 'allitineraries' !== $_GET['type'] ) { |
|
| 1330 | - $this->current_importer->url_qs .= '&type=' . $_GET['type']; |
|
| 1329 | + if (isset($_GET['type']) && 'allitineraries' !== $_GET['type']) { |
|
| 1330 | + $this->current_importer->url_qs .= '&type='.$_GET['type']; |
|
| 1331 | 1331 | $options[] = $_GET['type']; |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | $this->current_importer->url_qs .= '&results=2000'; |
| 1335 | 1335 | |
| 1336 | - add_option( 'lsx_ti_tours_api_options', $options ); |
|
| 1336 | + add_option('lsx_ti_tours_api_options', $options); |
|
| 1337 | 1337 | |
| 1338 | - $data = wp_remote_get( $this->current_importer->url . '/V8/List?' . $this->current_importer->url_qs ); |
|
| 1339 | - $tours = json_decode( wp_remote_retrieve_body( $data ), true ); |
|
| 1338 | + $data = wp_remote_get($this->current_importer->url.'/V8/List?'.$this->current_importer->url_qs); |
|
| 1339 | + $tours = json_decode(wp_remote_retrieve_body($data), true); |
|
| 1340 | 1340 | |
| 1341 | - if ( isset( $tours['error'] ) ) { |
|
| 1341 | + if (isset($tours['error'])) { |
|
| 1342 | 1342 | return $tours['error']; |
| 1343 | - } elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) { |
|
| 1344 | - set_transient( 'lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2 ); |
|
| 1343 | + } elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
| 1344 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
| 1345 | 1345 | return true; |
| 1346 | 1346 | } |
| 1347 | 1347 | } |
@@ -1352,12 +1352,12 @@ discard block |
||
| 1352 | 1352 | * @param boolean $wetu_id |
| 1353 | 1353 | * @return string |
| 1354 | 1354 | */ |
| 1355 | - public function get_post_id_by_key_value( $wetu_id = false ) { |
|
| 1355 | + public function get_post_id_by_key_value($wetu_id = false) { |
|
| 1356 | 1356 | global $wpdb; |
| 1357 | 1357 | $id = false; |
| 1358 | - if ( false !== $wetu_id && '' !== $wetu_id ) { |
|
| 1359 | - $result = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM `$wpdb->postmeta` WHERE `meta_key` = 'lsx_wetu_id' AND `meta_value` = '%s'", array( $wetu_id ) ) ); |
|
| 1360 | - if ( false !== $result && ! empty( $result ) ) { |
|
| 1358 | + if (false !== $wetu_id && '' !== $wetu_id) { |
|
| 1359 | + $result = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM `$wpdb->postmeta` WHERE `meta_key` = 'lsx_wetu_id' AND `meta_value` = '%s'", array($wetu_id))); |
|
| 1360 | + if (false !== $result && !empty($result)) { |
|
| 1361 | 1361 | $id = $result; |
| 1362 | 1362 | } |
| 1363 | 1363 | } |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function set_variables() { |
| 99 | 99 | parent::set_variables(); |
| 100 | - if ( false !== $this->api_key ) { |
|
| 101 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
| 100 | + if (false !== $this->api_key) { |
|
| 101 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
| 102 | 102 | $this->url_qs = ''; |
| 103 | 103 | } |
| 104 | - $tour_options = get_option( 'lsx_wetu_importer_tour_settings',false ); |
|
| 105 | - if ( false !== $tour_options ) { |
|
| 104 | + $tour_options = get_option('lsx_wetu_importer_tour_settings', false); |
|
| 105 | + if (false !== $tour_options) { |
|
| 106 | 106 | $this->tour_options = $tour_options; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | </div> |
| 127 | 127 | |
| 128 | 128 | <form method="get" action="" id="posts-filter"> |
| 129 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 129 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 130 | 130 | |
| 131 | 131 | <table class="wp-list-table widefat fixed posts"> |
| 132 | 132 | <?php $this->table_header(); ?> |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 136 | 136 | <td class="date column-date column-ref" colspan="5"> |
| 137 | 137 | <strong> |
| 138 | - <?php esc_html_e( 'Search for tours using the search form above','lsx-wetu-importer' ); ?> |
|
| 138 | + <?php esc_html_e('Search for tours using the search form above', 'lsx-wetu-importer'); ?> |
|
| 139 | 139 | </strong> |
| 140 | 140 | </td> |
| 141 | 141 | </tr> |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | </table> |
| 147 | 147 | |
| 148 | - <p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','lsx-wetu-importer' ); ?>" /> |
|
| 149 | - <input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','lsx-wetu-importer' ); ?>" /> |
|
| 148 | + <p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>" /> |
|
| 149 | + <input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>" /> |
|
| 150 | 150 | </p> |
| 151 | 151 | </form> |
| 152 | 152 | |
@@ -156,51 +156,51 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | <div class="row"> |
| 158 | 158 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 159 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
| 159 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
| 160 | 160 | <ul> |
| 161 | - <li><input class="content select-all" <?php $this->checked( $this->tour_options,'all' ); ?> type="checkbox"name="content[]" value="all" /> <?php esc_html_e( 'Select All','lsx-wetu-importer' ); ?></li> |
|
| 161 | + <li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li> |
|
| 162 | 162 | |
| 163 | - <?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_descriptions'] ) ) { ?> |
|
| 164 | - <li><input class="content" <?php $this->checked( $this->tour_options,'description' ); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li> |
|
| 163 | + <?php if (isset($this->options) && !isset($this->options['disable_tour_descriptions'])) { ?> |
|
| 164 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li> |
|
| 165 | 165 | <?php } ?> |
| 166 | 166 | |
| 167 | - <li><input class="content" <?php $this->checked( $this->tour_options,'price' ); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price','lsx-wetu-importer' ); ?></li> |
|
| 168 | - <li><input class="content" <?php $this->checked( $this->tour_options,'duration' ); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration','lsx-wetu-importer' ); ?></li> |
|
| 169 | - <li><input class="content" <?php $this->checked( $this->tour_options,'group_size' ); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e( 'Group Size','lsx-wetu-importer' ); ?></li> |
|
| 170 | - <li><input class="content" <?php $this->checked( $this->tour_options,'category' ); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category','lsx-wetu-importer' ); ?></li> |
|
| 171 | - <li><input class="content" <?php $this->checked( $this->tour_options,'tags' ); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e( 'Tags','lsx-wetu-importer' ); ?></li> |
|
| 167 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'lsx-wetu-importer'); ?></li> |
|
| 168 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'lsx-wetu-importer'); ?></li> |
|
| 169 | + <li><input class="content" <?php $this->checked($this->tour_options, 'group_size'); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e('Group Size', 'lsx-wetu-importer'); ?></li> |
|
| 170 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li> |
|
| 171 | + <li><input class="content" <?php $this->checked($this->tour_options, 'tags'); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e('Tags', 'lsx-wetu-importer'); ?></li> |
|
| 172 | 172 | |
| 173 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itineraries' ); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days','lsx-wetu-importer' ); ?></li> |
|
| 173 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'lsx-wetu-importer'); ?></li> |
|
| 174 | 174 | </ul> |
| 175 | 175 | </div> |
| 176 | 176 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 177 | - <h3><?php esc_html_e( 'Itinerary Info' ); ?></h3> |
|
| 177 | + <h3><?php esc_html_e('Itinerary Info'); ?></h3> |
|
| 178 | 178 | <ul> |
| 179 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_description' ); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li> |
|
| 180 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_included' ); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included','lsx-wetu-importer' ); ?></li> |
|
| 181 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_excluded' ); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded','lsx-wetu-importer' ); ?></li> |
|
| 179 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li> |
|
| 180 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'lsx-wetu-importer'); ?></li> |
|
| 181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'lsx-wetu-importer'); ?></li> |
|
| 182 | 182 | </ul> |
| 183 | 183 | |
| 184 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
| 184 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
| 185 | 185 | <ul> |
| 186 | - <li><input class="content" <?php $this->checked( $this->tour_options,'accommodation' ); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation','lsx-wetu-importer' ); ?></li> |
|
| 187 | - <li><input class="content" <?php $this->checked( $this->tour_options,'destination' ); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations','lsx-wetu-importer' ); ?></li> |
|
| 188 | - <li><input class="content" <?php $this->checked( $this->tour_options,'featured_image' ); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Featured Image','lsx-wetu-importer' ); ?></li> |
|
| 189 | - <li><input class="content" <?php $this->checked( $this->tour_options,'banner_image' ); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Banner Image','lsx-wetu-importer' ); ?></li> |
|
| 186 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'lsx-wetu-importer'); ?></li> |
|
| 187 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'lsx-wetu-importer'); ?></li> |
|
| 188 | + <li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Featured Image', 'lsx-wetu-importer'); ?></li> |
|
| 189 | + <li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Banner Image', 'lsx-wetu-importer'); ?></li> |
|
| 190 | 190 | </ul> |
| 191 | 191 | </div> |
| 192 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
| 192 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 193 | 193 | <div style="width:30%;display:block;float:left;"> |
| 194 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 195 | - <?php $this->team_member_checkboxes( $this->tour_options ); ?> |
|
| 194 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 195 | + <?php $this->team_member_checkboxes($this->tour_options); ?> |
|
| 196 | 196 | </div> |
| 197 | 197 | <?php } ?> |
| 198 | 198 | |
| 199 | 199 | <br clear="both" /> |
| 200 | 200 | </div> |
| 201 | 201 | |
| 202 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 203 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','lsx-wetu-importer' ); ?>" /></p> |
|
| 202 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 203 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p> |
|
| 204 | 204 | <table class="wp-list-table widefat fixed posts"> |
| 205 | 205 | <?php $this->table_header(); ?> |
| 206 | 206 | |
@@ -212,12 +212,12 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | </table> |
| 214 | 214 | |
| 215 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','lsx-wetu-importer' ); ?>" /></p> |
|
| 215 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p> |
|
| 216 | 216 | </form> |
| 217 | 217 | </div> |
| 218 | 218 | |
| 219 | 219 | <div style="display:none;" class="completed-list-wrapper"> |
| 220 | - <h3><?php esc_html_e( 'Completed', 'lsx-wetu-importer' ); ?> - <small><?php esc_html_e( 'Import your', 'lsx-wetu-importer' ); ?> <a href="<?php echo esc_attr( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=accommodation"><?php esc_html_e( 'accommodation' ); ?></a> <?php esc_html_e( 'next','lsx-wetu-importer' ); ?></small></h3> |
|
| 220 | + <h3><?php esc_html_e('Completed', 'lsx-wetu-importer'); ?> - <small><?php esc_html_e('Import your', 'lsx-wetu-importer'); ?> <a href="<?php echo esc_attr(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=accommodation"><?php esc_html_e('accommodation'); ?></a> <?php esc_html_e('next', 'lsx-wetu-importer'); ?></small></h3> |
|
| 221 | 221 | <ul> |
| 222 | 222 | </ul> |
| 223 | 223 | </div> |
@@ -231,23 +231,23 @@ discard block |
||
| 231 | 231 | * @return void |
| 232 | 232 | */ |
| 233 | 233 | public function update_options_form() { |
| 234 | - $form_options = get_option( 'lsx_ti_tours_api_options' ); |
|
| 235 | - if ( false === $form_options ) { |
|
| 236 | - $form_options = array( 'sample' ); |
|
| 234 | + $form_options = get_option('lsx_ti_tours_api_options'); |
|
| 235 | + if (false === $form_options) { |
|
| 236 | + $form_options = array('sample'); |
|
| 237 | 237 | } |
| 238 | 238 | ?> |
| 239 | 239 | <form method="get" class="tour-refresh-form"> |
| 240 | - <input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" /> |
|
| 240 | + <input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" /> |
|
| 241 | 241 | <input type="hidden" name="tab" value="tour" /> |
| 242 | 242 | <input type="hidden" name="refresh_tours" value="true" /> |
| 243 | 243 | <input class="content" type="hidden" name="own" value="true" /> |
| 244 | 244 | |
| 245 | 245 | <select name="type"> |
| 246 | - <option <?php if ( in_array( 'allitineraries', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?> value="allitineraries"><?php esc_html_e( 'All Itineraries','lsx-wetu-importer' ); ?></option> |
|
| 247 | - <option <?php if ( in_array( 'sample', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="sample"><?php esc_html_e( 'Sample','lsx-wetu-importer' ); ?></option> |
|
| 248 | - <option <?php if ( in_array( 'personal', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="personal"><?php esc_html_e( 'Personal','lsx-wetu-importer' ); ?></option> |
|
| 246 | + <option <?php if (in_array('allitineraries', $form_options)) { echo esc_attr('selected="selected"'); } ?> value="allitineraries"><?php esc_html_e('All Itineraries', 'lsx-wetu-importer'); ?></option> |
|
| 247 | + <option <?php if (in_array('sample', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="sample"><?php esc_html_e('Sample', 'lsx-wetu-importer'); ?></option> |
|
| 248 | + <option <?php if (in_array('personal', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="personal"><?php esc_html_e('Personal', 'lsx-wetu-importer'); ?></option> |
|
| 249 | 249 | </select> |
| 250 | - <input class="button submit" type="submit" value="<?php esc_attr_e( 'Refresh', 'lsx-wetu-importer' ); ?>" /> |
|
| 250 | + <input class="button submit" type="submit" value="<?php esc_attr_e('Refresh', 'lsx-wetu-importer'); ?>" /> |
|
| 251 | 251 | </form> |
| 252 | 252 | <?php |
| 253 | 253 | } |
@@ -272,9 +272,9 @@ discard block |
||
| 272 | 272 | LIMIT 0,500 |
| 273 | 273 | "); |
| 274 | 274 | |
| 275 | - if ( null !== $current_tours && ! empty( $current_tours ) ) { |
|
| 276 | - foreach ( $current_tours as $tour ) { |
|
| 277 | - $return[ $tour->meta_value ] = $tour; |
|
| 275 | + if (null !== $current_tours && !empty($current_tours)) { |
|
| 276 | + foreach ($current_tours as $tour) { |
|
| 277 | + $return[$tour->meta_value] = $tour; |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
@@ -286,45 +286,45 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | public function process_ajax_search() { |
| 288 | 288 | $return = false; |
| 289 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 289 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 290 | 290 | |
| 291 | - if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) { |
|
| 292 | - $tours = get_transient( 'lsx_ti_tours' ); |
|
| 291 | + if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
| 292 | + $tours = get_transient('lsx_ti_tours'); |
|
| 293 | 293 | |
| 294 | - if ( false !== $tours ) { |
|
| 294 | + if (false !== $tours) { |
|
| 295 | 295 | $searched_items = false; |
| 296 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 297 | - $keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) ); |
|
| 298 | - } else { |
|
| 299 | - $keyphrases = array( 0 ); |
|
| 296 | + if (isset($_POST['keyword'])) { |
|
| 297 | + $keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword'])); |
|
| 298 | + }else { |
|
| 299 | + $keyphrases = array(0); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if ( ! is_array( $keyphrases ) ) { |
|
| 303 | - $keyphrases = array( $keyphrases ); |
|
| 302 | + if (!is_array($keyphrases)) { |
|
| 303 | + $keyphrases = array($keyphrases); |
|
| 304 | 304 | } |
| 305 | - foreach ( $keyphrases as &$keyword ) { |
|
| 306 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 305 | + foreach ($keyphrases as &$keyword) { |
|
| 306 | + $keyword = ltrim(rtrim($keyword)); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $post_status = false; |
| 310 | - if ( in_array( 'publish',$keyphrases ) ) { |
|
| 310 | + if (in_array('publish', $keyphrases)) { |
|
| 311 | 311 | $post_status = 'publish'; |
| 312 | 312 | } |
| 313 | - if ( in_array( 'pending',$keyphrases ) ) { |
|
| 313 | + if (in_array('pending', $keyphrases)) { |
|
| 314 | 314 | $post_status = 'pending'; |
| 315 | 315 | } |
| 316 | - if ( in_array( 'draft',$keyphrases ) ) { |
|
| 316 | + if (in_array('draft', $keyphrases)) { |
|
| 317 | 317 | $post_status = 'draft'; |
| 318 | 318 | } |
| 319 | - if ( in_array( 'import',$keyphrases ) ) { |
|
| 319 | + if (in_array('import', $keyphrases)) { |
|
| 320 | 320 | $post_status = 'import'; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( ! empty( $tours ) ) { |
|
| 323 | + if (!empty($tours)) { |
|
| 324 | 324 | $current_tours = $this->find_current_tours(); |
| 325 | 325 | |
| 326 | - foreach ( $tours as $row_key => $row ) { |
|
| 327 | - if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) { |
|
| 326 | + foreach ($tours as $row_key => $row) { |
|
| 327 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
| 328 | 328 | continue; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -335,60 +335,60 @@ discard block |
||
| 335 | 335 | //If this is a current tour, add its ID to the row. |
| 336 | 336 | $row['post_id'] = 0; |
| 337 | 337 | |
| 338 | - if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) { |
|
| 339 | - $row['post_id'] = $current_tours[ $row['identifier'] ]->post_id; |
|
| 338 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
| 339 | + $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | //If we are searching for |
| 343 | - if ( false !== $post_status ) { |
|
| 344 | - if ( 'import' === $post_status ) { |
|
| 343 | + if (false !== $post_status) { |
|
| 344 | + if ('import' === $post_status) { |
|
| 345 | 345 | |
| 346 | - if ( 0 !== $row['post_id'] ) { |
|
| 346 | + if (0 !== $row['post_id']) { |
|
| 347 | 347 | continue; |
| 348 | - } else { |
|
| 349 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 348 | + }else { |
|
| 349 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 350 | 350 | } |
| 351 | - } else { |
|
| 352 | - if ( 0 === $row['post_id'] ) { |
|
| 351 | + }else { |
|
| 352 | + if (0 === $row['post_id']) { |
|
| 353 | 353 | continue; |
| 354 | - } else { |
|
| 355 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 354 | + }else { |
|
| 355 | + $current_status = get_post_status($row['post_id']); |
|
| 356 | 356 | |
| 357 | - if ( $current_status !== $post_status ) { |
|
| 357 | + if ($current_status !== $post_status) { |
|
| 358 | 358 | continue; |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 362 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 363 | 363 | } |
| 364 | - } else { |
|
| 364 | + }else { |
|
| 365 | 365 | // Search through each keyword. |
| 366 | - foreach ( $keyphrases as $keyphrase ) { |
|
| 366 | + foreach ($keyphrases as $keyphrase) { |
|
| 367 | 367 | |
| 368 | 368 | // Make sure the keyphrase is turned into an array. |
| 369 | - $keywords = explode( ' ',$keyphrase ); |
|
| 370 | - if ( ! is_array( $keywords ) ) { |
|
| 371 | - $keywords = array( $keywords ); |
|
| 369 | + $keywords = explode(' ', $keyphrase); |
|
| 370 | + if (!is_array($keywords)) { |
|
| 371 | + $keywords = array($keywords); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) { |
|
| 375 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 376 | - } else if ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) { |
|
| 377 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 378 | - } else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) { |
|
| 379 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 374 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
| 375 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 376 | + }else if ($this->multineedle_stripos(ltrim(rtrim($row['reference_number'])), $keywords) !== false) { |
|
| 377 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 378 | + }else if ($this->multineedle_stripos(ltrim(rtrim($row['identifier_key'])), $keywords) !== false) { |
|
| 379 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - if ( false !== $searched_items ) { |
|
| 387 | - ksort( $searched_items ); |
|
| 388 | - $return = implode( $searched_items ); |
|
| 386 | + if (false !== $searched_items) { |
|
| 387 | + ksort($searched_items); |
|
| 388 | + $return = implode($searched_items); |
|
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | - print_r( $return ); |
|
| 391 | + print_r($return); |
|
| 392 | 392 | die(); |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -396,31 +396,31 @@ discard block |
||
| 396 | 396 | /** |
| 397 | 397 | * Formats the row for output on the screen. |
| 398 | 398 | */ |
| 399 | - public function format_row( $row = false ) { |
|
| 400 | - if ( false !== $row ) { |
|
| 399 | + public function format_row($row = false) { |
|
| 400 | + if (false !== $row) { |
|
| 401 | 401 | $status = 'import'; |
| 402 | 402 | |
| 403 | - if ( 0 !== $row['post_id'] ) { |
|
| 404 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
| 403 | + if (0 !== $row['post_id']) { |
|
| 404 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $row_html = ' |
| 408 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
| 408 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
| 409 | 409 | <th class="check-column" scope="row"> |
| 410 | - <label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
| 411 | - <input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '"> |
|
| 410 | + <label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
| 411 | + <input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'"> |
|
| 412 | 412 | </th> |
| 413 | 413 | <td class="post-title page-title column-title"> |
| 414 | - ' . $row['name'] . ' |
|
| 414 | + ' . $row['name'].' |
|
| 415 | 415 | </td> |
| 416 | 416 | <td class="date column-date"> |
| 417 | - ' . $row['reference_number'] . ' |
|
| 417 | + ' . $row['reference_number'].' |
|
| 418 | 418 | </td> |
| 419 | 419 | <td class="date column-date"> |
| 420 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 420 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 421 | 421 | </td> |
| 422 | 422 | <td class="ssid column-ssid"> |
| 423 | - ' . $row['identifier'] . ' |
|
| 423 | + ' . $row['identifier'].' |
|
| 424 | 424 | </td> |
| 425 | 425 | </tr>'; |
| 426 | 426 | return $row_html; |
@@ -430,38 +430,38 @@ discard block |
||
| 430 | 430 | /** |
| 431 | 431 | * Connect to wetu |
| 432 | 432 | */ |
| 433 | - public function process_ajax_import( $force = false ) { |
|
| 433 | + public function process_ajax_import($force = false) { |
|
| 434 | 434 | $return = false; |
| 435 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 436 | - if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) { |
|
| 435 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 436 | + if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
| 437 | 437 | |
| 438 | - $wetu_id = sanitize_text_field( $_POST['wetu_id'] ); |
|
| 439 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 440 | - $post_id = sanitize_text_field( $_POST['post_id'] ); |
|
| 441 | - } else { |
|
| 438 | + $wetu_id = sanitize_text_field($_POST['wetu_id']); |
|
| 439 | + if (isset($_POST['post_id'])) { |
|
| 440 | + $post_id = sanitize_text_field($_POST['post_id']); |
|
| 441 | + }else { |
|
| 442 | 442 | $post_id = 0; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - delete_option( 'lsx_wetu_importer_tour_settings' ); |
|
| 445 | + delete_option('lsx_wetu_importer_tour_settings'); |
|
| 446 | 446 | |
| 447 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 448 | - $content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) ); |
|
| 449 | - add_option( 'lsx_wetu_importer_tour_settings',$content ); |
|
| 450 | - } else { |
|
| 447 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 448 | + $content = array_map('sanitize_text_field', wp_unslash($_POST['content'])); |
|
| 449 | + add_option('lsx_wetu_importer_tour_settings', $content); |
|
| 450 | + }else { |
|
| 451 | 451 | $content = false; |
| 452 | 452 | } |
| 453 | - $jdata = wp_remote_get( 'https://wetu.com/API/Itinerary/V8/Get?id=' . $wetu_id ); |
|
| 453 | + $jdata = wp_remote_get('https://wetu.com/API/Itinerary/V8/Get?id='.$wetu_id); |
|
| 454 | 454 | |
| 455 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 456 | - $jdata = json_decode( $jdata['body'], true ); |
|
| 457 | - $return = $this->import_row( $jdata, $wetu_id, $post_id, $content ); |
|
| 458 | - $this->format_completed_row( $return ); |
|
| 455 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 456 | + $jdata = json_decode($jdata['body'], true); |
|
| 457 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
| 458 | + $this->format_completed_row($return); |
|
| 459 | 459 | $this->save_queue(); |
| 460 | 460 | $this->cleanup_posts(); |
| 461 | - $this->attach_destination_images( $content ); |
|
| 462 | - $this->clean_attached_destinations( $return ); |
|
| 463 | - } else { |
|
| 464 | - $this->format_error( esc_html__( 'There was a problem importing your tour, please contact support.', 'lsx-wetu-importer' ) ); |
|
| 461 | + $this->attach_destination_images($content); |
|
| 462 | + $this->clean_attached_destinations($return); |
|
| 463 | + }else { |
|
| 464 | + $this->format_error(esc_html__('There was a problem importing your tour, please contact support.', 'lsx-wetu-importer')); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | } |
@@ -472,13 +472,13 @@ discard block |
||
| 472 | 472 | * @param $id string |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function clean_attached_destinations( $id ) { |
|
| 476 | - $current_connections = get_post_meta( $id, 'destination_to_tour', false ); |
|
| 477 | - delete_post_meta( $id,'destination_to_tour' ); |
|
| 478 | - $current_connections = array_unique( $current_connections ); |
|
| 475 | + public function clean_attached_destinations($id) { |
|
| 476 | + $current_connections = get_post_meta($id, 'destination_to_tour', false); |
|
| 477 | + delete_post_meta($id, 'destination_to_tour'); |
|
| 478 | + $current_connections = array_unique($current_connections); |
|
| 479 | 479 | |
| 480 | - foreach ( $current_connections as $connection ) { |
|
| 481 | - add_post_meta( $id, 'destination_to_tour',$connection, false ); |
|
| 480 | + foreach ($current_connections as $connection) { |
|
| 481 | + add_post_meta($id, 'destination_to_tour', $connection, false); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
@@ -488,12 +488,12 @@ discard block |
||
| 488 | 488 | * @param $data array |
| 489 | 489 | * @param $wetu_id string |
| 490 | 490 | */ |
| 491 | - public function import_row( $data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false ) { |
|
| 491 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false) { |
|
| 492 | 492 | $post_name = ''; |
| 493 | 493 | $data_post_content = ''; |
| 494 | 494 | $data_post_excerpt = ''; |
| 495 | 495 | |
| 496 | - $current_post = get_post( $id ); |
|
| 496 | + $current_post = get_post($id); |
|
| 497 | 497 | |
| 498 | 498 | $post = array( |
| 499 | 499 | 'post_type' => 'tour', |
@@ -501,64 +501,64 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | $content_used_general_description = false; |
| 503 | 503 | |
| 504 | - if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
| 504 | + if (!empty($importable_content) && in_array('description', $importable_content)) { |
|
| 505 | 505 | $data_post_content = $current_post->post_content; |
| 506 | - if ( isset( $data['summary'] ) && ! empty( $data['summary'] ) ) { |
|
| 506 | + if (isset($data['summary']) && !empty($data['summary'])) { |
|
| 507 | 507 | $data_post_content = $data['summary']; |
| 508 | 508 | } |
| 509 | 509 | $post['post_content'] = $data_post_content; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | // Create or update the post. |
| 513 | - if ( false !== $id && '0' !== $id ) { |
|
| 513 | + if (false !== $id && '0' !== $id) { |
|
| 514 | 514 | $post['ID'] = $id; |
| 515 | 515 | $post['post_status'] = 'publish'; |
| 516 | - $id = wp_update_post( $post ); |
|
| 517 | - } else { |
|
| 516 | + $id = wp_update_post($post); |
|
| 517 | + }else { |
|
| 518 | 518 | // Set the name. |
| 519 | - if ( isset( $data['name'] ) ) { |
|
| 520 | - $post_name = wp_unique_post_slug( sanitize_title( $data['name'] ), $id, 'draft', 'tour', 0 ); |
|
| 519 | + if (isset($data['name'])) { |
|
| 520 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - if ( ! isset( $post['post_content'] ) ) { |
|
| 523 | + if (!isset($post['post_content'])) { |
|
| 524 | 524 | $post['post_content'] = ' '; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | $post['post_name'] = $post_name; |
| 528 | 528 | $post['post_title'] = $data['name']; |
| 529 | 529 | $post['post_status'] = 'publish'; |
| 530 | - $id = wp_insert_post( $post ); |
|
| 530 | + $id = wp_insert_post($post); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | // Set reference number. |
| 534 | - $this->set_reference_number( $data, $id ); |
|
| 534 | + $this->set_reference_number($data, $id); |
|
| 535 | 535 | |
| 536 | 536 | // Set the price. |
| 537 | - if ( false !== $importable_content && in_array( 'price', $importable_content ) ) { |
|
| 538 | - $this->set_price( $data, $id ); |
|
| 537 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
| 538 | + $this->set_price($data, $id); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | // Set the Duration. |
| 542 | - if ( false !== $importable_content && in_array( 'duration', $importable_content ) ) { |
|
| 543 | - $this->set_duration( $data, $id ); |
|
| 542 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
| 543 | + $this->set_duration($data, $id); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | // Set the Group Size. |
| 547 | - if ( false !== $importable_content && in_array( 'group_size', $importable_content ) ) { |
|
| 548 | - $this->set_group_size( $data, $id ); |
|
| 547 | + if (false !== $importable_content && in_array('group_size', $importable_content)) { |
|
| 548 | + $this->set_group_size($data, $id); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // Set the Group Size. |
| 552 | - if ( false !== $importable_content && in_array( 'tags', $importable_content ) ) { |
|
| 553 | - $this->set_travel_styles( $id, $data ); |
|
| 552 | + if (false !== $importable_content && in_array('tags', $importable_content)) { |
|
| 553 | + $this->set_travel_styles($id, $data); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - if ( false !== $importable_content && in_array( 'itineraries', $importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) { |
|
| 557 | - $this->process_itineraries( $data, $id, $importable_content ); |
|
| 556 | + if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
| 557 | + $this->process_itineraries($data, $id, $importable_content); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - if ( in_array( 'map', $importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) { |
|
| 561 | - $this->set_map_data( $data, $id ); |
|
| 560 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
| 561 | + $this->set_map_data($data, $id); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | return $id; |
@@ -567,195 +567,195 @@ discard block |
||
| 567 | 567 | /** |
| 568 | 568 | * A loop which runs through each leg on the tour. |
| 569 | 569 | */ |
| 570 | - public function process_itineraries( $data, $id, $importable_content ) { |
|
| 570 | + public function process_itineraries($data, $id, $importable_content) { |
|
| 571 | 571 | $day_counter = 1; |
| 572 | 572 | $leg_counter = 0; |
| 573 | 573 | |
| 574 | - delete_post_meta( $id, 'itinerary' ); |
|
| 574 | + delete_post_meta($id, 'itinerary'); |
|
| 575 | 575 | |
| 576 | - if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) { |
|
| 577 | - delete_post_meta( $id, 'accommodation_to_tour' ); |
|
| 576 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 577 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
| 578 | 578 | } |
| 579 | - if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) { |
|
| 580 | - delete_post_meta( $id, 'departs_from' ); |
|
| 581 | - delete_post_meta( $id, 'ends_in' ); |
|
| 579 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 580 | + delete_post_meta($id, 'departs_from'); |
|
| 581 | + delete_post_meta($id, 'ends_in'); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | $departs_from = false; |
| 585 | 585 | $ends_in = false; |
| 586 | 586 | |
| 587 | - foreach ( $data['legs'] as $leg ) { |
|
| 587 | + foreach ($data['legs'] as $leg) { |
|
| 588 | 588 | // Itinerary Accommodation. |
| 589 | 589 | $current_accommodation = false; |
| 590 | - if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) { |
|
| 591 | - $current_accommodation = $this->set_accommodation( $leg, $id ); |
|
| 590 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 591 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | // Itinerary Destination. |
| 595 | 595 | $current_destination = false; |
| 596 | - if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) { |
|
| 597 | - $current_destination = $this->set_destination( $leg, $id, $leg_counter ); |
|
| 596 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 597 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | // If the Nights are the same mount of days in the array, then it isnt "By Destination". |
| 601 | - if ( ( ( 1 <= (int) $leg['nights'] && isset( $leg['periods'] ) ) ) || 0 === $leg['itinerary_leg_id'] ) { |
|
| 602 | - foreach ( $leg['periods'] as $day ) { |
|
| 601 | + if (((1 <= (int) $leg['nights'] && isset($leg['periods']))) || 0 === $leg['itinerary_leg_id']) { |
|
| 602 | + foreach ($leg['periods'] as $day) { |
|
| 603 | 603 | $current_day = array(); |
| 604 | - $current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter; |
|
| 604 | + $current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter; |
|
| 605 | 605 | |
| 606 | 606 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
| 607 | 607 | |
| 608 | 608 | // Description. |
| 609 | - if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $day['notes'] ) ) { |
|
| 609 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
| 610 | 610 | $current_day['description'] = $day['notes']; |
| 611 | - } else { |
|
| 611 | + }else { |
|
| 612 | 612 | $current_day['description'] = ''; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // Itinerary Gallery. |
| 616 | - if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $day['images'] ) ) { |
|
| 616 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
| 617 | 617 | $current_day['featured_image'] = ''; |
| 618 | - } else { |
|
| 618 | + }else { |
|
| 619 | 619 | $current_day['featured_image'] = ''; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | // Accommodation. |
| 623 | - if ( false !== $current_accommodation ) { |
|
| 624 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 625 | - } else { |
|
| 623 | + if (false !== $current_accommodation) { |
|
| 624 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 625 | + }else { |
|
| 626 | 626 | $current_day['accommodation_to_tour'] = array(); |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | // Destination. |
| 630 | - if ( false !== $current_destination ) { |
|
| 631 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 632 | - } else { |
|
| 630 | + if (false !== $current_destination) { |
|
| 631 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 632 | + }else { |
|
| 633 | 633 | $current_day['destination_to_tour'] = array(); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // Included. |
| 637 | - if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) { |
|
| 637 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
| 638 | 638 | $current_day['included'] = $day['included']; |
| 639 | - } else { |
|
| 639 | + }else { |
|
| 640 | 640 | $current_day['included'] = ''; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | // Excluded. |
| 644 | - if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) { |
|
| 644 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
| 645 | 645 | $current_day['excluded'] = $day['excluded']; |
| 646 | - } else { |
|
| 646 | + }else { |
|
| 647 | 647 | $current_day['excluded'] = ''; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 650 | + $this->set_itinerary_day($current_day, $id); |
|
| 651 | 651 | $day_counter++; |
| 652 | 652 | } |
| 653 | - } else { |
|
| 653 | + }else { |
|
| 654 | 654 | // This is for the by destination. |
| 655 | 655 | |
| 656 | 656 | $current_day = array(); |
| 657 | 657 | $next_day_count = $day_counter + (int) $leg['nights']; |
| 658 | 658 | $day_count_label = $next_day_count - 1; |
| 659 | 659 | |
| 660 | - $current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter; |
|
| 660 | + $current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter; |
|
| 661 | 661 | |
| 662 | - if ( 0 !== (int) $leg['nights'] ) { |
|
| 663 | - $current_day['title'] .= ' - ' . $day_count_label; |
|
| 662 | + if (0 !== (int) $leg['nights']) { |
|
| 663 | + $current_day['title'] .= ' - '.$day_count_label; |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | // Description. |
| 667 | - if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $leg['notes'] ) ) { |
|
| 667 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) { |
|
| 668 | 668 | $current_day['description'] = $leg['notes']; |
| 669 | - } else { |
|
| 669 | + }else { |
|
| 670 | 670 | $current_day['description'] = ''; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | // Itinerary Gallery. |
| 674 | - if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $leg['images'] ) ) { |
|
| 674 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) { |
|
| 675 | 675 | $current_day['featured_image'] = ''; |
| 676 | - } else { |
|
| 676 | + }else { |
|
| 677 | 677 | $current_day['featured_image'] = ''; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | // Accommodation. |
| 681 | - if ( false !== $current_accommodation ) { |
|
| 682 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 683 | - } else { |
|
| 681 | + if (false !== $current_accommodation) { |
|
| 682 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 683 | + }else { |
|
| 684 | 684 | $current_day['accommodation_to_tour'] = array(); |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | // Destination. |
| 688 | - if ( false !== $current_destination ) { |
|
| 689 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 690 | - } else { |
|
| 688 | + if (false !== $current_destination) { |
|
| 689 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 690 | + }else { |
|
| 691 | 691 | $current_day['destination_to_tour'] = array(); |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | // Included. |
| 695 | - if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) { |
|
| 695 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) { |
|
| 696 | 696 | $current_day['included'] = $leg['included']; |
| 697 | - } else { |
|
| 697 | + }else { |
|
| 698 | 698 | $current_day['included'] = ''; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | // Excluded. |
| 702 | - if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) { |
|
| 702 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) { |
|
| 703 | 703 | $current_day['excluded'] = $leg['excluded']; |
| 704 | - } else { |
|
| 704 | + }else { |
|
| 705 | 705 | $current_day['excluded'] = ''; |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 708 | + $this->set_itinerary_day($current_day, $id); |
|
| 709 | 709 | $day_counter = $next_day_count; |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | // If we are in the first leg, and the destination was attached then save it as the departure field. |
| 713 | - if ( 0 === $leg_counter && false !== $current_destination ) { |
|
| 713 | + if (0 === $leg_counter && false !== $current_destination) { |
|
| 714 | 714 | $departs_from = $current_destination; |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // If its the last leg then save it as the ends in. |
| 718 | - if ( ( count( $data['legs'] ) - 2 ) === $leg_counter && false !== $current_destination ) { |
|
| 718 | + if ((count($data['legs']) - 2) === $leg_counter && false !== $current_destination) { |
|
| 719 | 719 | $ends_in = $current_destination; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | $leg_counter++; |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - if ( false !== $departs_from ) { |
|
| 726 | - add_post_meta( $id, 'departs_from', $departs_from, true ); |
|
| 725 | + if (false !== $departs_from) { |
|
| 726 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
| 727 | 727 | } |
| 728 | - if ( false !== $ends_in ) { |
|
| 729 | - add_post_meta( $id, 'ends_in', $ends_in, true ); |
|
| 728 | + if (false !== $ends_in) { |
|
| 729 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
| 730 | 730 | } |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
| 734 | 734 | * Run through your routes and save the points as a KML file. |
| 735 | 735 | */ |
| 736 | - public function set_map_data( $data, $id, $zoom = 9 ) { |
|
| 737 | - if ( ! empty( $data['routes'] ) ) { |
|
| 738 | - delete_post_meta( $id,'wetu_map_points' ); |
|
| 736 | + public function set_map_data($data, $id, $zoom = 9) { |
|
| 737 | + if (!empty($data['routes'])) { |
|
| 738 | + delete_post_meta($id, 'wetu_map_points'); |
|
| 739 | 739 | |
| 740 | 740 | $points = array(); |
| 741 | 741 | |
| 742 | - foreach ( $data['routes'] as $route ) { |
|
| 742 | + foreach ($data['routes'] as $route) { |
|
| 743 | 743 | |
| 744 | - if ( isset( $route['points'] ) && '' !== $route['points'] ) { |
|
| 744 | + if (isset($route['points']) && '' !== $route['points']) { |
|
| 745 | 745 | |
| 746 | - $temp_points = explode( ';',$route['points'] ); |
|
| 747 | - $point_counter = count( $temp_points ); |
|
| 746 | + $temp_points = explode(';', $route['points']); |
|
| 747 | + $point_counter = count($temp_points); |
|
| 748 | 748 | |
| 749 | - for ( $x = 0; $x <= $point_counter; $x++ ) { |
|
| 749 | + for ($x = 0; $x <= $point_counter; $x++) { |
|
| 750 | 750 | $y = $x + 1; |
| 751 | - $points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ]; |
|
| 751 | + $points[] = $temp_points[$x].','.$temp_points[$y]; |
|
| 752 | 752 | $x++; |
| 753 | 753 | } |
| 754 | 754 | } |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - if ( ! empty( $points ) ) { |
|
| 758 | - $this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true ); |
|
| 757 | + if (!empty($points)) { |
|
| 758 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | |
@@ -766,64 +766,64 @@ discard block |
||
| 766 | 766 | /** |
| 767 | 767 | * Set the Itinerary Day. |
| 768 | 768 | */ |
| 769 | - public function set_itinerary_day( $day, $id ) { |
|
| 770 | - $this->save_custom_field( $day, 'itinerary', $id, false, false ); |
|
| 769 | + public function set_itinerary_day($day, $id) { |
|
| 770 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
| 774 | 774 | * Set the ref number |
| 775 | 775 | */ |
| 776 | - public function set_reference_number( $data, $id ) { |
|
| 777 | - if ( isset( $data['reference_number'] ) && '' !== $data['reference_number'] ) { |
|
| 778 | - $this->save_custom_field( $data['reference_number'], 'lsx_wetu_ref', $id ); |
|
| 776 | + public function set_reference_number($data, $id) { |
|
| 777 | + if (isset($data['reference_number']) && '' !== $data['reference_number']) { |
|
| 778 | + $this->save_custom_field($data['reference_number'], 'lsx_wetu_ref', $id); |
|
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | 783 | * Set the price. |
| 784 | 784 | */ |
| 785 | - public function set_price( $data, $id ) { |
|
| 785 | + public function set_price($data, $id) { |
|
| 786 | 786 | // Price. |
| 787 | - if ( isset( $data['price'] ) && '' !== $data['price'] ) { |
|
| 787 | + if (isset($data['price']) && '' !== $data['price']) { |
|
| 788 | 788 | $price = $data['price']; |
| 789 | - if ( false === apply_filters( 'lsx_wetu_importer_disable_tour_price_filter', false ) ) { |
|
| 790 | - $price = preg_replace( '/[^0-9,.]/', '', $price ); |
|
| 789 | + if (false === apply_filters('lsx_wetu_importer_disable_tour_price_filter', false)) { |
|
| 790 | + $price = preg_replace('/[^0-9,.]/', '', $price); |
|
| 791 | 791 | } |
| 792 | - $meta_key = apply_filters( 'lsx_wetu_importer_price_meta_key', 'price' ); |
|
| 793 | - $this->save_custom_field( $price, $meta_key, $id ); |
|
| 792 | + $meta_key = apply_filters('lsx_wetu_importer_price_meta_key', 'price'); |
|
| 793 | + $this->save_custom_field($price, $meta_key, $id); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | // Price includes. |
| 797 | - if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) { |
|
| 798 | - $meta_key = apply_filters( 'lsx_wetu_importer_included_meta_key', 'included' ); |
|
| 799 | - $this->save_custom_field( $data['price_includes'], $meta_key, $id ); |
|
| 797 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
| 798 | + $meta_key = apply_filters('lsx_wetu_importer_included_meta_key', 'included'); |
|
| 799 | + $this->save_custom_field($data['price_includes'], $meta_key, $id); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | // Price Excludes. |
| 803 | - if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) { |
|
| 804 | - $meta_key = apply_filters( 'lsx_wetu_importer_not_included_meta_key', 'not_included' ); |
|
| 805 | - $this->save_custom_field( $data['price_excludes'], $meta_key, $id ); |
|
| 803 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
| 804 | + $meta_key = apply_filters('lsx_wetu_importer_not_included_meta_key', 'not_included'); |
|
| 805 | + $this->save_custom_field($data['price_excludes'], $meta_key, $id); |
|
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | /** |
| 810 | 810 | * Set the duration. |
| 811 | 811 | */ |
| 812 | - public function set_duration( $data, $id ) { |
|
| 813 | - if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) { |
|
| 812 | + public function set_duration($data, $id) { |
|
| 813 | + if (isset($data['days']) && !empty($data['days'])) { |
|
| 814 | 814 | $price = $data['days']; |
| 815 | - $price = preg_replace( '/[^0-9,.]/', '', $price ); |
|
| 816 | - $this->save_custom_field( $price, 'duration', $id ); |
|
| 815 | + $price = preg_replace('/[^0-9,.]/', '', $price); |
|
| 816 | + $this->save_custom_field($price, 'duration', $id); |
|
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
| 821 | 821 | * Set the group size |
| 822 | 822 | */ |
| 823 | - public function set_group_size( $data, $id ) { |
|
| 824 | - if ( isset( $data['group_size'] ) && ! empty( $data['group_size'] ) ) { |
|
| 823 | + public function set_group_size($data, $id) { |
|
| 824 | + if (isset($data['group_size']) && !empty($data['group_size'])) { |
|
| 825 | 825 | $group_size = $data['group_size']; |
| 826 | - $this->save_custom_field( $group_size,'group_size',$id ); |
|
| 826 | + $this->save_custom_field($group_size, 'group_size', $id); |
|
| 827 | 827 | } |
| 828 | 828 | } |
| 829 | 829 | |
@@ -834,10 +834,10 @@ discard block |
||
| 834 | 834 | * @param array $travel_styles |
| 835 | 835 | * @return void |
| 836 | 836 | */ |
| 837 | - public function set_travel_styles( $id, $data ) { |
|
| 838 | - if ( isset( $data['tags'] ) ) { |
|
| 839 | - foreach ( $data['tags'] as $tag ) { |
|
| 840 | - $this->set_term( $id, $tag, 'travel-style' ); |
|
| 837 | + public function set_travel_styles($id, $data) { |
|
| 838 | + if (isset($data['tags'])) { |
|
| 839 | + foreach ($data['tags'] as $tag) { |
|
| 840 | + $this->set_term($id, $tag, 'travel-style'); |
|
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | } |
@@ -845,27 +845,27 @@ discard block |
||
| 845 | 845 | /** |
| 846 | 846 | * Connects the Accommodation if its available |
| 847 | 847 | */ |
| 848 | - public function set_accommodation( $day, $id ) { |
|
| 848 | + public function set_accommodation($day, $id) { |
|
| 849 | 849 | $ac_id = false; |
| 850 | 850 | $this->current_accommodation = $this->find_current_accommodation(); |
| 851 | 851 | |
| 852 | - if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) { |
|
| 853 | - if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) { |
|
| 854 | - $ac_id = $this->current_accommodation[ $day['content_entity_id'] ]; |
|
| 855 | - } else { |
|
| 852 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
| 853 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
| 854 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
| 855 | + }else { |
|
| 856 | 856 | $ac_id = wp_insert_post(array( |
| 857 | 857 | 'post_type' => 'accommodation', |
| 858 | 858 | 'post_status' => 'draft', |
| 859 | 859 | 'post_title' => $day['content_entity_id'], |
| 860 | 860 | )); |
| 861 | 861 | |
| 862 | - $this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id ); |
|
| 862 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - if ( '' !== $ac_id && false !== $ac_id ) { |
|
| 866 | - $this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false ); |
|
| 867 | - $this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false ); |
|
| 868 | - $this->queue_item( $ac_id ); |
|
| 865 | + if ('' !== $ac_id && false !== $ac_id) { |
|
| 866 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
| 867 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
| 868 | + $this->queue_item($ac_id); |
|
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | return $ac_id; |
@@ -877,14 +877,14 @@ discard block |
||
| 877 | 877 | * @param $post_type string |
| 878 | 878 | * @return boolean / array |
| 879 | 879 | */ |
| 880 | - public function find_current_accommodation( $post_type = 'accommodation' ) { |
|
| 880 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 881 | 881 | global $wpdb; |
| 882 | - $accommodation = parent::find_current_accommodation( $post_type ); |
|
| 882 | + $accommodation = parent::find_current_accommodation($post_type); |
|
| 883 | 883 | $return = false; |
| 884 | 884 | |
| 885 | - if ( ! empty( $accommodation ) ) { |
|
| 886 | - foreach ( $accommodation as $key => $acc ) { |
|
| 887 | - $return[ $acc->meta_value ] = $acc->post_id; |
|
| 885 | + if (!empty($accommodation)) { |
|
| 886 | + foreach ($accommodation as $key => $acc) { |
|
| 887 | + $return[$acc->meta_value] = $acc->post_id; |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | * @return boolean / array |
| 897 | 897 | */ |
| 898 | 898 | public function find_current_destinations() { |
| 899 | - return $this->find_current_accommodation( 'destination' ); |
|
| 899 | + return $this->find_current_accommodation('destination'); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -906,44 +906,44 @@ discard block |
||
| 906 | 906 | * @param $id string |
| 907 | 907 | * @return boolean / string |
| 908 | 908 | */ |
| 909 | - public function set_destination( $day, $id, $leg_counter ) { |
|
| 909 | + public function set_destination($day, $id, $leg_counter) { |
|
| 910 | 910 | $dest_id = false; |
| 911 | 911 | $country_id = false; |
| 912 | 912 | |
| 913 | 913 | $this->current_destinations = $this->find_current_destinations(); |
| 914 | 914 | |
| 915 | - if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) { |
|
| 916 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'], $this->current_destinations ) ) { |
|
| 917 | - $dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ]; |
|
| 915 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
| 916 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
| 917 | + $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
|
| 918 | 918 | |
| 919 | 919 | //TODO Check for attachments here. |
| 920 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 920 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 921 | 921 | |
| 922 | 922 | //Check if there is a country asigned. |
| 923 | - $potential_id = wp_get_post_parent_id( $dest_id ); |
|
| 924 | - $country_wetu_id = get_post_meta( $potential_id, 'lsx_wetu_id', true ); |
|
| 923 | + $potential_id = wp_get_post_parent_id($dest_id); |
|
| 924 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
| 925 | 925 | |
| 926 | - if ( false !== $country_wetu_id ) { |
|
| 927 | - $country_id = $this->set_country( $country_wetu_id, $id ); |
|
| 926 | + if (false !== $country_wetu_id) { |
|
| 927 | + $country_id = $this->set_country($country_wetu_id, $id); |
|
| 928 | 928 | } |
| 929 | - } else { |
|
| 930 | - $destination_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] ); |
|
| 929 | + }else { |
|
| 930 | + $destination_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']); |
|
| 931 | 931 | |
| 932 | - if ( ! empty( $destination_json ) && isset( $destination_json['response'] ) && isset( $destination_json['response']['code'] ) && 200 === $destination_json['response']['code'] ) { |
|
| 932 | + if (!empty($destination_json) && isset($destination_json['response']) && isset($destination_json['response']['code']) && 200 === $destination_json['response']['code']) { |
|
| 933 | 933 | |
| 934 | - $destination_data = json_decode( $destination_json['body'], true ); |
|
| 934 | + $destination_data = json_decode($destination_json['body'], true); |
|
| 935 | 935 | |
| 936 | - if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) { |
|
| 936 | + if (!empty($destination_data) && !isset($destination_data['error'])) { |
|
| 937 | 937 | $destination_title = $day['destination_content_entity_id']; |
| 938 | 938 | |
| 939 | - if ( isset( $destination_data[0]['name'] ) ) { |
|
| 939 | + if (isset($destination_data[0]['name'])) { |
|
| 940 | 940 | $destination_title = $destination_data[0]['name']; |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] ) |
|
| 944 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) { |
|
| 943 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 944 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
| 945 | 945 | |
| 946 | - $country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id ); |
|
| 946 | + $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
|
| 947 | 947 | // Save the destination so we can grab the tour featured image and banner from them. |
| 948 | 948 | } |
| 949 | 949 | |
@@ -953,40 +953,40 @@ discard block |
||
| 953 | 953 | 'post_title' => $destination_title, |
| 954 | 954 | ); |
| 955 | 955 | |
| 956 | - if ( false !== $country_id ) { |
|
| 956 | + if (false !== $country_id) { |
|
| 957 | 957 | $dest_post['post_parent'] = $country_id; |
| 958 | 958 | } |
| 959 | - $dest_id = wp_insert_post( $dest_post ); |
|
| 959 | + $dest_id = wp_insert_post($dest_post); |
|
| 960 | 960 | |
| 961 | 961 | // Make sure we register the. |
| 962 | - $this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id; |
|
| 962 | + $this->current_destinations[$day['destination_content_entity_id']] = $dest_id; |
|
| 963 | 963 | |
| 964 | 964 | // If there are images attached then use the destination. |
| 965 | - if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) { |
|
| 966 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 965 | + if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) { |
|
| 966 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - $this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id ); |
|
| 969 | + $this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id); |
|
| 970 | 970 | } |
| 971 | 971 | } |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - if ( '' !== $dest_id && false !== $dest_id ) { |
|
| 975 | - $this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false ); |
|
| 976 | - $this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false ); |
|
| 974 | + if ('' !== $dest_id && false !== $dest_id) { |
|
| 975 | + $this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false); |
|
| 976 | + $this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false); |
|
| 977 | 977 | |
| 978 | 978 | //Save the item to display in the queue |
| 979 | - $this->queue_item( $dest_id ); |
|
| 979 | + $this->queue_item($dest_id); |
|
| 980 | 980 | |
| 981 | 981 | //Save the item to clean up the amount of connections. |
| 982 | - $this->cleanup_posts[ $dest_id ] = 'tour_to_destination'; |
|
| 982 | + $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
|
| 983 | 983 | |
| 984 | 984 | //Add this relation info so we can make sure certain items are set as countries. |
| 985 | - if ( 0 !== $country_id && false !== $country_id ) { |
|
| 986 | - $this->relation_meta[ $dest_id ] = $country_id; |
|
| 987 | - $this->relation_meta[ $country_id ] = 0; |
|
| 988 | - } else { |
|
| 989 | - $this->relation_meta[ $dest_id ] = 0; |
|
| 985 | + if (0 !== $country_id && false !== $country_id) { |
|
| 986 | + $this->relation_meta[$dest_id] = $country_id; |
|
| 987 | + $this->relation_meta[$country_id] = 0; |
|
| 988 | + }else { |
|
| 989 | + $this->relation_meta[$dest_id] = 0; |
|
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | } |
@@ -1002,23 +1002,23 @@ discard block |
||
| 1002 | 1002 | * |
| 1003 | 1003 | * @return string |
| 1004 | 1004 | */ |
| 1005 | - public function set_country( $country_wetu_id, $id ) { |
|
| 1005 | + public function set_country($country_wetu_id, $id) { |
|
| 1006 | 1006 | $country_id = false; |
| 1007 | 1007 | $this->current_destinations = $this->find_current_destinations(); |
| 1008 | 1008 | |
| 1009 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) { |
|
| 1010 | - $country_id = $this->current_destinations[ $country_wetu_id ]; |
|
| 1011 | - $this->destination_images[ $id ][] = array( $country_id, $country_wetu_id ); |
|
| 1012 | - } else { |
|
| 1013 | - $country_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id ); |
|
| 1009 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
| 1010 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
| 1011 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1012 | + }else { |
|
| 1013 | + $country_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id); |
|
| 1014 | 1014 | |
| 1015 | - if ( ! empty( $country_json ) && isset( $country_json['response'] ) && isset( $country_json['response']['code'] ) && 200 === $country_json['response']['code'] ) { |
|
| 1016 | - $country_data = json_decode( $country_json['body'], true ); |
|
| 1015 | + if (!empty($country_json) && isset($country_json['response']) && isset($country_json['response']['code']) && 200 === $country_json['response']['code']) { |
|
| 1016 | + $country_data = json_decode($country_json['body'], true); |
|
| 1017 | 1017 | |
| 1018 | 1018 | // Format the title of the destination if its available, otherwise default to the WETU ID. |
| 1019 | 1019 | $country_title = $country_wetu_id; |
| 1020 | 1020 | |
| 1021 | - if ( isset( $country_data[0]['name'] ) ) { |
|
| 1021 | + if (isset($country_data[0]['name'])) { |
|
| 1022 | 1022 | $country_title = $country_data[0]['name']; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
@@ -1029,23 +1029,23 @@ discard block |
||
| 1029 | 1029 | )); |
| 1030 | 1030 | |
| 1031 | 1031 | //add the country to the current destination stack |
| 1032 | - $this->current_destinations[ $country_wetu_id ] = $country_id; |
|
| 1032 | + $this->current_destinations[$country_wetu_id] = $country_id; |
|
| 1033 | 1033 | |
| 1034 | 1034 | // Check if there are images and save fore use later. |
| 1035 | - if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) { |
|
| 1036 | - $this->destination_images[ $id ][] = array( $country_id,$country_wetu_id ); |
|
| 1035 | + if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) { |
|
| 1036 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | //Save the wetu field |
| 1040 | - $this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id ); |
|
| 1040 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
| 1041 | 1041 | } |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | - if ( '' !== $country_id && false !== $country_id ) { |
|
| 1045 | - $this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false ); |
|
| 1046 | - $this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false ); |
|
| 1047 | - $this->queue_item( $country_id ); |
|
| 1048 | - $this->cleanup_posts[ $country_id ] = 'tour_to_destination'; |
|
| 1044 | + if ('' !== $country_id && false !== $country_id) { |
|
| 1045 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
| 1046 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
| 1047 | + $this->queue_item($country_id); |
|
| 1048 | + $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
|
| 1049 | 1049 | |
| 1050 | 1050 | return $country_id; |
| 1051 | 1051 | } |
@@ -1060,44 +1060,44 @@ discard block |
||
| 1060 | 1060 | * |
| 1061 | 1061 | * @return string |
| 1062 | 1062 | */ |
| 1063 | - public function attach_destination_images( $importable_content = array() ) { |
|
| 1064 | - if ( false !== $this->destination_images ) { |
|
| 1065 | - $this->shuffle_assoc( $this->destination_images ); |
|
| 1063 | + public function attach_destination_images($importable_content = array()) { |
|
| 1064 | + if (false !== $this->destination_images) { |
|
| 1065 | + $this->shuffle_assoc($this->destination_images); |
|
| 1066 | 1066 | |
| 1067 | - foreach ( $this->destination_images as $tour => $destinations ) { |
|
| 1067 | + foreach ($this->destination_images as $tour => $destinations) { |
|
| 1068 | 1068 | //$this->shuffle_assoc( $destinations ); |
| 1069 | 1069 | |
| 1070 | 1070 | $image_set = false; |
| 1071 | 1071 | $forced = false; |
| 1072 | 1072 | |
| 1073 | - foreach ( $destinations as $destination ) { |
|
| 1074 | - if ( false === $image_set && false === $forced ) { |
|
| 1075 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 1073 | + foreach ($destinations as $destination) { |
|
| 1074 | + if (false === $image_set && false === $forced) { |
|
| 1075 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 1076 | 1076 | $url_qs = ''; |
| 1077 | 1077 | |
| 1078 | - $jdata = wp_remote_get( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] ); |
|
| 1078 | + $jdata = wp_remote_get($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
| 1079 | 1079 | |
| 1080 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 1081 | - $adata = json_decode( $jdata['body'], true ); |
|
| 1080 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 1081 | + $adata = json_decode($jdata['body'], true); |
|
| 1082 | 1082 | |
| 1083 | - if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) { |
|
| 1084 | - $this->find_attachments( $destination[0] ); |
|
| 1083 | + if (!empty($adata) && !empty($adata[0]['content']['images'])) { |
|
| 1084 | + $this->find_attachments($destination[0]); |
|
| 1085 | 1085 | |
| 1086 | 1086 | //Set the featured image |
| 1087 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 1088 | - $image_set = $this->set_featured_image( $adata, $tour ); |
|
| 1089 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 1090 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
| 1087 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 1088 | + $image_set = $this->set_featured_image($adata, $tour); |
|
| 1089 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 1090 | + $image_set = $this->set_banner_image($adata, $tour); |
|
| 1091 | 1091 | $forced = true; |
| 1092 | 1092 | } |
| 1093 | 1093 | continue; |
| 1094 | 1094 | } |
| 1095 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 1096 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
| 1095 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 1096 | + $image_set = $this->set_banner_image($adata, $tour); |
|
| 1097 | 1097 | } |
| 1098 | 1098 | } |
| 1099 | 1099 | } |
| 1100 | - } else { |
|
| 1100 | + }else { |
|
| 1101 | 1101 | continue; |
| 1102 | 1102 | } |
| 1103 | 1103 | } |
@@ -1108,28 +1108,28 @@ discard block |
||
| 1108 | 1108 | /** |
| 1109 | 1109 | * Creates the main gallery data |
| 1110 | 1110 | */ |
| 1111 | - public function set_featured_image( $data, $id ) { |
|
| 1111 | + public function set_featured_image($data, $id) { |
|
| 1112 | 1112 | $image_set = false; |
| 1113 | 1113 | $counter = 0; |
| 1114 | 1114 | |
| 1115 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1116 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
| 1115 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1116 | + foreach ($data[0]['content']['images'] as $v) { |
|
| 1117 | 1117 | /*print_r('<pre>'); |
| 1118 | 1118 | print_r( $v ); |
| 1119 | 1119 | print_r('</pre>');*/ |
| 1120 | 1120 | |
| 1121 | - if ( true === $image_set ) { |
|
| 1121 | + if (true === $image_set) { |
|
| 1122 | 1122 | $counter++; |
| 1123 | 1123 | continue; |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
| 1127 | - $temp_featured_image = $this->attach_image( $v , $id ); |
|
| 1126 | + if (!$this->check_if_image_is_used($v)) { |
|
| 1127 | + $temp_featured_image = $this->attach_image($v, $id); |
|
| 1128 | 1128 | |
| 1129 | - if ( false !== $temp_featured_image ) { |
|
| 1129 | + if (false !== $temp_featured_image) { |
|
| 1130 | 1130 | $this->featured_image = $temp_featured_image; |
| 1131 | - delete_post_meta( $id, '_thumbnail_id' ); |
|
| 1132 | - add_post_meta( $id, '_thumbnail_id', $this->featured_image, true ); |
|
| 1131 | + delete_post_meta($id, '_thumbnail_id'); |
|
| 1132 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
| 1133 | 1133 | $image_set = true; |
| 1134 | 1134 | } |
| 1135 | 1135 | } |
@@ -1143,40 +1143,40 @@ discard block |
||
| 1143 | 1143 | /** |
| 1144 | 1144 | * Sets a banner image |
| 1145 | 1145 | */ |
| 1146 | - public function set_banner_image( $data, $id, $content = array( 'none' ) ) { |
|
| 1146 | + public function set_banner_image($data, $id, $content = array('none')) { |
|
| 1147 | 1147 | $image_set = false; |
| 1148 | 1148 | $counter = 0; |
| 1149 | 1149 | |
| 1150 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1150 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1151 | 1151 | |
| 1152 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
| 1152 | + foreach ($data[0]['content']['images'] as $v) { |
|
| 1153 | 1153 | /*print_r('<pre>'); |
| 1154 | 1154 | print_r( $v ); |
| 1155 | 1155 | print_r('</pre>');*/ |
| 1156 | 1156 | |
| 1157 | - if ( true === $image_set || 0 === $counter ) { |
|
| 1157 | + if (true === $image_set || 0 === $counter) { |
|
| 1158 | 1158 | $counter++; |
| 1159 | 1159 | continue; |
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
| 1163 | - $temp_banner = $this->attach_image( $v, $id, array( |
|
| 1162 | + if (!$this->check_if_image_is_used($v)) { |
|
| 1163 | + $temp_banner = $this->attach_image($v, $id, array( |
|
| 1164 | 1164 | 'width' => '1920', |
| 1165 | 1165 | 'height' => '600', |
| 1166 | 1166 | 'cropping' => 'c', |
| 1167 | - ) ); |
|
| 1167 | + )); |
|
| 1168 | 1168 | |
| 1169 | - if ( false !== $temp_banner ) { |
|
| 1169 | + if (false !== $temp_banner) { |
|
| 1170 | 1170 | $this->banner_image = $temp_banner; |
| 1171 | 1171 | |
| 1172 | - delete_post_meta( $id,'image_group' ); |
|
| 1172 | + delete_post_meta($id, 'image_group'); |
|
| 1173 | 1173 | |
| 1174 | 1174 | $new_banner = array( |
| 1175 | 1175 | 'banner_image' => array( |
| 1176 | 1176 | 'cmb-field-0' => $this->banner_image, |
| 1177 | 1177 | ), |
| 1178 | 1178 | ); |
| 1179 | - add_post_meta( $id,'image_group',$new_banner,true ); |
|
| 1179 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
| 1180 | 1180 | $image_set = true; |
| 1181 | 1181 | } |
| 1182 | 1182 | } |
@@ -1190,36 +1190,36 @@ discard block |
||
| 1190 | 1190 | /** |
| 1191 | 1191 | * Grabs all of the current used featured images on the site. |
| 1192 | 1192 | */ |
| 1193 | - public function check_if_image_is_used( $v ) { |
|
| 1193 | + public function check_if_image_is_used($v) { |
|
| 1194 | 1194 | global $wpdb; |
| 1195 | 1195 | |
| 1196 | - $temp_fragment = explode( '/', $v['url_fragment'] ); |
|
| 1197 | - $url_filename = $temp_fragment[ count( $temp_fragment ) - 1 ]; |
|
| 1198 | - $url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $url_filename ); |
|
| 1199 | - $url_filename = trim( $url_filename ); |
|
| 1200 | - $url_filename = str_replace( ' ', '_', $url_filename ); |
|
| 1196 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
| 1197 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
| 1198 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
| 1199 | + $url_filename = trim($url_filename); |
|
| 1200 | + $url_filename = str_replace(' ', '_', $url_filename); |
|
| 1201 | 1201 | |
| 1202 | - if ( in_array( $url_filename, $this->found_attachments ) ) { |
|
| 1202 | + if (in_array($url_filename, $this->found_attachments)) { |
|
| 1203 | 1203 | // check to see if there is a featured image set with this ID. |
| 1204 | - $found_id = array_search( $url_filename, $this->found_attachments ); |
|
| 1204 | + $found_id = array_search($url_filename, $this->found_attachments); |
|
| 1205 | 1205 | |
| 1206 | - $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array( $found_id ) ) ); |
|
| 1207 | - if ( ! empty( $results ) ) { |
|
| 1206 | + $results = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array($found_id))); |
|
| 1207 | + if (!empty($results)) { |
|
| 1208 | 1208 | return true; |
| 1209 | - } else { |
|
| 1209 | + }else { |
|
| 1210 | 1210 | return false; |
| 1211 | 1211 | } |
| 1212 | - } else { |
|
| 1213 | - $results = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s'", array( $url_filename ) ) ); |
|
| 1212 | + }else { |
|
| 1213 | + $results = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s'", array($url_filename))); |
|
| 1214 | 1214 | |
| 1215 | - if ( ! empty( $results ) ) { |
|
| 1216 | - $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array( $results[0]->ID ) ) ); |
|
| 1217 | - if ( ! empty( $results ) ) { |
|
| 1215 | + if (!empty($results)) { |
|
| 1216 | + $results = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array($results[0]->ID))); |
|
| 1217 | + if (!empty($results)) { |
|
| 1218 | 1218 | return true; |
| 1219 | - } else { |
|
| 1219 | + }else { |
|
| 1220 | 1220 | return false; |
| 1221 | 1221 | } |
| 1222 | - } else { |
|
| 1222 | + }else { |
|
| 1223 | 1223 | return false; |
| 1224 | 1224 | } |
| 1225 | 1225 | } |
@@ -1230,10 +1230,10 @@ discard block |
||
| 1230 | 1230 | * |
| 1231 | 1231 | * @param $id int |
| 1232 | 1232 | */ |
| 1233 | - public function queue_item( $id ) { |
|
| 1234 | - if ( is_array( $this->import_queue ) && ! in_array( $id, $this->import_queue ) ) { |
|
| 1233 | + public function queue_item($id) { |
|
| 1234 | + if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) { |
|
| 1235 | 1235 | $this->import_queue[] = $id; |
| 1236 | - } else { |
|
| 1236 | + }else { |
|
| 1237 | 1237 | $this->import_queue[] = $id; |
| 1238 | 1238 | } |
| 1239 | 1239 | } |
@@ -1242,18 +1242,18 @@ discard block |
||
| 1242 | 1242 | * Saves the queue to the option. |
| 1243 | 1243 | */ |
| 1244 | 1244 | public function save_queue() { |
| 1245 | - if ( ! empty( $this->import_queue ) ) { |
|
| 1246 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 1247 | - $saved_imports = array_merge( $this->queued_imports, $this->import_queue ); |
|
| 1248 | - } else { |
|
| 1245 | + if (!empty($this->import_queue)) { |
|
| 1246 | + if (!empty($this->queued_imports)) { |
|
| 1247 | + $saved_imports = array_merge($this->queued_imports, $this->import_queue); |
|
| 1248 | + }else { |
|
| 1249 | 1249 | $saved_imports = $this->import_queue; |
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | - delete_option( 'lsx_wetu_importer_que' ); |
|
| 1252 | + delete_option('lsx_wetu_importer_que'); |
|
| 1253 | 1253 | |
| 1254 | - if ( ! empty( $saved_imports ) ) { |
|
| 1255 | - $saved_imports = array_unique( $saved_imports ); |
|
| 1256 | - update_option( 'lsx_wetu_importer_que', $saved_imports ); |
|
| 1254 | + if (!empty($saved_imports)) { |
|
| 1255 | + $saved_imports = array_unique($saved_imports); |
|
| 1256 | + update_option('lsx_wetu_importer_que', $saved_imports); |
|
| 1257 | 1257 | } |
| 1258 | 1258 | } |
| 1259 | 1259 | } |
@@ -1266,13 +1266,13 @@ discard block |
||
| 1266 | 1266 | <thead> |
| 1267 | 1267 | <tr> |
| 1268 | 1268 | <th style="" class="manage-column column-cb check-column no-sort" id="cb" scope="col"> |
| 1269 | - <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label> |
|
| 1269 | + <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label> |
|
| 1270 | 1270 | <input type="checkbox" id="cb-select-all-1"> |
| 1271 | 1271 | </th> |
| 1272 | - <th style="" class="manage-column column-title " id="title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th> |
|
| 1273 | - <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th> |
|
| 1274 | - <th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th> |
|
| 1275 | - <th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th> |
|
| 1272 | + <th style="" class="manage-column column-title " id="title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th> |
|
| 1273 | + <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th> |
|
| 1274 | + <th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th> |
|
| 1275 | + <th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th> |
|
| 1276 | 1276 | </tr> |
| 1277 | 1277 | </thead> |
| 1278 | 1278 | <?php |
@@ -1286,13 +1286,13 @@ discard block |
||
| 1286 | 1286 | <tfoot> |
| 1287 | 1287 | <tr> |
| 1288 | 1288 | <th style="" class="manage-column column-cb check-column" id="cb" scope="col"> |
| 1289 | - <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label> |
|
| 1289 | + <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label> |
|
| 1290 | 1290 | <input type="checkbox" id="cb-select-all-1"> |
| 1291 | 1291 | </th> |
| 1292 | - <th style="" class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th> |
|
| 1293 | - <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th> |
|
| 1294 | - <th style="" class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th> |
|
| 1295 | - <th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th> |
|
| 1292 | + <th style="" class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th> |
|
| 1293 | + <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th> |
|
| 1294 | + <th style="" class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th> |
|
| 1295 | + <th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th> |
|
| 1296 | 1296 | </tr> |
| 1297 | 1297 | </tfoot> |
| 1298 | 1298 | <?php |
@@ -11,13 +11,13 @@ |
||
| 11 | 11 | * Domain Path: /languages/ |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -define( 'LSX_WETU_IMPORTER_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 15 | -define( 'LSX_WETU_IMPORTER_CORE', __FILE__ ); |
|
| 16 | -define( 'LSX_WETU_IMPORTER_URL', plugin_dir_url( __FILE__ ) ); |
|
| 17 | -define( 'LSX_WETU_IMPORTER_VER', '1.3.0' ); |
|
| 14 | +define('LSX_WETU_IMPORTER_PATH', plugin_dir_path(__FILE__)); |
|
| 15 | +define('LSX_WETU_IMPORTER_CORE', __FILE__); |
|
| 16 | +define('LSX_WETU_IMPORTER_URL', plugin_dir_url(__FILE__)); |
|
| 17 | +define('LSX_WETU_IMPORTER_VER', '1.3.0'); |
|
| 18 | 18 | |
| 19 | -register_activation_hook( LSX_WETU_IMPORTER_CORE, array( 'LSX_WETU_Importer', 'register_activation_hook' ) ); |
|
| 19 | +register_activation_hook(LSX_WETU_IMPORTER_CORE, array('LSX_WETU_Importer', 'register_activation_hook')); |
|
| 20 | 20 | |
| 21 | 21 | /* ======================= Below is the Plugin Class init ========================= */ |
| 22 | 22 | |
| 23 | -require_once( LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer.php' ); |
|
| 23 | +require_once(LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer.php'); |
|