Code Duplication    Length = 19-19 lines in 2 locations

json-endpoints/class.wpcom-json-api-update-post-endpoint.php 1 location

@@ 869-887 (lines=19) @@
866
	}
867
868
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
869
	function restore_post( $path, $blog_id, $post_id ) {
870
		$args  = $this->query_args();
871
		$post = get_post( $post_id );
872
873
		if ( !$post || is_wp_error( $post ) ) {
874
			return new WP_Error( 'unknown_post', 'Unknown post', 404 );
875
		}
876
877
		if ( !current_user_can( 'delete_post', $post->ID ) ) {
878
			return new WP_Error( 'unauthorized', 'User cannot restore trashed posts', 403 );
879
		}
880
881
		/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
882
		do_action( 'wpcom_json_api_objects', 'posts' );
883
884
		wp_untrash_post( $post->ID );
885
886
		return $this->get_post_by( 'ID', $post->ID, $args['context'] );
887
	}
888
889
	private function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) {
890
		if ( $delete_featured_image ) {

json-endpoints/class.wpcom-json-api-update-post-v1-1-endpoint.php 1 location

@@ 937-955 (lines=19) @@
934
	}
935
936
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
937
	function restore_post( $path, $blog_id, $post_id ) {
938
		$args  = $this->query_args();
939
		$post = get_post( $post_id );
940
941
		if ( !$post || is_wp_error( $post ) ) {
942
			return new WP_Error( 'unknown_post', 'Unknown post', 404 );
943
		}
944
945
		if ( !current_user_can( 'delete_post', $post->ID ) ) {
946
			return new WP_Error( 'unauthorized', 'User cannot restore trashed posts', 403 );
947
		}
948
949
		/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
950
		do_action( 'wpcom_json_api_objects', 'posts' );
951
952
		wp_untrash_post( $post->ID );
953
954
		return $this->get_post_by( 'ID', $post->ID, $args['context'] );
955
	}
956
957
	protected function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) {
958
		if ( $delete_featured_image ) {