Code Duplication    Length = 12-12 lines in 3 locations

classes/admin.php 3 locations

@@ 1433-1444 (lines=12) @@
1430
				$id     = esc_attr( $post_data['id'] );
1431
				$result = $this->mappings->update_fieldmap( $post_data, $wordpress_fields, $salesforce_fields, $id );
1432
			}
1433
			if ( false === $result ) { // if the database didn't save, it's still an error
1434
				$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1435
				if ( '' !== $cachekey ) {
1436
					$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&transient=' . $cachekey;
1437
				}
1438
			} else {
1439
				if ( isset( $post_data['transient'] ) ) { // there was previously an error saved. can delete it now.
1440
					$this->sfwp_transients->delete( esc_attr( $post_data['map_transient'] ) );
1441
				}
1442
				// then send the user to the list of fieldmaps
1443
				$url = esc_url_raw( $post_data['redirect_url_success'] );
1444
			}
1445
		}
1446
		wp_safe_redirect( $url );
1447
		exit();
@@ 1499-1510 (lines=12) @@
1496
				$id     = esc_attr( $post_data['id'] );
1497
				$result = $this->mappings->update_object_map( $post_data, $id );
1498
			}
1499
			if ( false === $result ) { // if the database didn't save, it's still an error
1500
				$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1501
				if ( '' !== $cachekey ) {
1502
					$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&map_transient=' . $cachekey;
1503
				}
1504
			} else {
1505
				if ( isset( $post_data['map_transient'] ) ) { // there was previously an error saved. can delete it now.
1506
					$this->sfwp_transients->delete( esc_attr( $post_data['map_transient'] ) );
1507
				}
1508
				// then send the user to the success redirect url
1509
				$url = esc_url_raw( $post_data['redirect_url_success'] );
1510
			}
1511
		}
1512
		wp_safe_redirect( $url );
1513
		exit();
@@ 1552-1563 (lines=12) @@
1549
					$url = esc_url_raw( $post_data['redirect_url_success'] );
1550
				}
1551
1552
				if ( false === $result ) { // if the database didn't save, it's still an error
1553
					$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1554
					if ( '' !== $cachekey ) {
1555
						$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&mapping_error_transient=' . $cachekey;
1556
					}
1557
				} else {
1558
					if ( isset( $post_data['mapping_error_transient'] ) ) { // there was previously an error saved. can delete it now.
1559
						$this->sfwp_transients->delete( esc_attr( $post_data['mapping_error_transient'] ) );
1560
					}
1561
					// then send the user to the list of fieldmaps
1562
					$url = esc_url_raw( $post_data['redirect_url_success'] );
1563
				}
1564
			}
1565
			wp_safe_redirect( $url );
1566
			exit();