Code Duplication    Length = 19-19 lines in 2 locations

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

@@ 648-666 (lines=19) @@
645
	}
646
647
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
648
	function restore_post( $path, $blog_id, $post_id ) {
649
		$args  = $this->query_args();
650
		$post = get_post( $post_id );
651
652
		if ( !$post || is_wp_error( $post ) ) {
653
			return new WP_Error( 'unknown_post', 'Unknown post', 404 );
654
		}
655
656
		if ( !current_user_can( 'delete_post', $post->ID ) ) {
657
			return new WP_Error( 'unauthorized', 'User cannot restore trashed posts', 403 );
658
		}
659
660
		/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
661
		do_action( 'wpcom_json_api_objects', 'posts' );
662
663
		wp_untrash_post( $post->ID );
664
665
		return $this->get_post_by( 'ID', $post->ID, $args['context'] );
666
	}
667
668
	private function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) {
669
		if ( $delete_featured_image ) {

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

@@ 659-677 (lines=19) @@
656
	}
657
658
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
659
	function restore_post( $path, $blog_id, $post_id ) {
660
		$args  = $this->query_args();
661
		$post = get_post( $post_id );
662
663
		if ( !$post || is_wp_error( $post ) ) {
664
			return new WP_Error( 'unknown_post', 'Unknown post', 404 );
665
		}
666
667
		if ( !current_user_can( 'delete_post', $post->ID ) ) {
668
			return new WP_Error( 'unauthorized', 'User cannot restore trashed posts', 403 );
669
		}
670
671
		/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
672
		do_action( 'wpcom_json_api_objects', 'posts' );
673
674
		wp_untrash_post( $post->ID );
675
676
		return $this->get_post_by( 'ID', $post->ID, $args['context'] );
677
	}
678
679
	protected function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) {
680
		if ( $delete_featured_image ) {