get_avatar_url example


function rest_get_avatar_urls( $id_or_email ) {
    $avatar_sizes = rest_get_avatar_sizes();

    $urls = array();
    foreach ( $avatar_sizes as $size ) {
        $urls[ $size ] = get_avatar_url( $id_or_email, array( 'size' => $size ) );
    }

    return $urls;
}

/** * Retrieves the pixel sizes for avatars. * * @since 4.7.0 * * @return int[] List of pixel sizes for avatars. Default `[ 24, 48, 96 ]`. */
$avatar = apply_filters( 'pre_get_avatar', null, $id_or_email$args );

        if ( ! is_null( $avatar ) ) {
            /** This filter is documented in wp-includes/pluggable.php */
            return apply_filters( 'get_avatar', $avatar$id_or_email$args['size']$args['default']$args['alt']$args );
        }

        if ( ! $args['force_display'] && ! get_option( 'show_avatars' ) ) {
            return false;
        }

        $url2x = get_avatar_url( $id_or_emailarray_merge( $args, array( 'size' => $args['size'] * 2 ) ) );

        $args = get_avatar_data( $id_or_email$args );

        $url = $args['url'];

        if ( ! $url || is_wp_error( $url ) ) {
            return false;
        }

        $class = array( 'avatar', 'avatar-' . (int) $args['size'], 'photo' );

        


        $lock_user = get_userdata( $user_id );

        if ( ! $lock_user ) {
            return null;
        }

        return array(
            'id'     => $lock_user->ID,
            'name'   => $lock_user->display_name,
            'avatar' => get_avatar_url( $lock_user->ID, array( 'size' => 128 ) ),
        );
    }

    /** * Checks locked changeset with heartbeat API. * * @since 4.9.0 * * @param array $response The Heartbeat response. * @param array $data The $_POST data sent. * @param string $screen_id The screen id. * @return array The Heartbeat response. */
if ( $user_id ) {
                $user = get_userdata( $user_id );

                if ( $user && current_user_can( 'edit_post', $post_id ) ) {
                    $send = array(
                        'name' => $user->display_name,
                        /* translators: %s: User's display name. */
                        'text' => sprintf( __( '%s is currently editing' )$user->display_name ),
                    );

                    if ( get_option( 'show_avatars' ) ) {
                        $send['avatar_src']    = get_avatar_url( $user->ID, array( 'size' => 18 ) );
                        $send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) );
                    }

                    $checked[ $key ] = $send;
                }
            }
        }
    }

    if ( ! empty( $checked ) ) {
        $response['wp-check-locked-posts'] = $checked;
    }
$editor_settings['__unstableIsBlockBasedTheme']      = wp_is_block_theme();
    $editor_settings['localAutosaveInterval']            = 15;
    $editor_settings['disableLayoutStyles']              = current_theme_supports( 'disable-layout-styles' );
    $editor_settings['__experimentalDiscussionSettings'] = array(
        'commentOrder'         => get_option( 'comment_order' ),
        'commentsPerPage'      => get_option( 'comments_per_page' ),
        'defaultCommentsPage'  => get_option( 'default_comments_page' ),
        'pageComments'         => get_option( 'page_comments' ),
        'threadComments'       => get_option( 'thread_comments' ),
        'threadCommentsDepth'  => get_option( 'thread_comments_depth' ),
        'defaultCommentStatus' => get_option( 'default_comment_status' ),
        'avatarURL'            => get_avatar_url(
            '',
            array(
                'size'          => 96,
                'force_default' => true,
                'default'       => get_option( 'avatar_default' ),
            )
        ),
    );

    $post_content_block_attributes = wp_get_post_content_block_attributes();

    
$locked = false;

    /** This filter is documented in wp-admin/includes/post.php */
    if ( apply_filters( 'show_post_locked_dialog', true, $post$user_id ) ) {
        $locked = true;
    }

    $user_details = null;
    if ( $locked ) {
        $user         = get_userdata( $user_id );
        $user_details = array(
            'avatar' => get_avatar_url( $user_id, array( 'size' => 128 ) ),
            'name'   => $user->display_name,
        );
    }

    $lock_details = array(
        'isLocked' => $locked,
        'user'     => $user_details,
    );
} else {
    // Lock the post.     $active_post_lock = wp_set_post_lock( $post->ID );
    
Home | Imprint | This part of the site doesn't use cookies.