Completed
Push — master ( ef4c1a...1aafd8 )
by Warwick
07:18
created
classes/class-importer.php 1 patch
Spacing   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -148,31 +148,31 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function __construct() {
150 150
 
151
-		add_action( 'admin_init', array( $this, 'compatible_version_check' ) );
151
+		add_action('admin_init', array($this, 'compatible_version_check'));
152 152
 
153 153
 		// Don't run anything else in the plugin, if we're on an incompatible PHP version
154
-		if ( ! self::compatible_version() ) {
154
+		if (!self::compatible_version()) {
155 155
 			return;
156 156
 		}
157 157
 
158 158
 		$this->set_variables();
159 159
 
160
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
161
-		add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 );
162
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 );
160
+		add_action('init', array($this, 'load_plugin_textdomain'));
161
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
162
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
163 163
 
164 164
 		require_once(WETU_IMPORTER_PATH.'classes/class-accommodation.php');
165 165
 		require_once(WETU_IMPORTER_PATH.'classes/class-destination.php');
166 166
 		require_once(WETU_IMPORTER_PATH.'classes/class-tours.php');
167 167
 
168
-		add_action( 'init', array( $this, 'load_class' ) );
168
+		add_action('init', array($this, 'load_class'));
169 169
 
170
-		if('default' !== $this->tab_slug){
171
-			add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));
172
-			add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));
170
+		if ('default' !== $this->tab_slug) {
171
+			add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));
172
+			add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));
173 173
 
174
-			add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));
175
-			add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
174
+			add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));
175
+			add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
176 176
 		}
177 177
 	}
178 178
 
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 	 * @since 1.0.0
185 185
 	 */
186 186
 	public function load_plugin_textdomain() {
187
-		load_plugin_textdomain( 'wetu-importer', FALSE, basename( WETU_IMPORTER_PATH ) . '/languages');
187
+		load_plugin_textdomain('wetu-importer', FALSE, basename(WETU_IMPORTER_PATH).'/languages');
188 188
 	}
189 189
 
190 190
 	/**
191 191
 	 * Sets the variables used throughout the plugin.
192 192
 	 */
193 193
 	public function set_variables() {
194
-		$this->post_types = array('accommodation','destination','tour');
195
-		$temp_options = get_option('_lsx-to_settings',false);
194
+		$this->post_types = array('accommodation', 'destination', 'tour');
195
+		$temp_options = get_option('_lsx-to_settings', false);
196 196
 
197 197
 		//Set the options.
198
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
198
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
199 199
 			$this->options = $temp_options[$this->plugin_slug];
200 200
 
201 201
 			$this->api_key = false;
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
             }
214 214
 
215 215
 			//Set the tab slug
