Code Duplication    Length = 27-27 lines in 3 locations

modules/post-by-email.php 3 locations

@@ 146-172 (lines=27) @@
143
		return $response;
144
	}
145
146
	function create_post_by_email_address() {
147
		Jetpack::load_xml_rpc_client();
148
		$xml = new Jetpack_IXR_Client( array(
149
			'user_id' => get_current_user_id(),
150
		) );
151
		$xml->query( 'jetpack.createPostByEmailAddress' );
152
153
		if ( $xml->isError() ) {
154
			echo json_encode( array(
155
				'response' => 'error',
156
				'message' => __( 'Unable to create your Post By Email address. Please try again later.', 'jetpack' )
157
			) );
158
			die();
159
		}
160
161
		$response = $xml->getResponse();
162
		if ( empty( $response ) ) {
163
			echo json_encode( array(
164
				'response' => 'error',
165
				'message' => __( 'Unable to create your Post By Email address. Please try again later.', 'jetpack' )
166
			) );
167
			die();
168
		}
169
170
		echo $response;
171
		die();
172
	}
173
174
	function regenerate_post_by_email_address() {
175
		Jetpack::load_xml_rpc_client();
@@ 174-200 (lines=27) @@
171
		die();
172
	}
173
174
	function regenerate_post_by_email_address() {
175
		Jetpack::load_xml_rpc_client();
176
		$xml = new Jetpack_IXR_Client( array(
177
			'user_id' => get_current_user_id(),
178
		) );
179
		$xml->query( 'jetpack.regeneratePostByEmailAddress' );
180
181
		if ( $xml->isError() ) {
182
			echo json_encode( array(
183
				'response' => 'error',
184
				'message' => __( 'Unable to regenerate your Post By Email address. Please try again later.', 'jetpack' )
185
			) );
186
			die();
187
		}
188
189
		$response = $xml->getResponse();
190
		if ( empty( $response ) ) {
191
			echo json_encode( array(
192
				'response' => 'error',
193
				'message' => __( 'Unable to regenerate your Post By Email address. Please try again later.', 'jetpack' )
194
			) );
195
			die();
196
		}
197
198
		echo $response;
199
		die();
200
	}
201
202
	function delete_post_by_email_address() {
203
		Jetpack::load_xml_rpc_client();
@@ 202-228 (lines=27) @@
199
		die();
200
	}
201
202
	function delete_post_by_email_address() {
203
		Jetpack::load_xml_rpc_client();
204
		$xml = new Jetpack_IXR_Client( array(
205
			'user_id' => get_current_user_id(),
206
		) );
207
		$xml->query( 'jetpack.deletePostByEmailAddress' );
208
209
		if ( $xml->isError() ) {
210
			echo json_encode( array(
211
				'response' => 'error',
212
				'message' => __( 'Unable to disable your Post By Email address. Please try again later.', 'jetpack' )
213
			) );
214
			die();
215
		}
216
217
		$response = $xml->getResponse();
218
		if ( empty( $response ) ) {
219
			echo json_encode( array(
220
				'response' => 'error',
221
				'message' => __( 'Unable to disable your Post By Email address. Please try again later.', 'jetpack' )
222
			) );
223
			die();
224
		}
225
226
		echo $response;
227
		die();
228
	}
229
}
230