Code Duplication    Length = 29-29 lines in 2 locations

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

@@ 515-543 (lines=29) @@
512
			$post['post_excerpt'] = $data_post_excerpt;
513
		}
514
515
		if ( false !== $id && '0' !== $id ) {
516
			$post['ID'] = $id;
517
518
			if ( isset( $data[0]['name'] ) ) {
519
				$post['post_title'] = $data[0]['name'];
520
				$post['post_status'] = 'publish';
521
				$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
522
			}
523
524
			$id = wp_update_post( $post );
525
			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
526
			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
527
		} else {
528
			// Set the name.
529
			if ( isset( $data[0]['name'] ) ) {
530
				$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
531
			}
532
533
			$post['post_name']   = $post_name;
534
			$post['post_title']  = $data[0]['name'];
535
			$post['post_status'] = 'publish';
536
			$id                  = wp_insert_post( $post );
537
538
			// Save the WETU ID and the Last date it was modified.
539
			if ( false !== $id ) {
540
				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
541
				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
542
			}
543
		}
544
545
		// Setup some default for use in the import.
546
		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

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