Code Duplication    Length = 28-28 lines in 2 locations

classes/wordpress.php 2 locations

@@ 1870-1897 (lines=28) @@
1867
			$term = wp_insert_term( $name, $taxonomy, $args );
1868
		}
1869
1870
		if ( is_wp_error( $term ) ) {
1871
			$success = false;
1872
			$errors  = $term;
1873
		} else {
1874
			$term_id = $term[ "$id_field" ];
1875
			$success = true;
1876
			$errors  = array();
1877
			foreach ( $params as $key => $value ) {
1878
				$method  = $value['method_modify'];
1879
				$meta_id = $method( $term_id, $key, $value['value'] );
1880
				if ( false === $meta_id ) {
1881
					$success  = false;
1882
					$errors[] = array(
1883
						'message' => sprintf(
1884
							// translators: %1$s is a method name.
1885
							esc_html__( 'Tried to upsert meta with method %1$s.', 'object-sync-for-salesforce' ),
1886
							esc_html( $method )
1887
						),
1888
						'key'     => $key,
1889
						'value'   => $value,
1890
					);
1891
				}
1892
			}
1893
1894
			// Developers can use this hook to set any other term data.
1895
			do_action( $this->option_prefix . 'set_more_term_data', $term_id, $params, 'create' );
1896
1897
		}
1898
1899
		if ( is_wp_error( $term ) ) {
1900
			$success = false;
@@ 2087-2114 (lines=28) @@
2084
		}
2085
		$term = wp_update_term( $term_id, $taxonomy, $args );
2086
2087
		if ( is_wp_error( $term ) ) {
2088
			$success = false;
2089
			$errors  = $term;
2090
		} else {
2091
			$term_id = $term[ "$id_field" ];
2092
			$success = true;
2093
			$errors  = array();
2094
			foreach ( $params as $key => $value ) {
2095
				$method  = $value['method_modify'];
2096
				$meta_id = $method( $term_id, $key, $value['value'] );
2097
				if ( false === $meta_id ) {
2098
					$success  = false;
2099
					$errors[] = array(
2100
						'message' => sprintf(
2101
							// translators: %1$s is a method name.
2102
							esc_html__( 'Tried to update meta with method %1$s.', 'object-sync-for-salesforce' ),
2103
							esc_html( $method )
2104
						),
2105
						'key'     => $key,
2106
						'value'   => $value,
2107
					);
2108
				}
2109
			}
2110
2111
			// Developers can use this hook to set any other term data.
2112
			do_action( $this->option_prefix . 'set_more_term_data', $term_id, $params, 'update' );
2113
2114
		}
2115
2116
		if ( is_wp_error( $term ) ) {
2117
			$success = false;