Code Duplication    Length = 19-19 lines in 2 locations

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

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

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

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