216
-			if(isset($_GET['tab']) || isset($_POST['type'])) {
217
-				if(isset($_GET['tab'])) {
216
+			if (isset($_GET['tab']) || isset($_POST['type'])) {
217
+				if (isset($_GET['tab'])) {
218 218
 					$this->tab_slug = $_GET['tab'];
219
-				}else{
219
+				}else {
220 220
 					$this->tab_slug = $_POST['type'];
221 221
 				}
222 222
 
223
-				if('tours' !== $this->tab_slug) {
223
+				if ('tours' !== $this->tab_slug) {
224 224
 					//If any tours were queued
225 225
 					$this->queued_imports = get_option('wetu_importer_que', false);
226 226
 				}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
242 242
                     $cropping = $this->options['cropping'];
243 243
                 }
244
-                $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
244
+                $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
245 245
             }
246 246
 
247 247
 		}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @since 1.0.0
265 265
 	 */
266 266
 	public static function compatible_version() {
267
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
267
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
268 268
 			return false;
269 269
 		}
270 270
 
@@ -278,13 +278,13 @@  discard block
 block discarded – undo
278 278
 	 * @since 1.0.0
279 279
 	 */
280 280
 	public function compatible_version_check() {
281
-		if ( ! self::compatible_version() ) {
282
-			if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) {
283
-				deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
284
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
281
+		if (!self::compatible_version()) {
282
+			if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) {
283
+				deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
284
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
285 285
 				
286
-				if ( isset( $_GET['activate'] ) ) {
287
-					unset( $_GET['activate'] );
286
+				if (isset($_GET['activate'])) {
287
+					unset($_GET['activate']);
288 288
 				}
289 289
 			}
290 290
 		}
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function compatible_version_notice() {
299 299
 		$class = 'notice notice-error';
300
-		$message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' );
301
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
300
+		$message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer');
301
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
302 302
 	}
303 303
 	
304 304
 	/**
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
 	 * @since 1.0.0
309 309
 	 */
310 310
 	public static function compatible_version_check_on_activation() {
311
-		if ( ! self::compatible_version() ) {
312
-			deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
313
-			wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) );
311
+		if (!self::compatible_version()) {
312
+			deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
313
+			wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'));
314 314
 		}
315 315
 	}
316 316
 
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
     /*
320 320
      * Load the importer class you want to use
321 321
      */
322
-    public function load_class(){
322
+    public function load_class() {
323 323
 
324
-		switch($this->tab_slug){
324
+		switch ($this->tab_slug) {
325 325
 			case 'accommodation':
326 326
 				$this->current_importer = new WETU_Importer_Accommodation();
327 327
 				break;
@@ -345,25 +345,25 @@  discard block
 block discarded – undo
345 345
 	 * Registers the admin page which will house the importer form.
346 346
 	 */
347 347
 	public function register_importer_page() {
348
-		add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) );
348
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page'));
349 349
 	}
350 350
 
351 351
 	/**
352 352
 	 * Enqueue the JS needed to contact wetu and return your result.
353 353
 	 */
354 354
 	public function admin_scripts() {
355
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
355
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
356 356
 			$min = '';
357
-		} else {
357
+		}else {
358 358
 			$min = '.min';
359 359
 		}
360 360
 		$min = '';
361 361
 
362
-		if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){
363
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
364
-			wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array(
362
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
363
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
364
+			wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array(
365 365
 				'ajax_url' => admin_url('admin-ajax.php'),
366
-			) );
366
+			));
367 367
 		}
368 368
 	}
369 369
 
@@ -375,25 +375,25 @@  discard block
 block discarded – undo
375 375
         <div class="wrap">
376 376
 			<?php screen_icon(); ?>
377 377
 
