protected function handle_featured_media( $featured_media, $post_id ) {

		$featured_media = (int) $featured_media;
		if ( $featured_media ) {
			$result = set_post_thumbnail( $post_id, $featured_media );
			if ( $result ) {
				return true;
			} else {
				return new WP_Error( 'rest_invalid_featured_media', __( 'Invalid featured media id.' ), array( 'status' => 400 ) );
			}
		} else {
			return delete_post_thumbnail( $post_id );
		}

	}
protected function handle_featured_media( $featured_media, $post_id ) {

		$featured_media = (int) $featured_media;
		if ( $featured_media ) {
			$result = set_post_thumbnail( $post_id, $featured_media );
			if ( $result ) {
				return true;
			} else {
				return new WP_Error( 'rest_invalid_featured_media', __( 'Invalid featured media id.' ), array( 'status' => 400 ) );
			}
		} else {
			return delete_post_thumbnail( $post_id );
		}

	}
protected function handle_featured_media ( $ featured_media , $ post_id ) { $ featured_media = ( int ) $ featured_media ; if ( $ featured_media ) { $ result = set_post_thumbnail ( $ post_id , $ featured_media ) ; if ( $ result ) { return true ; } else { return new WP_Error ( 'rest_invalid_featured_media' , __ ( 'Invalid featured media id.' ) , array ( 'status' => 400 ) ) ; } } else { return delete_post_thumbnail ( $ post_id ) ; } }
Determine the featured media based on a request param.

@param int $featured_media Featured Media ID.
@param int $post_id        Post ID.
@return bool|WP_Error
Determine the featured media based on a request param .