Completed
Push — master ( 13e5ed...79e677 )
by Warwick
06:23
created
classes/class-importer.php 1 patch
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -156,31 +156,31 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function __construct() {
158 158
 
159
-		add_action( 'admin_init', array( $this, 'compatible_version_check' ) );
159
+		add_action('admin_init', array($this, 'compatible_version_check'));
160 160
 
161 161
 		// Don't run anything else in the plugin, if we're on an incompatible PHP version
162
-		if ( ! self::compatible_version() ) {
162
+		if (!self::compatible_version()) {
163 163
 			return;
164 164
 		}
165 165
 
166 166
 		$this->set_variables();
167 167
 
168
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
169
-		add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 );
170
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 );
168
+		add_action('init', array($this, 'load_plugin_textdomain'));
169
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
170
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
171 171
 
172 172
 		require_once(WETU_IMPORTER_PATH.'classes/class-accommodation.php');
173 173
 		require_once(WETU_IMPORTER_PATH.'classes/class-destination.php');
174 174
 		require_once(WETU_IMPORTER_PATH.'classes/class-tours.php');
175 175
 
176
-		add_action( 'init', array( $this, 'load_class' ) );
176
+		add_action('init', array($this, 'load_class'));
177 177
 
178
-		if('default' !== $this->tab_slug){
179
-			add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));
180
-			add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));
178
+		if ('default' !== $this->tab_slug) {
179
+			add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));
180
+			add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));
181 181
 
182
-			add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));
183
-			add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
182
+			add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));
183
+			add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
184 184
 		}
185 185
 	}
186 186
 
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.0.0
193 193
 	 */
194 194
 	public function load_plugin_textdomain() {
195
-		load_plugin_textdomain( 'wetu-importer', FALSE, basename( WETU_IMPORTER_PATH ) . '/languages');
195
+		load_plugin_textdomain('wetu-importer', FALSE, basename(WETU_IMPORTER_PATH).'/languages');
196 196
 	}
197 197
 
198 198
 	/**
199 199
 	 * Sets the variables used throughout the plugin.
200 200
 	 */
201 201
 	public function set_variables() {
202
-		$this->post_types = array('accommodation','destination','tour');
203
-		$temp_options = get_option('_lsx-to_settings',false);
202
+		$this->post_types = array('accommodation', 'destination', 'tour');
203
+		$temp_options = get_option('_lsx-to_settings', false);
204 204
 
205 205
 		//Set the options.
206
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
206
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
207 207
 			$this->options = $temp_options[$this->plugin_slug];
208 208
 
209 209
 			$this->api_key = false;
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
             }
222 222
 
223 223
 			//Set the tab slug
224
-			if(isset($_GET['tab']) || isset($_POST['type'])) {
224
+			if (isset($_GET['tab']) || isset($_POST['type'])) {
225 225
 				if (isset($_GET['tab'])) {
226 226
 					$this->tab_slug = $_GET['tab'];
227
-				} else {
227
+				}else {
228 228
 					$this->tab_slug = $_POST['type'];
229 229
 				}
230 230
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                 if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
249 249
                     $cropping = $this->options['cropping'];
250 250
                 }
251
-                $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
251
+                $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
252 252
             }
253 253
 
254 254
 		}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @since 1.0.0
272 272
 	 */
273 273
 	public static function compatible_version() {
274
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
274
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
275 275
 			return false;
276 276
 		}
277 277
 
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * @since 1.0.0
286 286
 	 */
287 287
 	public function compatible_version_check() {
288
-		if ( ! self::compatible_version() ) {
289
-			if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) {
290
-				deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
291
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
288
+		if (!self::compatible_version()) {
289
+			if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) {
290
+				deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
291
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
292 292
 				
293
-				if ( isset( $_GET['activate'] ) ) {
294
-					unset( $_GET['activate'] );
293
+				if (isset($_GET['activate'])) {
294
+					unset($_GET['activate']);
295 295
 				}
296 296
 			}
297 297
 		}
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	public function compatible_version_notice() {
306 306
 		$class = 'notice notice-error';
307
-		$message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' );
308
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
307
+		$message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer');
308
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
309 309
 	}
310 310
 	
311 311
 	/**
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
 	 * @since 1.0.0
316 316
 	 */
317 317
 	public static function compatible_version_check_on_activation() {
318
-		if ( ! self::compatible_version() ) {
319
-			deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
320
-			wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) );
318
+		if (!self::compatible_version()) {
319
+			deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
320
+			wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'));
321 321
 		}
322 322
 	}
323 323
 
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
     /*
327 327
      * Load the importer class you want to use
328 328
      */
329
-    public function load_class(){
329
+    public function load_class() {
330 330
 
331
-		switch($this->tab_slug){
331
+		switch ($this->tab_slug) {
332 332
 			case 'accommodation':
333 333
 				$this->current_importer = new WETU_Importer_Accommodation();
334 334
 				break;
@@ -352,25 +352,25 @@  discard block
 block discarded – undo
352 352
 	 * Registers the admin page which will house the importer form.
353 353
 	 */
354 354
 	public function register_importer_page() {
355
-		add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) );
355
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page'));
356 356
 	}
357 357
 
358 358
 	/**
359 359
 	 * Enqueue the JS needed to contact wetu and return your result.
360 360
 	 */
361 361
 	public function admin_scripts() {
362
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
362
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
363 363
 			$min = '';
364
-		} else {
364
+		}else {
365 365
 			$min = '.min';
366 366
 		}
367 367
 		$min = '';
368 368
 
369
-		if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){
370
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
371
-			wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array(
369
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
370
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
371
+			wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array(
372 372
 				'ajax_url' => admin_url('admin-ajax.php'),
373
-			) );
373
+			));
374 374
 		}
