Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/19/2022 09:21:45 PM (3 years ago)
Author:
imath
Message:

Make it possible to disable Avatar history & richer logging activities

Advanced users wishing to:

  1. disable the Avatar history feature, can do so returning true when filtering 'bp_disable_avatar_history',
  2. prevent one or more logging activity types to have a richer output, can return an array of the allowed activity types (or an empty array to completely disable the feature) when filtering 'bp_activity_get_types_supporting_generated_content'.

Props sbrajesh, oztaser

Fixes #8617

File:
1 edited

Legend:

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

    r13181 r13215  
    14631463            // Set generated content properties.
    14641464            if ( 'new_avatar' === $activity_type ) {
    1465                 $avatars = bp_avatar_get_version( $user_id, 'user', bp_get_activity_date_recorded() );
    1466 
    1467                 if ( $avatars && 1 === count( $avatars ) ) {
    1468                     $avatar            = reset( $avatars );
    1469                     $historical_avatar = trailingslashit( $avatar->parent_dir_url ) . $avatar->name;
    1470 
    1471                     // Add historical avatar to the current activity.
     1465                $avatars = array();
     1466
     1467                // Use the avatar history to display the avatar that was in use at the time the activity was posted.
     1468                if ( ! bp_avatar_history_is_disabled() ) {
     1469                    $avatars = bp_avatar_get_version( $user_id, 'user', bp_get_activity_date_recorded() );
     1470
     1471                    if ( $avatars && 1 === count( $avatars ) ) {
     1472                        $avatar            = reset( $avatars );
     1473                        $historical_avatar = trailingslashit( $avatar->parent_dir_url ) . $avatar->name;
     1474
     1475                        // Add historical avatar to the current activity.
     1476                        $generated_content->user_profile_photo = array(
     1477                            'value'             => $historical_avatar,
     1478                            'sanitize_callback' => 'esc_url',
     1479                        );
     1480                    }
     1481
     1482                    // Otherwise use the current/latest avatar.
     1483                } else {
    14721484                    $generated_content->user_profile_photo = array(
    1473                         'value'             => $historical_avatar,
     1485                        'value'             => bp_core_fetch_avatar(
     1486                            array(
     1487                                'item_id' => $user_id,
     1488                                'object'  => 'user',
     1489                                'type'    => 'full',
     1490                                'width'   => bp_core_avatar_full_width(),
     1491                                'height'  => bp_core_avatar_full_height(),
     1492                                'html'    => false,
     1493                            )
     1494                        ),
    14741495                        'sanitize_callback' => 'esc_url',
    14751496                    );
    1476 
    1477                     // Do not use a generated content.
    1478                 } else {
    1479                     return false;
    14801497                }
    14811498            }
Note: See TracChangeset for help on using the changeset viewer.