Changeset 3168
- Timestamp:
- 08/09/2010 09:53:49 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2/bp-activity/bp-activity-templatetags.php
r3145 r3168 395 395 } 396 396 397 /** 398 * bp_activity_avatar( $args ) 399 * 400 * Output the avatar of the user that performed the action 401 * 402 * @param array $args 403 */ 397 404 function bp_activity_avatar( $args = '' ) { 398 405 echo bp_get_activity_avatar( $args ); 399 406 } 407 /** 408 * bp_get_activity_avatar( $args ) 409 * 410 * Return the avatar of the user that performed the action 411 * 412 * @global array $bp 413 * @global object $activities_template 414 * @param array $args optional 415 * @return string 416 */ 400 417 function bp_get_activity_avatar( $args = '' ) { 401 418 global $bp, $activities_template; 402 419 403 420 $defaults = array( 404 'type' => 'thumb',405 'width' => 20,421 'type' => 'thumb', 422 'width' => 20, 406 423 'height' => 20, 407 'class' => 'avatar',408 'alt' => __( 'Avatar', 'buddypress' ),409 'email' => false424 'class' => 'avatar', 425 'alt' => __( 'Avatar', 'buddypress' ), 426 'email' => false 410 427 ); 411 428 … … 413 430 extract( $r, EXTR_SKIP ); 414 431 415 $item_id = false; 416 if ( (int)$activities_template->activity->user_id ) 417 $item_id = $activities_template->activity->user_id; 418 else if ( $activities_template->activity->item_id ) 419 $item_id = $activities_template->activity->item_id; 420 421 $object = 'user'; 422 if ( $bp->groups->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id ) 423 $object = 'group'; 424 if ( $bp->blogs->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id ) 425 $object = 'blog'; 426 427 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, $object ); 428 429 /* If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. */ 430 if ( 'user' == $object && empty($email) ) 432 // Primary activity avatar is always a user, but can be modified via a filter 433 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, 'user' ); 434 $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $activities_template->activity->user_id ); 435 436 // If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. 437 if ( 'user' == $object && empty( $email ) ) 431 438 $email = $activities_template->activity->user_email; 432 439 433 440 return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) ); 441 } 442 443 /** 444 * bp_activity_secondary_avatar( $args ) 445 * 446 * Output the avatar of the object that action was performed on 447 * 448 * @param array $args optional 449 */ 450 function bp_activity_secondary_avatar( $args = '' ) { 451 echo bp_get_activity_secondary_avatar( $args ); 452 } 453 /** 454 * bp_get_activity_secondary_avatar( $args ) 455 * 456 * Return the avatar of the object that action was performed on 457 * 458 * @global array $bp 459 * @global object $activities_template 460 * @param array $args optional 461 * @return string 462 */ 463 function bp_get_activity_secondary_avatar( $args = '' ) { 464 global $bp, $activities_template; 465 466 $defaults = array( 467 'type' => 'thumb', 468 'width' => 20, 469 'height' => 20, 470 'class' => 'avatar', 471 'alt' => __( 'Avatar', 'buddypress' ), 472 'email' => false 473 ); 474 475 $r = wp_parse_args( $args, $defaults ); 476 extract( $r, EXTR_SKIP ); 477 478 // Set item_id and object (default to user) 479 switch ( $activities_template->activity->component ) { 480 case $bp->groups->id : 481 $object = 'group'; 482 $item_id = $activities_template->activity->item_id; 483 break; 484 case $bp->blogs->id : 485 $object = 'blog'; 486 $item_id = $activities_template->activity->item_id; 487 break; 488 default : 489 $object = 'user'; 490 $item_id = $activities_template->activity->user_id; 491 break; 492 } 493 494 // Allow object and item_id to be filtered 495 $object = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object ); 496 $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id ); 497 498 // Used for any user to user activity 499 if ( 'user' == $object && empty( $email ) ) 500 $email = $activities_template->activity->user_email; 501 502 return apply_filters( 'bp_get_activity_secondary_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) ); 434 503 } 435 504
Note: See TracChangeset
for help on using the changeset viewer.