375 375
 	}
376 376
 
@@ -382,25 +382,25 @@  discard block
 block discarded – undo
382 382
         <div class="wrap">
383 383
 			<?php screen_icon(); ?>
384 384
 
385
-			<?php if(!is_object($this->current_importer)){
385
+			<?php if (!is_object($this->current_importer)) {
386 386
 				?>
387
-                <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2>
387
+                <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2>
388 388
                 <p>If this is the first time you are running the import, then follow the steps below.</p>
389 389
                 <ul>
390
-                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li>
391
-                    <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li>
392
-                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
390
+                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li>
391
+                    <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li>
392
+                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
393 393
                 </ul>
394 394
 
395
-                <h3><?php _e('Additional Tools','wetu-importer'); ?></h3>
395
+                <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3>
396 396
                 <ul>
397
-                    <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation','wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.','wetu-importer'); ?></small></li>
398
-					<?php if(class_exists('Lsx_Banners')){ ?>
399
-                        <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images','wetu-importer'); ?></a></li>
397
+                    <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation', 'wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.', 'wetu-importer'); ?></small></li>
398
+					<?php if (class_exists('Lsx_Banners')) { ?>
399
+                        <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images', 'wetu-importer'); ?></a></li>
400 400
 					<?php } ?>
401 401
                 </ul>
402 402
 				<?php
403
-			}else{
403
+			}else {
404 404
 			   $this->current_importer->display_page();
405 405
             }; ?>
406 406
         </div>
@@ -415,38 +415,38 @@  discard block
 block discarded – undo
415 415
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
416 416
             <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
417 417
 
418
-            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
418
+            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
419 419
 
420
-			<?php do_action('wetu_importer_search_form',$this); ?>
420
+			<?php do_action('wetu_importer_search_form', $this); ?>
421 421
 
422 422
             <div class="normal-search">
423
-                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
423
+                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
424 424
             </div>
425 425
             <div class="advanced-search hidden" style="display:none;">
426
-                <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
426
+                <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
427 427
                 <textarea rows="10" cols="40" name="bulk-keywords"></textarea>
428
-                <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
428
+                <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
429 429
             </div>
430 430
 
431 431
             <p>
432
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
433
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
434
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
435
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a>
436
-
437
-                <?php if('tour'===$this->tab_slug){ ?>
438
-                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a>
439
-                <?php }else if(!empty($this->queued_imports)) { ?>
440
-                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue','wetu-importer'); ?></a>
432
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
433
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
434
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
435
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a>
436
+
437
+                <?php if ('tour' === $this->tab_slug) { ?>
438
+                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a>
439
+                <?php }else if (!empty($this->queued_imports)) { ?>
440
+                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue', 'wetu-importer'); ?></a>
441 441
                 <?php } ?>
442 442
             </p>
443 443
 
444 444
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
445
-                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
445
+                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
446 446
             </div>
447 447
 
448 448
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
449
-                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
449
+                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
450 450
             </div>
451 451
         </form> 
452 452
 		<?php
@@ -495,15 +495,15 @@  discard block
 block discarded – undo
495 495
 	 *
496 496
 	 * @param $tab string
497 497
 	 */
498
-	public function navigation($tab='') {
498
+	public function navigation($tab = '') {
499 499
 		$post_types = array(
500
-			'tour'              => esc_attr('Tours','wetu-importer'),
501
-			'accommodation'     => esc_attr('Accommodation','wetu-importer'),
502
-			'destination'       => esc_attr('Destinations','wetu-importer'),
500
+			'tour'              => esc_attr('Tours', 'wetu-importer'),
501
+			'accommodation'     => esc_attr('Accommodation', 'wetu-importer'),
502
+			'destination'       => esc_attr('Destinations', 'wetu-importer'),
503 503
 		);
504
-		echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab,'','current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home','wetu-importer').'</a>';
505
-		foreach($post_types as $post_type => $label){
506
-			echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
504
+		echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab, '', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home', 'wetu-importer').'</a>';
505
+		foreach ($post_types as $post_type => $label) {
506
+			echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
507 507
 		}
508 508
 		echo '</div><br clear="both"/></div>';
509 509
 	}
@@ -511,23 +511,23 @@  discard block
 block discarded – undo
511 511
 	/**
512 512
 	 * set_taxonomy with some terms
513 513
 	 */
514
-	public function team_member_checkboxes($selected=array()) {
515
-		if(post_type_exists('team')) { ?>
514
+	public function team_member_checkboxes($selected = array()) {
515
+		if (post_type_exists('team')) { ?>
516 516
             <ul>
517 517
 				<?php
518
-				$team_args=array(
518
+				$team_args = array(
519 519
 					'post_type'	=>	'team',
520 520
 					'post_status' => 'publish',
521 521
 					'nopagin' => true,
522 522
 					'fields' => 'ids'
523 523
 				);
524 524
 				$team_members = new WP_Query($team_args);
525
-				if($team_members->have_posts()){
526
-					foreach($team_members->posts as $member){ ?>
527
-                        <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
525
+				if ($team_members->have_posts()) {
526
+					foreach ($team_members->posts as $member) { ?>
527
+                        <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
528 528
 					<?php }
529
-				}else{ ?>
530
-                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
529
+				}else { ?>
530
+                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li>
531 531
 				<?php }
532 532
 				?>
533 533
             </ul>
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
 	 * @param $needle string
545 545
 	 * @param $echo bool
546 546
 	 */
547
-	public function checked($haystack=false,$needle='',$echo=true) {
548
-		$return = $this->itemd($haystack,$needle,'checked');
549
-		if('' !== $return) {
547
+	public function checked($haystack = false, $needle = '', $echo = true) {
548
+		$return = $this->itemd($haystack, $needle, 'checked');
549
+		if ('' !== $return) {
550 550
 			if (true === $echo) {
551 551
 				echo $return;
552
-			} else {
552
+			}else {
553 553
 				return $return;
554 554
 			}
555 555
 		}
@@ -562,12 +562,12 @@  discard block
 block discarded – undo
562 562
 	 * @param $needle string
563 563
 	 * @param $echo bool
564 564
 	 */
565
-	public function selected($haystack=false,$needle='',$echo=true) {
566
-		$return = $this->itemd($haystack,$needle,'selected');
567
-		if('' !== $return) {
565
+	public function selected($haystack = false, $needle = '', $echo = true) {
566
+		$return = $this->itemd($haystack, $needle, 'selected');
567
+		if ('' !== $return) {
568 568
 			if (true === $echo) {
569 569
 				echo $return;
570
-			} else {
570
+			}else {
571 571
 				return $return;
572 572
 			}
573 573
 		}
@@ -582,16 +582,16 @@  discard block
 block discarded – undo
582 582
 	 * @param $wrap bool
583 583
 	 * @return $html string
584 584
 	 */
585
-	public function itemd($haystack=false,$needle='',$type='',$wrap=true) {
585
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
586 586
 		$html = '';
587
-		if('' !== $type) {
587
+		if ('' !== $type) {
588 588
 			if (!is_array($haystack)) {
589 589
 				$haystack = array($haystack);
590 590
 			}
591 591
 			if (in_array($needle, $haystack)) {
592
-				if(true === $wrap || 'true' === $wrap) {
593
-					$html = $type . '="' . $type . '"';
594
-				}else{
592
+				if (true === $wrap || 'true' === $wrap) {
593
+					$html = $type.'="'.$type.'"';
594
+				}else {
595 595
 					$html = $type;
596 596
 				}
597 597
 			}
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
 	/**
604 604
 	 * grabs any attachments for the current item
605 605
 	 */
606
-	public function find_attachments($id=false) {
607
-		if(false !== $id){
608
-			if(empty($this->found_attachments)){
606
+	public function find_attachments($id = false) {
607
+		if (false !== $id) {
608
+			if (empty($this->found_attachments)) {
609 609
 
610 610
 				$attachments_args = array(
611 611
 					'post_parent' => $id,
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 				);
618 618
 
619 619
 				$attachments = new WP_Query($attachments_args);
620
-				if($attachments->have_posts()){
621
-					foreach($attachments->posts as $attachment){
622
-						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
620
+				if ($attachments->have_posts()) {
621
+					foreach ($attachments->posts as $attachment) {
622
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
623 623
 						$this->gallery_meta[] = $attachment->ID;
624 624
 					}
625 625
 				}
@@ -633,18 +633,18 @@  discard block
 block discarded – undo
633 633
 	/**
634 634
 	 * Saves the room data
635 635
 	 */
636
-	public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) {
637
-		if(false !== $value){
638
-			if(false !== $decrease){
636
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
637
+		if (false !== $value) {
638
+			if (false !== $decrease) {
639 639
 				$value = intval($value);
640 640
 				$value--;
641 641
 			}
642
-			$prev = get_post_meta($id,$meta_key,true);
642
+			$prev = get_post_meta($id, $meta_key, true);
643 643
 
644
-			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
645
-				update_post_meta($id,$meta_key,$value,$prev);
646
-			}else{
647
-				add_post_meta($id,$meta_key,$value,$unique);
644
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
645
+				update_post_meta($id, $meta_key, $value, $prev);
646
+			}else {
647
+				add_post_meta($id, $meta_key, $value, $unique);
648 648
 			}
649 649
 		}
650 650
 	}
@@ -653,12 +653,12 @@  discard block
 block discarded – undo
653 653
 	 * Grabs the custom fields,  and resaves an array of unique items.
654 654
 	 */
655 655
 	public function cleanup_posts() {
656
-		if(!empty($this->cleanup_posts)){
657
-			foreach($this->cleanup_posts as $id => $key) {
656
+		if (!empty($this->cleanup_posts)) {
657
+			foreach ($this->cleanup_posts as $id => $key) {
658 658
 				$prev_items = get_post_meta($id, $key, false);
659 659
 				$new_items = array_unique($prev_items);
660 660
 				delete_post_meta($id, $key);
661
-				foreach($new_items as $new_item) {
661
+				foreach ($new_items as $new_item) {
662 662
 					add_post_meta($id, $key, $new_item, false);
663 663
 				}
664 664
 			}
@@ -670,51 +670,51 @@  discard block
 block discarded – undo
670 670
 	/**
671 671
 	 * set_taxonomy with some terms
672 672
 	 */
673
-	public function set_taxonomy($taxonomy,$terms,$id) {
674
-		$result=array();
675
-		if(!empty($data))
673
+	public function set_taxonomy($taxonomy, $terms, $id) {
674
+		$result = array();
675
+		if (!empty($data))
676 676
 		{
677
-			foreach($data as $k)
677
+			foreach ($data as $k)
678 678
 			{
679
-				if($id)
679
+				if ($id)
680 680
 				{
681
-					if(!$term = term_exists(trim($k), $tax))
681
+					if (!$term = term_exists(trim($k), $tax))
682 682
 					{
683 683
 						$term = wp_insert_term(trim($k), $tax);
684
-						if ( is_wp_error($term) )
684
+						if (is_wp_error($term))
685 685
 						{
686 686
 							echo $term->get_error_message();
687 687
 						}
688 688
 						else
689 689
 						{
690
-							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
690
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
691 691
 						}
692 692
 					}
693 693
 					else
694 694
 					{
695
-						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
695
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
696 696
 					}
697 697
 				}
698 698
 				else
699 699
 				{
700
-					$result[]=trim($k);
700
+					$result[] = trim($k);
701 701
 				}
702 702
 			}
703 703
 		}
704 704
 		return $result;
705 705
 	}
706 706
 
707
-	public function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
708
-		if(!$term = term_exists($name, $taxonomy))
707
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
708
+		if (!$term = term_exists($name, $taxonomy))
709 709
 		{
710
-			if(false !== $parent){ $parent = array('parent'=>$parent); }
711
-			$term = wp_insert_term(trim($name), $taxonomy,$parent);
712
-			if ( is_wp_error($term) ){echo $term->get_error_message();}
713
-			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
710
+			if (false !== $parent) { $parent = array('parent'=>$parent); }
711
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
712
+			if (is_wp_error($term)) {echo $term->get_error_message(); }
713
+			else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); }
714 714
 		}
715 715
 		else
716 716
 		{
717
-			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
717
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
718 718
 		}
719 719
 		return $term['term_id'];
720 720
 	}
@@ -722,18 +722,18 @@  discard block
 block discarded – undo
722 722
 	/**
723 723
 	 * set_taxonomy with some terms
724 724
 	 */
725
-	public function taxonomy_checkboxes($taxonomy=false,$selected=array()) {
725
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
726 726
 		$return = '';
727
-		if(false !== $taxonomy){
727
+		if (false !== $taxonomy) {
728 728
 			$return .= '<ul>';
729
-			$terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false));
729
+			$terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false));
730 730
 
731
-			if(!is_wp_error($terms)){
732
-				foreach($terms as $term){
733
-					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
731
+			if (!is_wp_error($terms)) {
732
+				foreach ($terms as $term) {
733
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
734 734
 				}
735
-			}else{
736
-				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
735
+			}else {
736
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
737 737
 			}
738 738
 			$return .= '</ul>';
739 739
 		}
@@ -744,53 +744,53 @@  discard block
 block discarded – undo
744 744
 	/**
745 745
 	 * Saves the longitude and lattitude, as well as sets the map marker.
746 746
 	 */
747
-	public function set_map_data($data,$id,$zoom = '10') {
747
+	public function set_map_data($data, $id, $zoom = '10') {
748 748
 		$longitude = $latitude = $address = false;
749 749
 
750
-		if(isset($data[0]['position'])){
750
+		if (isset($data[0]['position'])) {
751 751
 
752
-			if(isset($data[0]['position']['driving_latitude'])){
752
+			if (isset($data[0]['position']['driving_latitude'])) {
753 753
 				$latitude = $data[0]['position']['driving_latitude'];
754
-			}elseif(isset($data[0]['position']['latitude'])){
754
+			}elseif (isset($data[0]['position']['latitude'])) {
755 755
 				$latitude = $data[0]['position']['latitude'];
756 756
 			}
757 757
 
758
-			if(isset($data[0]['position']['driving_longitude'])){
758
+			if (isset($data[0]['position']['driving_longitude'])) {
759 759
 				$longitude = $data[0]['position']['driving_longitude'];
760
-			}elseif(isset($data[0]['position']['longitude'])){
760
+			}elseif (isset($data[0]['position']['longitude'])) {
761 761
 				$longitude = $data[0]['position']['longitude'];
762 762
 			}
763 763
 
764 764
 		}
765
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
766
-			if(isset($data[0]['content']['contact_information']['address'])){
765
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
766
+			if (isset($data[0]['content']['contact_information']['address'])) {
767 767
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
768 768
 
769
-				$address = explode("\n",$address);
770
-				foreach($address as $bitkey => $bit){
769
+				$address = explode("\n", $address);
770
+				foreach ($address as $bitkey => $bit) {
771 771
 					$bit = ltrim(rtrim($bit));
772
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
772
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
773 773
 						unset($address[$bitkey]);
774 774
 					}
775 775
 				}
776
-				$address = implode(', ',$address);
776
+				$address = implode(', ', $address);
777 777
 				$address = str_replace(', , ', ', ', $address);
778 778
 			}
779 779
 		}
780 780
 
781
-		if(false !== $longitude){
781
+		if (false !== $longitude) {
782 782
 			$location_data = array(
783
-				'address'	=>	(string)$address,
784
-				'lat'		=>	(string)$latitude,
785
-				'long'		=>	(string)$longitude,
786
-				'zoom'		=>	(string)$zoom,
783
+				'address'	=>	(string) $address,
784
+				'lat'		=>	(string) $latitude,
785
+				'long'		=>	(string) $longitude,
786
+				'zoom'		=>	(string) $zoom,
787 787
 				'elevation'	=>	'',
788 788
 			);
789
-			if(false !== $id && '0' !== $id){
790
-				$prev = get_post_meta($id,'location',true);
791
-				update_post_meta($id,'location',$location_data,$prev);
792
-			}else{
793
-				add_post_meta($id,'location',$location_data,true);
789
+			if (false !== $id && '0' !== $id) {
790
+				$prev = get_post_meta($id, 'location', true);
791
+				update_post_meta($id, 'location', $location_data, $prev);
792
+			}else {
793
+				add_post_meta($id, 'location', $location_data, true);
794 794
 			}
795 795
 		}
796 796
 	}
@@ -800,16 +800,16 @@  discard block
 block discarded – undo
800 800
 	/**
801 801
 	 * Creates the main gallery data
802 802
 	 */
803
-	public function set_featured_image($data,$id) {
804
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
805
-			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
803
+	public function set_featured_image($data, $id) {
804
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
805
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id);
806 806
 
807
-			if(false !== $this->featured_image){
808
-				delete_post_meta($id,'_thumbnail_id');
809
-				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
807
+			if (false !== $this->featured_image) {
808
+				delete_post_meta($id, '_thumbnail_id');
809
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
810 810
 
811
-				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
812
-					add_post_meta($id,'gallery',$this->featured_image,false);
811
+				if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) {
812
+					add_post_meta($id, 'gallery', $this->featured_image, false);
813 813
 					$this->gallery_meta[] = $this->featured_image;
814 814
 				}
815 815
 			}
@@ -819,17 +819,17 @@  discard block
 block discarded – undo
819 819
 	/**
820 820
 	 * Sets a banner image
821 821
 	 */
822
-	public function set_banner_image($data,$id) {
823
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
824
-			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'600','cropping'=>'c'));
822
+	public function set_banner_image($data, $id) {
823
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
824
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1], $id, array('width'=>'1920', 'height'=>'600', 'cropping'=>'c'));
825 825
 
826
-			if(false !== $this->banner_image){
827
-				delete_post_meta($id,'image_group');
826
+			if (false !== $this->banner_image) {
827
+				delete_post_meta($id, 'image_group');
828 828
 				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
829
-				add_post_meta($id,'image_group',$new_banner,true);
829
+				add_post_meta($id, 'image_group', $new_banner, true);
830 830
 
831
-				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
832
-					add_post_meta($id,'gallery',$this->banner_image,false);
831
+				if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) {
832
+					add_post_meta($id, 'gallery', $this->banner_image, false);
833 833
 					$this->gallery_meta[] = $this->banner_image;
834 834
 				}
835 835
 			}
@@ -839,24 +839,24 @@  discard block
 block discarded – undo
839 839
 	/**
840 840
 	 * Creates the main gallery data
841 841
 	 */
842
-	public function create_main_gallery($data,$id) {
842
+	public function create_main_gallery($data, $id) {
843 843
 
844
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
844
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
845 845
 			$counter = 0;
846
-			foreach($data[0]['content']['images'] as $image_data){
847
-				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
848
-				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
846
+			foreach ($data[0]['content']['images'] as $image_data) {
847
+				if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; }
848
+				if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; }
849 849
 
850
-				$this->gallery_meta[] = $this->attach_image($image_data,$id);
850
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
851 851
 				$counter++;
852 852
 			}
853 853
 
854
-			if(!empty($this->gallery_meta)){
855
-				delete_post_meta($id,'gallery');
854
+			if (!empty($this->gallery_meta)) {
855
+				delete_post_meta($id, 'gallery');
856 856
 				$this->gallery_meta = array_unique($this->gallery_meta);
857
-				foreach($this->gallery_meta as $gallery_id){
858
-					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
859
-						add_post_meta($id,'gallery',$gallery_id,false);
857
+				foreach ($this->gallery_meta as $gallery_id) {
858
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
859
+						add_post_meta($id, 'gallery', $gallery_id, false);
860 860
 					}
861 861
 				}
862 862
 			}
@@ -866,27 +866,27 @@  discard block
 block discarded – undo
866 866
 	/**
867 867
 	 * search_form
868 868
 	 */
869
-	public function get_scaling_url($args=array()) {
869
+	public function get_scaling_url($args = array()) {
870 870
 
871 871
 		$defaults = array(
872 872
 			'width' => '640',
873 873
 			'height' => '480',
874 874
 			'cropping' => 'c'
875 875
 		);
876
-		if(false !== $this->options){
877
-			if(isset($this->options['width']) && '' !== $this->options['width']){
876
+		if (false !== $this->options) {
877
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
878 878
 				$defaults['width'] = $this->options['width'];
879 879
 			}
880 880
 
881
-			if(isset($this->options['height']) && '' !== $this->options['height']){
881
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
882 882
 				$defaults['height'] = $this->options['height'];
883 883
 			}
884 884
 
885
-			if(isset($this->options['cropping']) && '' !== $this->options['cropping']){
885
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
886 886
 				$defaults['cropping'] = $this->options['cropping'];
887 887
 			}
888 888
 		}
889
-		$args = wp_parse_args($args,$defaults);
889
+		$args = wp_parse_args($args, $defaults);
890 890
 
891 891
 		$cropping = $args['cropping'];
892 892
 		$width = $args['width'];
@@ -899,40 +899,40 @@  discard block
 block discarded – undo
899 899
 	/**
900 900
 	 * Attaches 1 image
901 901
 	 */
902
-	public function attach_image($v=false,$parent_id,$image_sizes=false){
903
-		if(false !== $v){
904
-			$temp_fragment = explode('/',$v['url_fragment']);
905
-			$url_filename = $temp_fragment[count($temp_fragment)-1];
906
-			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
907
-
908
-			if(in_array($url_filename,$this->found_attachments)){
909
-				return array_search($url_filename,$this->found_attachments);
902
+	public function attach_image($v = false, $parent_id, $image_sizes = false) {
903
+		if (false !== $v) {
904
+			$temp_fragment = explode('/', $v['url_fragment']);
905
+			$url_filename = $temp_fragment[count($temp_fragment) - 1];
906
+			$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
907
+
908
+			if (in_array($url_filename, $this->found_attachments)) {
909
+				return array_search($url_filename, $this->found_attachments);
910 910
 			}
911 911
 
912
-			$postdata=array();
913
-			if(empty($v['label']))
912
+			$postdata = array();
913
+			if (empty($v['label']))
914 914
 			{
915
-				$v['label']='';
915
+				$v['label'] = '';
916 916
 			}
917
-			if(!empty($v['description']))
917
+			if (!empty($v['description']))
918 918
 			{
919
-				$desc=wp_strip_all_tags($v['description']);
920
-				$posdata=array('post_excerpt'=>$desc);
919
+				$desc = wp_strip_all_tags($v['description']);
920
+				$posdata = array('post_excerpt'=>$desc);
921 921
 			}
922
-			if(!empty($v['section']))
922
+			if (!empty($v['section']))
923 923
 			{
924
-				$desc=wp_strip_all_tags($v['section']);
925
-				$posdata=array('post_excerpt'=>$desc);
924
+				$desc = wp_strip_all_tags($v['section']);
925
+				$posdata = array('post_excerpt'=>$desc);
926 926
 			}
927 927
 
928
-			$attachID=NULL;
928
+			$attachID = NULL;
929 929
 			//Resizor - add option to setting if required
930
-			$fragment = str_replace(' ','%20',$v['url_fragment']);
930
+			$fragment = str_replace(' ', '%20', $v['url_fragment']);
931 931
 			$url = $this->get_scaling_url($image_sizes).$fragment;
932
-			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
932
+			$attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
933 933
 
934 934
 			//echo($attachID.' add image');
935
-			if($attachID!=NULL)
935
+			if ($attachID != NULL)
936 936
 			{
937 937
 				return $attachID;
938 938
 			}
@@ -940,13 +940,13 @@  discard block
 block discarded – undo
940 940
 		return 	false;
941 941
 	}
942 942
 
943
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
943
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
944 944
 
945
-		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
945
+		if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
946 946
 
947
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
948
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
949
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
947
+		require_once(ABSPATH.'wp-admin/includes/file.php');
948
+		require_once(ABSPATH.'wp-admin/includes/media.php');
949
+		require_once(ABSPATH.'wp-admin/includes/image.php');
950 950
 		// Download file to temp location, returns full server path to temp file
951 951
 		//$tmp = download_url( $url );
952 952
 
@@ -955,53 +955,53 @@  discard block
 block discarded – undo
955 955
 
956 956
 		$image = file_get_contents($url);
957 957
 		file_put_contents($tmp, $image);
958
-		chmod($tmp,'777');
958
+		chmod($tmp, '777');
959 959
 
960
-		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
960
+		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
961 961
 		$url_filename = basename($matches[0]);
962
-		$url_filename=str_replace('%20','_',$url_filename);
962
+		$url_filename = str_replace('%20', '_', $url_filename);
963 963
 		// extract filename from url for title
964
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
964
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
965 965
 
966 966
 		// override filename if given, reconstruct server path
967
-		if ( !empty( $filename ) && " " != $filename )
967
+		if (!empty($filename) && " " != $filename)
968 968
 		{
969 969
 			$filename = sanitize_file_name($filename);
970
-			$tmppath = pathinfo( $tmp );
970
+			$tmppath = pathinfo($tmp);
971 971
 
972 972
 			$extension = '';
973
-			if(isset($tmppath['extension'])){
973
+			if (isset($tmppath['extension'])) {
974 974
 				$extension = $tmppath['extension'];
975 975
 			}
976 976
 
977
-			$new = $tmppath['dirname'] . "/". $filename . "." . $extension;
978
-			rename($tmp, $new);                                                                 // renames temp file on server
979
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
977
+			$new = $tmppath['dirname']."/".$filename.".".$extension;
978
+			rename($tmp, $new); // renames temp file on server
979
+			$tmp = $new; // push new filename (in path) to be used in file array later
980 980
 		}
981 981
 
982 982
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
983
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
983
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
984 984
 
985
-		if ( !empty( $filename) && " " != $filename )
985
+		if (!empty($filename) && " " != $filename)
986 986
 		{
987
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
987
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
988 988
 		}
989 989
 		else
990 990
 		{
991
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
991
+			$file_array['name'] = $url_filename; // just use original URL filename
992 992
 		}
993 993
 
994 994
 		// set additional wp_posts columns
995
-		if ( empty( $post_data['post_title'] ) )
995
+		if (empty($post_data['post_title']))
996 996
 		{
997 997
 
998
-			$url_filename=str_replace('%20',' ',$url_filename);
998
+			$url_filename = str_replace('%20', ' ', $url_filename);
999 999
 
1000
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
1000
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
1001 1001
 		}
1002 1002
 
1003 1003
 		// make sure gets tied to parent
1004
-		if ( empty( $post_data['post_parent'] ) )
1004
+		if (empty($post_data['post_parent']))
1005 1005
 		{
1006 1006
 			$post_data['post_parent'] = $post_id;
1007 1007
 		}
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
 		// required libraries for media_handle_sideload
1010 1010
 
1011 1011
 		// do the validation and storage stuff
1012
-		$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
1012
+		$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
1013 1013
 
1014 1014
 		// If error storing permanently, unlink
1015
-		if ( is_wp_error($att_id) )
1015
+		if (is_wp_error($att_id))
1016 1016
 		{
1017
-			unlink($file_array['tmp_name']);   // clean up
1017
+			unlink($file_array['tmp_name']); // clean up
1018 1018
 			return false; // output wp_error
1019 1019
 			//return $att_id; // output wp_error
1020 1020
 		}
@@ -1043,24 +1043,24 @@  discard block
 block discarded – undo
1043 1043
 	/**
1044 1044
 	 * Formats the row for the completed list.
1045 1045
 	 */
1046
-	public function format_completed_row($response){
1046
+	public function format_completed_row($response) {
1047 1047
 		echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>';
1048 1048
 	}
1049 1049
 
1050 1050
 	/**
1051 1051
 	 * Does a multine search
1052 1052
 	 */
1053
-	public function multineedle_stripos($haystack, $needles, $offset=0) {
1053
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1054 1054
 		$found = false;
1055 1055
 		$needle_count = count($needles);
1056
-		foreach($needles as $needle) {
1057
-			if(false !== stripos($haystack, $needle, $offset)){
1056
+		foreach ($needles as $needle) {
1057
+			if (false !== stripos($haystack, $needle, $offset)) {
1058 1058
 				$found[] = true;
1059 1059
 			}
1060 1060
 		}
1061
-		if(false !== $found && $needle_count === count($found)){
1061
+		if (false !== $found && $needle_count === count($found)) {
1062 1062
 			return true;
1063
-		}else{
1063
+		}else {
1064 1064
 			return false;
1065 1065
 		}
1066 1066
 	}
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	/**
1069 1069
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1070 1070
 	 */
1071
-	public function find_current_accommodation($post_type='accommodation') {
1071
+	public function find_current_accommodation($post_type = 'accommodation') {
1072 1072
 		global $wpdb;
1073 1073
 		$return = array();
1074 1074
 
@@ -1084,8 +1084,8 @@  discard block
 block discarded – undo
1084 1084
 
1085 1085
 					LIMIT 0,500
1086 1086
 		");
1087
-		if(null !== $current_accommodation && !empty($current_accommodation)){
1088
-			foreach($current_accommodation as $accom){
1087
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1088
+			foreach ($current_accommodation as $accom) {
1089 1089
 				$return[$accom->meta_value] = $accom;
1090 1090
 			}
1091 1091
 		}
@@ -1095,31 +1095,31 @@  discard block
 block discarded – undo
1095 1095
 	/**
1096 1096
 	 * Set the Video date
1097 1097
 	 */
1098
-	public function set_video_data($data,$id) {
1099
-		if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){
1098
+	public function set_video_data($data, $id) {
1099
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1100 1100
 			$videos = false;
1101 1101
 
1102
-			foreach($data[0]['content']['youtube_videos'] as $video){
1102
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1103 1103
 				$temp_video = array();
1104 1104
 
1105
-				if(isset($video['label'])){
1105
+				if (isset($video['label'])) {
1106 1106
 					$temp_video['title'] = $video['label'];
1107 1107
 				}
1108
-				if(isset($video['description'])){
1108
+				if (isset($video['description'])) {
1109 1109
 					$temp_video['description'] = strip_tags($video['description']);
1110 1110
 				}
1111
-				if(isset($video['url'])){
1111
+				if (isset($video['url'])) {
1112 1112
 					$temp_video['url'] = $video['url'];
1113 1113
 				}
1114 1114
 				$temp_video['thumbnail'] = '';
1115 1115
 				$videos[] = $temp_video;
1116 1116
 			}
1117 1117
 
1118
-			if(false !== $id && '0' !== $id){
1118
+			if (false !== $id && '0' !== $id) {
1119 1119
 				delete_post_meta($id, 'videos');
1120 1120
 			}
1121
-			foreach($videos as $video){
1122
-				add_post_meta($id,'videos',$video,false);
1121
+			foreach ($videos as $video) {
1122
+				add_post_meta($id, 'videos', $video, false);
1123 1123
 			}
1124 1124
 		}
1125 1125
 	}
Please login to merge, or discard this patch.