Code Duplication    Length = 29-29 lines in 2 locations

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

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

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

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