378
-			<?php if(!is_object($this->current_importer)){
378
+			<?php if (!is_object($this->current_importer)) {
379 379
 				?>
380
-                <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2>
380
+                <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2>
381 381
                 <p>If this is the first time you are running the import, then follow the steps below.</p>
382 382
                 <ul>
383
-                    <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>
384
-                    <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>
385
-                    <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>
383
+                    <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>
384
+                    <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>
385
+                    <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>
386 386
                 </ul>
387 387
 
388
-                <h3><?php _e('Additional Tools','wetu-importer'); ?></h3>
388
+                <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3>
389 389
                 <ul>
390
-                    <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>
391
-					<?php if(class_exists('Lsx_Banners')){ ?>
392
-                        <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>
390
+                    <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>
391
+					<?php if (class_exists('Lsx_Banners')) { ?>
392
+                        <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>
393 393
 					<?php } ?>
394 394
                 </ul>
395 395
 				<?php
396
-			}else{
396
+			}else {
397 397
 			   $this->current_importer->display_page();
398 398
             }; ?>
399 399
         </div>
@@ -408,33 +408,33 @@  discard block
 block discarded – undo
408 408
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
409 409
             <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
410 410
 
411
-            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
411
+            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
412 412
 
413
-			<?php do_action('wetu_importer_search_form',$this); ?>
413
+			<?php do_action('wetu_importer_search_form', $this); ?>
414 414
 
415 415
             <div class="normal-search">
416
-                <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'); ?>" />
416
+                <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'); ?>" />
417 417
             </div>
418 418
             <div class="advanced-search hidden" style="display:none;">
419
-                <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
419
+                <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
420 420
                 <textarea rows="10" cols="40" name="bulk-keywords"></textarea>
421
-                <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
421
+                <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
422 422
             </div>
423 423
 
424 424
             <p>
425
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
426
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
427
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
428
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a>
429
-                <?php if('tour'===$this->tab_slug || false !== $this->queued_imports){ ?> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a><?php } ?>
425
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
426
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
427
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
428
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a>
429
+                <?php if ('tour' === $this->tab_slug || false !== $this->queued_imports) { ?> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a><?php } ?>
430 430
             </p>
431 431
 
432 432
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
433
-                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
433
+                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
434 434
             </div>
435 435
 
436 436
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
437
-                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
437
+                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
438 438
             </div>
439 439
         </form> 
440 440
 		<?php
@@ -483,15 +483,15 @@  discard block
 block discarded – undo
483 483
 	 *
484 484
 	 * @param $tab string
485 485
 	 */
486
-	public function navigation($tab='') {
486
+	public function navigation($tab = '') {
487 487
 		$post_types = array(
488
-			'tour'              => esc_attr('Tours','wetu-importer'),
489
-			'accommodation'     => esc_attr('Accommodation','wetu-importer'),
490
-			'destination'       => esc_attr('Destinations','wetu-importer'),
488
+			'tour'              => esc_attr('Tours', 'wetu-importer'),
489
+			'accommodation'     => esc_attr('Accommodation', 'wetu-importer'),
490
+			'destination'       => esc_attr('Destinations', 'wetu-importer'),
491 491
 		);
492
-		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>';
493
-		foreach($post_types as $post_type => $label){
494
-			echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
492
+		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>';
493
+		foreach ($post_types as $post_type => $label) {
494
+			echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
495 495
 		}
496 496
 		echo '</div><br clear="both"/></div>';
497 497
 	}
@@ -499,23 +499,23 @@  discard block
 block discarded – undo
499 499
 	/**
500 500
 	 * set_taxonomy with some terms
501 501
 	 */
502
-	public function team_member_checkboxes($selected=array()) {
503
-		if(post_type_exists('team')) { ?>
502
+	public function team_member_checkboxes($selected = array()) {
503
+		if (post_type_exists('team')) { ?>
504 504
             <ul>
505 505
 				<?php
506
-				$team_args=array(
506
+				$team_args = array(
507 507
 					'post_type'	=>	'team',
508 508
 					'post_status' => 'publish',
509 509
 					'nopagin' => true,
510 510
 					'fields' => 'ids'
511 511
 				);
512 512
 				$team_members = new WP_Query($team_args);
513
-				if($team_members->have_posts()){
514
-					foreach($team_members->posts as $member){ ?>
515
-                        <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
513
+				if ($team_members->have_posts()) {
514
+					foreach ($team_members->posts as $member) { ?>
515
+                        <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
516 516
 					<?php }
517
-				}else{ ?>
518
-                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
517
+				}else { ?>
518
+                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li>
519 519
 				<?php }
520 520
 				?>
521 521
             </ul>
@@ -532,12 +532,12 @@  discard block
 block discarded – undo
532 532
 	 * @param $needle string
533 533
 	 * @param $echo bool
534 534
 	 */
535
-	public function checked($haystack=false,$needle='',$echo=true) {
536
-		$return = $this->itemd($haystack,$needle,'checked');
537
-		if('' !== $return) {
535
+	public function checked($haystack = false, $needle = '', $echo = true) {
536
+		$return = $this->itemd($haystack, $needle, 'checked');
537
+		if ('' !== $return) {
538 538
 			if (true === $echo) {
539 539
 				echo $return;
540
-			} else {
540
+			}else {
541 541
 				return $return;
542 542
 			}
543 543
 		}
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
 	 * @param $needle string
551 551
 	 * @param $echo bool
552 552
 	 */
553
-	public function selected($haystack=false,$needle='',$echo=true) {
554
-		$return = $this->itemd($haystack,$needle,'selected');
555
-		if('' !== $return) {
553
+	public function selected($haystack = false, $needle = '', $echo = true) {
554
+		$return = $this->itemd($haystack, $needle, 'selected');
555
+		if ('' !== $return) {
556 556
 			if (true === $echo) {
557 557
 				echo $return;
558
-			} else {
558
+			}else {
559 559
 				return $return;
560 560
 			}
561 561
 		}
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
 	 * @param $wrap bool
571 571
 	 * @return $html string
572 572
 	 */
573
-	public function itemd($haystack=false,$needle='',$type='',$wrap=true) {
573
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
574 574
 		$html = '';
575
-		if('' !== $type) {
575
+		if ('' !== $type) {
576 576
 			if (!is_array($haystack)) {
577 577
 				$haystack = array($haystack);
578 578
 			}
579 579
 			if (in_array($needle, $haystack)) {
580
-				if(true === $wrap || 'true' === $wrap) {
581
-					$html = $type . '="' . $type . '"';
582
-				}else{
580
+				if (true === $wrap || 'true' === $wrap) {
581
+					$html = $type.'="'.$type.'"';
582
+				}else {
583 583
 					$html = $type;
584 584
 				}
585 585
 			}
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
 	/**
592 592
 	 * grabs any attachments for the current item
593 593
 	 */
594
-	public function find_attachments($id=false) {
595
-		if(false !== $id){
596
-			if(empty($this->found_attachments)){
594
+	public function find_attachments($id = false) {
595
+		if (false !== $id) {
596
+			if (empty($this->found_attachments)) {
597 597
 
598 598
 				$attachments_args = array(
599 599
 					'post_parent' => $id,
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 				);
606 606
 
607 607
 				$attachments = new WP_Query($attachments_args);
608
-				if($attachments->have_posts()){
609
-					foreach($attachments->posts as $attachment){
610
-						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
608
+				if ($attachments->have_posts()) {
609
+					foreach ($attachments->posts as $attachment) {
610
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
611 611
 						$this->gallery_meta[] = $attachment->ID;
612 612
 					}
613 613
 				}
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 	/**
622 622
 	 * Saves the room data
623 623
 	 */
624
-	public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) {
625
-		if(false !== $value){
626
-			if(false !== $decrease){
624
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
625
+		if (false !== $value) {
626
+			if (false !== $decrease) {
627 627
 				$value = intval($value);
628 628
 				$value--;
629 629
 			}
630
-			$prev = get_post_meta($id,$meta_key,true);
630
+			$prev = get_post_meta($id, $meta_key, true);
631 631
 
632
-			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
633
-				update_post_meta($id,$meta_key,$value,$prev);
634
-			}else{
635
-				add_post_meta($id,$meta_key,$value,$unique);
632
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
633
+				update_post_meta($id, $meta_key, $value, $prev);
634
+			}else {
635
+				add_post_meta($id, $meta_key, $value, $unique);
636 636
 			}
637 637
 		}
638 638
 	}
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
 	 * Grabs the custom fields,  and resaves an array of unique items.
642 642
 	 */
643 643
 	public function cleanup_posts() {
644
-		if(!empty($this->cleanup_posts)){
645
-			foreach($this->cleanup_posts as $id => $key) {
644
+		if (!empty($this->cleanup_posts)) {
645
+			foreach ($this->cleanup_posts as $id => $key) {
646 646
 				$prev_items = get_post_meta($id, $key, false);
647 647
 				$new_items = array_unique($prev_items);
648 648
 				delete_post_meta($id, $key);
649
-				foreach($new_items as $new_item) {
649
+				foreach ($new_items as $new_item) {
650 650
 					add_post_meta($id, $key, $new_item, false);
651 651
 				}
652 652
 			}
@@ -658,51 +658,51 @@  discard block
 block discarded – undo
658 658
 	/**
659 659
 	 * set_taxonomy with some terms
660 660
 	 */
661
-	public function set_taxonomy($taxonomy,$terms,$id) {
662
-		$result=array();
663
-		if(!empty($data))
661
+	public function set_taxonomy($taxonomy, $terms, $id) {
662
+		$result = array();
663
+		if (!empty($data))
664 664
 		{
665
-			foreach($data as $k)
665
+			foreach ($data as $k)
666 666
 			{
667
-				if($id)
667
+				if ($id)
668 668
 				{
669
-					if(!$term = term_exists(trim($k), $tax))
669
+					if (!$term = term_exists(trim($k), $tax))
670 670
 					{
671 671
 						$term = wp_insert_term(trim($k), $tax);
672
-						if ( is_wp_error($term) )
672
+						if (is_wp_error($term))
673 673
 						{
674 674
 							echo $term->get_error_message();
675 675
 						}
676 676
 						else
677 677
 						{
678
-							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
678
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
679 679
 						}
680 680
 					}
681 681
 					else
682 682
 					{
683
-						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
683
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
684 684
 					}
685 685
 				}
686 686
 				else
687 687
 				{
688
-					$result[]=trim($k);
688
+					$result[] = trim($k);
689 689
 				}
690 690
 			}
691 691
 		}
692 692
 		return $result;
693 693
 	}
694 694
 
695
-	public function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
696
-		if(!$term = term_exists($name, $taxonomy))
695
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
696
+		if (!$term = term_exists($name, $taxonomy))
697 697
 		{
698
-			if(false !== $parent){ $parent = array('parent'=>$parent); }
699
-			$term = wp_insert_term(trim($name), $taxonomy,$parent);
700
-			if ( is_wp_error($term) ){echo $term->get_error_message();}
701
-			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
698
+			if (false !== $parent) { $parent = array('parent'=>$parent); }
699
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
700
+			if (is_wp_error($term)) {echo $term->get_error_message(); }
701
+			else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); }
702 702
 		}
703 703
 		else
704 704
 		{
705
-			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
705
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
706 706
 		}
707 707
 		return $term['term_id'];
708 708
 	}
@@ -710,18 +710,18 @@  discard block
 block discarded – undo
710 710
 	/**
711 711
 	 * set_taxonomy with some terms
712 712
 	 */
713
-	public function taxonomy_checkboxes($taxonomy=false,$selected=array()) {
713
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
714 714
 		$return = '';
715
-		if(false !== $taxonomy){
715
+		if (false !== $taxonomy) {
716 716
 			$return .= '<ul>';
717
-			$terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false));
717
+			$terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false));
718 718
 
719
-			if(!is_wp_error($terms)){
720
-				foreach($terms as $term){
721
-					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
719
+			if (!is_wp_error($terms)) {
720
+				foreach ($terms as $term) {
721
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
722 722
 				}
723
-			}else{
724
-				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
723
+			}else {
724
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
725 725
 			}
726 726
 			$return .= '</ul>';
727 727
 		}
@@ -732,53 +732,53 @@  discard block
 block discarded – undo
732 732
 	/**
733 733
 	 * Saves the longitude and lattitude, as well as sets the map marker.
734 734
 	 */
735
-	public function set_map_data($data,$id,$zoom = '10') {
735
+	public function set_map_data($data, $id, $zoom = '10') {
736 736
 		$longitude = $latitude = $address = false;
737 737
 
738
-		if(isset($data[0]['position'])){
738
+		if (isset($data[0]['position'])) {
739 739
 
740
-			if(isset($data[0]['position']['driving_latitude'])){
740
+			if (isset($data[0]['position']['driving_latitude'])) {
741 741
 				$latitude = $data[0]['position']['driving_latitude'];
742
-			}elseif(isset($data[0]['position']['latitude'])){
742
+			}elseif (isset($data[0]['position']['latitude'])) {
743 743
 				$latitude = $data[0]['position']['latitude'];
744 744
 			}
745 745
 
746
-			if(isset($data[0]['position']['driving_longitude'])){
746
+			if (isset($data[0]['position']['driving_longitude'])) {
747 747
 				$longitude = $data[0]['position']['driving_longitude'];
748
-			}elseif(isset($data[0]['position']['longitude'])){
748
+			}elseif (isset($data[0]['position']['longitude'])) {
749 749
 				$longitude = $data[0]['position']['longitude'];
750 750
 			}
751 751
 
752 752
 		}
753
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
754
-			if(isset($data[0]['content']['contact_information']['address'])){
753
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
754
+			if (isset($data[0]['content']['contact_information']['address'])) {
755 755
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
756 756
 
757
-				$address = explode("\n",$address);
758
-				foreach($address as $bitkey => $bit){
757
+				$address = explode("\n", $address);
758
+				foreach ($address as $bitkey => $bit) {
759 759
 					$bit = ltrim(rtrim($bit));
760
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
760
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
761 761
 						unset($address[$bitkey]);
762 762
 					}
763 763
 				}
764
-				$address = implode(', ',$address);
764
+				$address = implode(', ', $address);
765 765
 				$address = str_replace(', , ', ', ', $address);
766 766
 			}
767 767
 		}
768 768
 
769
-		if(false !== $longitude){
769
+		if (false !== $longitude) {
770 770
 			$location_data = array(
771
-				'address'	=>	(string)$address,
772
-				'lat'		=>	(string)$latitude,
773
-				'long'		=>	(string)$longitude,
774
-				'zoom'		=>	(string)$zoom,
771
+				'address'	=>	(string) $address,
772
+				'lat'		=>	(string) $latitude,
773
+				'long'		=>	(string) $longitude,
774
+				'zoom'		=>	(string) $zoom,
775 775
 				'elevation'	=>	'',
776 776
 			);
777
-			if(false !== $id && '0' !== $id){
778
-				$prev = get_post_meta($id,'location',true);
779
-				update_post_meta($id,'location',$location_data,$prev);
780
-			}else{
781
-				add_post_meta($id,'location',$location_data,true);
777
+			if (false !== $id && '0' !== $id) {
778
+				$prev = get_post_meta($id, 'location', true);
779
+				update_post_meta($id, 'location', $location_data, $prev);
780
+			}else {
781
+				add_post_meta($id, 'location', $location_data, true);
782 782
 			}
783 783
 		}
784 784
 	}
@@ -788,16 +788,16 @@  discard block
 block discarded – undo
788 788
 	/**
789 789
 	 * Creates the main gallery data
790 790
 	 */
791
-	public function set_featured_image($data,$id) {
792
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
793
-			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
791
+	public function set_featured_image($data, $id) {
792
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
793
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id);
794 794
 
795
-			if(false !== $this->featured_image){
796
-				delete_post_meta($id,'_thumbnail_id');
797
-				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
795
+			if (false !== $this->featured_image) {
796
+				delete_post_meta($id, '_thumbnail_id');
797
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
798 798
 
799
-				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
800
-					add_post_meta($id,'gallery',$this->featured_image,false);
799
+				if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) {
800
+					add_post_meta($id, 'gallery', $this->featured_image, false);
801 801
 					$this->gallery_meta[] = $this->featured_image;
802 802
 				}
803 803
 			}
@@ -807,17 +807,17 @@  discard block
 block discarded – undo
807 807
 	/**
808 808
 	 * Sets a banner image
809 809
 	 */
810
-	public function set_banner_image($data,$id) {
811
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
812
-			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
810
+	public function set_banner_image($data, $id) {
811
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
812
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1], $id, array('width'=>'1920', 'height'=>'800', 'cropping'=>'c'));
813 813
 
814
-			if(false !== $this->banner_image){
815
-				delete_post_meta($id,'image_group');
814
+			if (false !== $this->banner_image) {
815
+				delete_post_meta($id, 'image_group');
816 816
 				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
817
-				add_post_meta($id,'image_group',$new_banner,true);
817
+				add_post_meta($id, 'image_group', $new_banner, true);
818 818
 
819
-				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
820
-					add_post_meta($id,'gallery',$this->banner_image,false);
819
+				if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) {
820
+					add_post_meta($id, 'gallery', $this->banner_image, false);
821 821
 					$this->gallery_meta[] = $this->banner_image;
822 822
 				}
823 823
 			}
@@ -827,24 +827,24 @@  discard block
 block discarded – undo
827 827
 	/**
828 828
 	 * Creates the main gallery data
829 829
 	 */
830
-	public function create_main_gallery($data,$id) {
830
+	public function create_main_gallery($data, $id) {
831 831
 
832
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
832
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
833 833
 			$counter = 0;
834
-			foreach($data[0]['content']['images'] as $image_data){
835
-				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
836
-				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
834
+			foreach ($data[0]['content']['images'] as $image_data) {
835
+				if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; }
836
+				if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; }
837 837
 
838
-				$this->gallery_meta[] = $this->attach_image($image_data,$id);
838
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
839 839
 				$counter++;
840 840
 			}
841 841
 
842
-			if(!empty($this->gallery_meta)){
843
-				delete_post_meta($id,'gallery');
842
+			if (!empty($this->gallery_meta)) {
843
+				delete_post_meta($id, 'gallery');
844 844
 				$this->gallery_meta = array_unique($this->gallery_meta);
845
-				foreach($this->gallery_meta as $gallery_id){
846
-					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
847
-						add_post_meta($id,'gallery',$gallery_id,false);
845
+				foreach ($this->gallery_meta as $gallery_id) {
846
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
847
+						add_post_meta($id, 'gallery', $gallery_id, false);
848 848
 					}
849 849
 				}
850 850
 			}
@@ -854,27 +854,27 @@  discard block
 block discarded – undo
854 854
 	/**
855 855
 	 * search_form
856 856
 	 */
857
-	public function get_scaling_url($args=array()) {
857
+	public function get_scaling_url($args = array()) {
858 858
 
859 859
 		$defaults = array(
860 860
 			'width' => '640',
861 861
 			'height' => '480',
862 862
 			'cropping' => 'c'
863 863
 		);
864
-		if(false !== $this->options){
865
-			if(isset($this->options['width']) && '' !== $this->options['width']){
864
+		if (false !== $this->options) {
865
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
866 866
 				$defaults['width'] = $this->options['width'];
867 867
 			}
868 868
 
869
-			if(isset($this->options['height']) && '' !== $this->options['height']){
869
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
870 870
 				$defaults['height'] = $this->options['height'];
871 871
 			}
872 872
 
873
-			if(isset($this->options['cropping']) && '' !== $this->options['cropping']){
873
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
874 874
 				$defaults['cropping'] = $this->options['cropping'];
875 875
 			}
876 876
 		}
877
-		$args = wp_parse_args($args,$defaults);
877
+		$args = wp_parse_args($args, $defaults);
878 878
 
879 879
 		$cropping = $args['cropping'];
880 880
 		$width = $args['width'];
@@ -887,40 +887,40 @@  discard block
 block discarded – undo
887 887
 	/**
888 888
 	 * Attaches 1 image
889 889
 	 */
890
-	public function attach_image($v=false,$parent_id,$image_sizes=false){
891
-		if(false !== $v){
892
-			$temp_fragment = explode('/',$v['url_fragment']);
893
-			$url_filename = $temp_fragment[count($temp_fragment)-1];
894
-			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
895
-
896
-			if(in_array($url_filename,$this->found_attachments)){
897
-				return array_search($url_filename,$this->found_attachments);
890
+	public function attach_image($v = false, $parent_id, $image_sizes = false) {
891
+		if (false !== $v) {
892
+			$temp_fragment = explode('/', $v['url_fragment']);
893
+			$url_filename = $temp_fragment[count($temp_fragment) - 1];
894
+			$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
895
+
896
+			if (in_array($url_filename, $this->found_attachments)) {
897
+				return array_search($url_filename, $this->found_attachments);
898 898
 			}
899 899
 
900
-			$postdata=array();
901
-			if(empty($v['label']))
900
+			$postdata = array();
901
+			if (empty($v['label']))
902 902
 			{
903
-				$v['label']='';
903
+				$v['label'] = '';
904 904
 			}
905
-			if(!empty($v['description']))
905
+			if (!empty($v['description']))
906 906
 			{
907
-				$desc=wp_strip_all_tags($v['description']);
908
-				$posdata=array('post_excerpt'=>$desc);
907
+				$desc = wp_strip_all_tags($v['description']);
908
+				$posdata = array('post_excerpt'=>$desc);
909 909
 			}
910
-			if(!empty($v['section']))
910
+			if (!empty($v['section']))
911 911
 			{
912
-				$desc=wp_strip_all_tags($v['section']);
913
-				$posdata=array('post_excerpt'=>$desc);
912
+				$desc = wp_strip_all_tags($v['section']);
913
+				$posdata = array('post_excerpt'=>$desc);
914 914
 			}
915 915
 
916
-			$attachID=NULL;
916
+			$attachID = NULL;
917 917
 			//Resizor - add option to setting if required
918
-			$fragment = str_replace(' ','%20',$v['url_fragment']);
918
+			$fragment = str_replace(' ', '%20', $v['url_fragment']);
919 919
 			$url = $this->get_scaling_url($image_sizes).$fragment;
920
-			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
920
+			$attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
921 921
 
922 922
 			//echo($attachID.' add image');
923
-			if($attachID!=NULL)
923
+			if ($attachID != NULL)
924 924
 			{
925 925
 				return $attachID;
926 926
 			}
@@ -928,13 +928,13 @@  discard block
 block discarded – undo
928 928
 		return 	false;
929 929
 	}
930 930
 
931
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
931
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
932 932
 
933
-		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
933
+		if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
934 934
 
935
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
936
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
937
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
935
+		require_once(ABSPATH.'wp-admin/includes/file.php');
936
+		require_once(ABSPATH.'wp-admin/includes/media.php');
937
+		require_once(ABSPATH.'wp-admin/includes/image.php');
938 938
 		// Download file to temp location, returns full server path to temp file
939 939
 		//$tmp = download_url( $url );
940 940
 
@@ -943,53 +943,53 @@  discard block
 block discarded – undo
943 943
 
944 944
 		$image = file_get_contents($url);
945 945
 		file_put_contents($tmp, $image);
946
-		chmod($tmp,'777');
946
+		chmod($tmp, '777');
947 947
 
948
-		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
948
+		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
949 949
 		$url_filename = basename($matches[0]);
950
-		$url_filename=str_replace('%20','_',$url_filename);
950
+		$url_filename = str_replace('%20', '_', $url_filename);
951 951
 		// extract filename from url for title
952
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
952
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
953 953
 
954 954
 		// override filename if given, reconstruct server path
955
-		if ( !empty( $filename ) && " " != $filename )
955
+		if (!empty($filename) && " " != $filename)
956 956
 		{
957 957
 			$filename = sanitize_file_name($filename);
958
-			$tmppath = pathinfo( $tmp );
958
+			$tmppath = pathinfo($tmp);
959 959
 
960 960
 			$extension = '';
961
-			if(isset($tmppath['extension'])){
961
+			if (isset($tmppath['extension'])) {
962 962
 				$extension = $tmppath['extension'];
963 963
 			}
964 964
 
965
-			$new = $tmppath['dirname'] . "/". $filename . "." . $extension;
966
-			rename($tmp, $new);                                                                 // renames temp file on server
967
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
965
+			$new = $tmppath['dirname']."/".$filename.".".$extension;
966
+			rename($tmp, $new); // renames temp file on server
967
+			$tmp = $new; // push new filename (in path) to be used in file array later
968 968
 		}
969 969
 
970 970
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
971
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
971
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
972 972
 
973
-		if ( !empty( $filename) && " " != $filename )
973
+		if (!empty($filename) && " " != $filename)
974 974
 		{
975
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
975
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
976 976
 		}
977 977
 		else
978 978
 		{
979
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
979
+			$file_array['name'] = $url_filename; // just use original URL filename
980 980
 		}
981 981
 
982 982
 		// set additional wp_posts columns
983
-		if ( empty( $post_data['post_title'] ) )
983
+		if (empty($post_data['post_title']))
984 984
 		{
985 985
 
986
-			$url_filename=str_replace('%20',' ',$url_filename);
986
+			$url_filename = str_replace('%20', ' ', $url_filename);
987 987
 
988
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
988
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
989 989
 		}
990 990
 
991 991
 		// make sure gets tied to parent
992
-		if ( empty( $post_data['post_parent'] ) )
992
+		if (empty($post_data['post_parent']))
993 993
 		{
994 994
 			$post_data['post_parent'] = $post_id;
995 995
 		}
@@ -997,12 +997,12 @@  discard block
 block discarded – undo
997 997
 		// required libraries for media_handle_sideload
998 998
 
999 999
 		// do the validation and storage stuff
1000
-		$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
1000
+		$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
1001 1001
 
1002 1002
 		// If error storing permanently, unlink
1003
-		if ( is_wp_error($att_id) )
1003
+		if (is_wp_error($att_id))
1004 1004
 		{
1005
-			unlink($file_array['tmp_name']);   // clean up
1005
+			unlink($file_array['tmp_name']); // clean up
1006 1006
 			return false; // output wp_error
1007 1007
 			//return $att_id; // output wp_error
1008 1008
 		}
@@ -1030,24 +1030,24 @@  discard block
 block discarded – undo
1030 1030
 	/**
1031 1031
 	 * Formats the row for the completed list.
1032 1032
 	 */
1033
-	public function format_completed_row($response){
1033
+	public function format_completed_row($response) {
1034 1034
 		echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>';
1035 1035
 	}
1036 1036
 
1037 1037
 	/**
1038 1038
 	 * Does a multine search
1039 1039
 	 */
1040
-	public function multineedle_stripos($haystack, $needles, $offset=0) {
1040
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1041 1041
 		$found = false;
1042 1042
 		$needle_count = count($needles);
1043
-		foreach($needles as $needle) {
1044
-			if(false !== stripos($haystack, $needle, $offset)){
1043
+		foreach ($needles as $needle) {
1044
+			if (false !== stripos($haystack, $needle, $offset)) {
1045 1045
 				$found[] = true;
1046 1046
 			}
1047 1047
 		}
1048
-		if(false !== $found && $needle_count === count($found)){
1048
+		if (false !== $found && $needle_count === count($found)) {
1049 1049
 			return true;
1050
-		}else{
1050
+		}else {
1051 1051
 			return false;
1052 1052
 		}
1053 1053
 	}
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 	/**
1056 1056
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1057 1057
 	 */
1058
-	public function find_current_accommodation($post_type='accommodation') {
1058
+	public function find_current_accommodation($post_type = 'accommodation') {
1059 1059
 		global $wpdb;
1060 1060
 		$return = array();
1061 1061
 
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
 
1072 1072
 					LIMIT 0,500
1073 1073
 		");
1074
-		if(null !== $current_accommodation && !empty($current_accommodation)){
1075
-			foreach($current_accommodation as $accom){
1074
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1075
+			foreach ($current_accommodation as $accom) {
1076 1076
 				$return[$accom->meta_value] = $accom;
1077 1077
 			}
1078 1078
 		}
Please login to merge, or discard this patch.