Code Duplication    Length = 19-19 lines in 2 locations

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

@@ 723-741 (lines=19) @@
720
		return $featured_image_id;
721
	}
722
723
	private function parse_and_set_author( $author = null, $post_type = 'post' ) {
724
		if ( empty( $author ) || ! post_type_supports( $post_type, 'author' ) )
725
			return get_current_user_id();
726
727
		$author = (string) $author;
728
		if ( ctype_digit( $author ) ) {
729
			$_user = get_user_by( 'id', $author );
730
			if ( ! $_user || is_wp_error( $_user ) )
731
				return new WP_Error( 'invalid_author', 'Invalid author provided' );
732
733
			return $_user->ID;
734
		}
735
736
		$_user = get_user_by( 'login', $author );
737
		if ( ! $_user || is_wp_error( $_user ) )
738
			return new WP_Error( 'invalid_author', 'Invalid author provided' );
739
740
		return $_user->ID;
741
	}
742
}
743

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

@@ 789-807 (lines=19) @@
786
		return $featured_image_id;
787
	}
788
789
	protected function parse_and_set_author( $author = null, $post_type = 'post' ) {
790
		if ( empty( $author ) || ! post_type_supports( $post_type, 'author' ) )
791
			return get_current_user_id();
792
793
		$author = (string) $author;
794
		if ( ctype_digit( $author ) ) {
795
			$_user = get_user_by( 'id', $author );
796
			if ( ! $_user || is_wp_error( $_user ) )
797
				return new WP_Error( 'invalid_author', 'Invalid author provided' );
798
799
			return $_user->ID;
800
		}
801
802
		$_user = get_user_by( 'login', $author );
803
		if ( ! $_user || is_wp_error( $_user ) )
804
			return new WP_Error( 'invalid_author', 'Invalid author provided' );
805
806
		return $_user->ID;
807
	}
808
809
	protected function should_load_theme_functions( $post_id = null ) {
810
		if ( empty( $post_id ) ) {