Code Duplication    Length = 11-11 lines in 2 locations

wp-admin/includes/ajax-actions.php 2 locations

@@ 2032-2042 (lines=11) @@
2029
2030
	if ( isset( $_REQUEST['post_id'] ) ) {
2031
		$post_id = $_REQUEST['post_id'];
2032
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
2033
			echo wp_json_encode( array(
2034
				'success' => false,
2035
				'data'    => array(
2036
					'message'  => __( "You don't have permission to attach files to this post." ),
2037
					'filename' => $_FILES['async-upload']['name'],
2038
				)
2039
			) );
2040
2041
			wp_die();
2042
		}
2043
	} else {
2044
		$post_id = null;
2045
	}
@@ 2052-2062 (lines=11) @@
2049
	// If the context is custom header or background, make sure the uploaded file is an image.
2050
	if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
2051
		$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] );
2052
		if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
2053
			echo wp_json_encode( array(
2054
				'success' => false,
2055
				'data'    => array(
2056
					'message'  => __( 'The uploaded file is not a valid image. Please try again.' ),
2057
					'filename' => $_FILES['async-upload']['name'],
2058
				)
2059
			) );
2060
2061
			wp_die();
2062
		}
2063
	}
2064
2065
	$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );