AnsPress_API::avatar( WP_REST_Request $request )

Description #

Callback for route /anspress/user/avatar/.

Parameters #

  • $request
    WP_REST_Request (Required) Request data.

Source #

File: includes/api.php

	public static function avatar( $request ) {
		$args = $request->get_query_params();
		if ( isset( $args['id'] ) ) {
			$size   = isset( $args['size'] ) ? (int) $args['size'] : 90;
			$avatar = get_avatar_url( (int) $args['id'], $size );
			return new WP_REST_Response( $avatar, 200 );
		}
		return new WP_Error( 'wrongData', __( 'Wrong data supplied', 'anspress-question-answer' ) );
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment