Code Duplication    Length = 11-11 lines in 2 locations

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

@@ 158-168 (lines=11) @@
155
		// Permissions
156
		$capabilities = $this->get_current_user_capabilities( $post );
157
158
		switch ( $context ) {
159
		case 'edit' :
160
			if ( ! $capabilities['edit_post'] ) {
161
				return new WP_Error( 'unauthorized', 'User cannot edit post', 403 );
162
			}
163
			break;
164
		case 'display' :
165
			break;
166
		default :
167
			return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 );
168
		}
169
170
		$can_view = $this->user_can_view_post( $post->ID );
171
		if ( !$can_view || is_wp_error( $can_view ) ) {

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

@@ 150-160 (lines=11) @@
147
		// Permissions
148
		$capabilities = $this->get_current_user_capabilities( $post );
149
150
		switch ( $context ) {
151
		case 'edit' :
152
			if ( ! $capabilities['edit_post'] ) {
153
				return new WP_Error( 'unauthorized', 'User cannot edit post', 403 );
154
			}
155
			break;
156
		case 'display' :
157
			break;
158
		default :
159
			return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 );
160
		}
161
162
		$can_view = $this->user_can_view_post( $post->ID );
163
		if ( !$can_view || is_wp_error( $can_view ) ) {