Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/25/2015 08:37:51 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Members: Improve logged-in and displayed user avatar functions:

  • Remove extract() usages
  • Pass $r and $args into filters
  • Pass $r into bp_core_fetch_avatar() enabling interaction with other parameter arguments

Fixes #6392.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-template.php

    r9803 r9804  
    14371437        function bp_get_loggedin_user_avatar( $args = '' ) {
    14381438
    1439                 $defaults = array(
    1440                         'type'   => 'thumb',
    1441                         'width'  => false,
    1442                         'height' => false,
    1443                         'html'   => true,
    1444                         'alt'    => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
    1445                 );
    1446 
    1447                 $r = wp_parse_args( $args, $defaults );
    1448                 extract( $r, EXTR_SKIP );
     1439                $r = wp_parse_args( $args, array(
     1440                        'item_id' => bp_loggedin_user_id(),
     1441                        'type'    => 'thumb',
     1442                        'width'   => false,
     1443                        'height'  => false,
     1444                        'html'    => true,
     1445                        'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
     1446                ) );
    14491447
    14501448                /**
    … …  
    14551453                 * @param string $value User avatar string.
    14561454                 */
    1457                 return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => bp_loggedin_user_id(), 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
     1455                return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( $r ), $r, $args );
    14581456        }
    14591457
    … …  
    14861484        function bp_get_displayed_user_avatar( $args = '' ) {
    14871485
    1488                 $defaults = array(
    1489                         'type'   => 'thumb',
    1490                         'width'  => false,
    1491                         'height' => false,
    1492                         'html'   => true,
    1493                         'alt'    => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
    1494                 );
    1495 
    1496                 $r = wp_parse_args( $args, $defaults );
    1497                 extract( $r, EXTR_SKIP );
     1486                $r = wp_parse_args( $args, array(
     1487                        'item_id' => bp_displayed_user_id(),
     1488                        'type'    => 'thumb',
     1489                        'width'   => false,
     1490                        'height'  => false,
     1491                        'html'    => true,
     1492                        'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
     1493                ) );
    14981494
    14991495                /**
    … …  
    15041500                 * @param string $value User avatar string.
    15051501                 */
    1506                 return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => bp_displayed_user_id(), 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
     1502                return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( $r ), $r, $args );
    15071503        }
    15081504
Note: See TracChangeset for help on using the changeset viewer.