Code Duplication    Length = 29-29 lines in 2 locations

classes/class-wetu-importer-accommodation.php 1 location

@@ 537-565 (lines=29) @@
534
			$post['post_excerpt'] = $data_post_excerpt;
535
		}
536
537
		if ( false !== $id && '0' !== $id ) {
538
			$post['ID'] = $id;
539
540
			if ( isset( $data[0]['name'] ) ) {
541
				$post['post_title'] = $data[0]['name'];
542
				$post['post_status'] = 'publish';
543
				$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ),$id, 'draft', 'accommodation', 0 );
544
			}
545
546
			$id = wp_update_post( $post );
547
			$prev_date = get_post_meta( $id,'lsx_wetu_modified_date', true );
548
			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
549
		} else {
550
			//Set the name
551
			if ( isset( $data[0]['name'] ) ) {
552
				$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ),$id, 'draft', 'accommodation', 0 );
553
			}
554
555
			$post['post_name'] = $post_name;
556
			$post['post_title'] = $data[0]['name'];
557
			$post['post_status'] = 'publish';
558
			$id = wp_insert_post( $post );
559
560
			//Save the WETU ID and the Last date it was modified.
561
			if ( false !== $id ) {
562
				add_post_meta( $id,'lsx_wetu_id',$wetu_id );
563
				add_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data[0]['last_modified'] ) );
564
			}
565
		}
566
567
		//Setup some default for use in the import
568
		if ( false !== $importable_content && (in_array( 'gallery',$importable_content ) || in_array( 'banner_image',$importable_content ) || in_array( 'featured_image',$importable_content )) ) {

classes/class-wetu-importer-destination.php 1 location

@@ 584-612 (lines=29) @@
581
				}
582
			}
583
584
			if ( false !== $id && '0' !== $id ) {
585
				$post['ID'] = $id;
586
587
				if ( isset( $data[0]['name'] ) ) {
588
					$post['post_title'] = $data[0]['name'];
589
					$post['post_status'] = 'publish';
590
					$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
591
				}
592
593
				$id = wp_update_post( $post );
594
				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
595
				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
596
			} else {
597
				//Set the name
598
				if ( isset( $data[0]['name'] ) ) {
599
					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
600
				}
601
602
				$post['post_name'] = $post_name;
603
				$post['post_title'] = $data[0]['name'];
604
				$post['post_status'] = 'publish';
605
				$id = wp_insert_post( $post );
606
607
				//Save the WETU ID and the Last date it was modified.
608
				if ( false !== $id ) {
609
					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
610
					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
611
				}
612
			}
613
614
			$this->find_attachments( $id );
615