Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/17/2013 02:20:38 AM (11 years ago)
Author:
boonebgorges
Message:

Pass more arguments through bp_get_message_thread_avatar()

Allowing more bp_core_fetch_avatar() arguments gives greater flexibility to
themers and plugin authors.

Fixes #4959

Props henrywright

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/bp-messages-template.php

    r7329 r7435  
    318318    }
    319319
    320 function bp_message_thread_avatar() {
    321     echo bp_get_message_thread_avatar();
    322 }
    323     function bp_get_message_thread_avatar() {
    324         global $messages_template;
    325 
    326         return apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array( 'item_id' => $messages_template->thread->last_sender_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname( $messages_template->thread->last_sender_id ) ) ) ) );
     320/**
     321 * Output the avatar for the last sender in the current message thread.
     322 *
     323 * @see bp_get_message_thread_avatar() for a description of arguments.
     324 *
     325 * @param array $args See {@link bp_get_message_thread_avatar()}.
     326 */
     327function bp_message_thread_avatar( $args = '' ) {
     328    echo bp_get_message_thread_avatar( $args );
     329}
     330    /**
     331     * Return the avatar for the last sender in the current message thread.
     332     *
     333     * @see bp_core_fetch_avatar() For a description of arguments and
     334     *      return values.
     335     *
     336     * @param array $args {
     337     *     Arguments are listed here with an explanation of their defaults.
     338     *     For more information about the arguments, see
     339     *     {@link bp_core_fetch_avatar()}.
     340     *     @type string $type Default: 'thumb'.
     341     *     @type int|bool $width Default: false.
     342     *     @type int|bool $height Default: false.
     343     *     @type string $class Default: 'avatar'.
     344     *     @type string|bool $id Default: false.
     345     *     @type string $alt Default: 'Profile picture of [display name]'.
     346     * }
     347     * @return User avatar string.
     348     */
     349    function bp_get_message_thread_avatar( $args = '' ) {
     350        global $messages_template;
     351
     352        $fullname = bp_core_get_user_displayname( $messages_template->thread->last_sender_id );
     353
     354        $defaults = array(
     355            'type'   => 'thumb',
     356            'width'  => false,
     357            'height' => false,
     358            'class'  => 'avatar',
     359            'id'     => false,
     360            'alt'    => sprintf( __( 'Profile picture of %s', 'buddypress' ), $fullname )
     361        );
     362
     363        $r = wp_parse_args( $args, $defaults );
     364        extract( $r, EXTR_SKIP );
     365
     366        return apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array( 'item_id' => $messages_template->thread->last_sender_id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) );
    327367    }
    328368
Note: See TracChangeset for help on using the changeset viewer.