Changeset 13215
- Timestamp:
- 01/19/2022 09:21:45 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r13181 r13215 633 633 634 634 /** 635 * Gets the list of activity types name supporting the requested feature. 636 * 637 * This function is still a WIP, please don't use it into your plugins or themes. 638 * 639 * @since 10.0.0 640 * 641 * @access private 642 * @todo `bp_activity_set_action()` should be improved to include a supports 643 * argument or best we should create a `bp_register_activity_type()` function 644 * to mimic the way WordPress registers post types. For now we'll use a non 645 * extendable workaround. 646 * 647 * @param string $feature The feature activity types should support. 648 * @return array The list of activity types name supporting the requested feature. 649 */ 650 function _bp_activity_get_types_by_support( $feature = 'generated-content' ) { 651 $activity_types = array(); 652 653 if ( 'generated-content' === $feature ) { 654 $activity_types = array( 'new_member', 'new_avatar' ); 655 656 if ( bp_is_active( 'friends' ) ) { 657 array_push( $activity_types, 'friendship_created' ); 658 } 659 660 if ( bp_is_active( 'groups' ) ) { 661 array_push( $activity_types, 'created_group', 'joined_group' ); 662 } 663 664 if ( bp_is_active( 'xprofile' ) ) { 665 array_push( $activity_types, 'updated_profile' ); 666 } 667 } 668 669 $filter_key = str_replace( '-', '_', $feature ); 670 671 /** 672 * Use this filter to add/remove activity types supporting the requested feature. 673 * 674 * The dynamic portion of the filter is the name of the requested feature where hyphens are 675 * replaced by underscores. Eg. use `bp_activity_get_types_supporting_generated_content` to 676 * edit the list of activities supporting the `generated-content` feature. 677 * 678 * @since 10.0.0 679 * 680 * @param array $activity_types The list of activity types name supporting the requested feature. 681 */ 682 return apply_filters( "bp_activity_get_types_supporting_{$filter_key}", $activity_types ); 683 } 684 685 /** 635 686 * Check if the *Post Type* activity supports a specific feature. 636 687 * … … 715 766 */ 716 767 case 'generated-content' : 717 /* 718 * @todo `bp_activity_set_action()` should be improved to include a supports 719 * argument or best we should create a `bp_register_activity_type()` function 720 * to mimic the way WordPress registers post types. For now we'll use a non 721 * extendable workaround. 722 */ 723 $activity_types = array( 'new_member', 'new_avatar' ); 724 725 if ( bp_is_active( 'friends' ) ) { 726 array_push( $activity_types, 'friendship_created' ); 727 } 728 729 if ( bp_is_active( 'groups' ) ) { 730 array_push( $activity_types, 'created_group', 'joined_group' ); 731 } 732 733 if ( bp_is_active( 'xprofile' ) ) { 734 array_push( $activity_types, 'updated_profile' ); 735 } 768 $activity_types = _bp_activity_get_types_by_support( 'generated-content' ); 736 769 737 770 $retval = in_array( $activity_type, $activity_types, true ); -
trunk/src/bp-activity/bp-activity-template.php
r13181 r13215 1463 1463 // Set generated content properties. 1464 1464 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 { 1472 1484 $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 ), 1474 1495 'sanitize_callback' => 'esc_url', 1475 1496 ); 1476 1477 // Do not use a generated content.1478 } else {1479 return false;1480 1497 } 1481 1498 } -
trunk/src/bp-core/bp-core-attachments.php
r13179 r13215 816 816 ); 817 817 818 if ( 'user' === $object ) { 818 // Add the recycle view if avatar history is enabled. 819 if ( 'user' === $object && ! bp_avatar_history_is_disabled() ) { 819 820 // Look inside history to see if the user previously uploaded avatars. 820 821 $avatars_history = bp_avatar_get_avatars_history( $item_id, $object ); -
trunk/src/bp-core/bp-core-avatars.php
r13178 r13215 2151 2151 2152 2152 /** 2153 * Informs about whether avatar history is disabled or not. 2154 * 2155 * @since 10.0.0 2156 * 2157 * @return bool True if avatar history is disabled. False otherwise. 2158 * Default: `false`. 2159 */ 2160 function bp_avatar_history_is_disabled() { 2161 /** 2162 * Filter here returning `true` to disable avatar history. 2163 * 2164 * @since 10.0.0 2165 * 2166 * @param bool $value True to disable avatar history. False otherwise. 2167 * Default: `false`. 2168 */ 2169 return apply_filters( 'bp_disable_avatar_history', false ); 2170 } 2171 2172 /** 2153 2173 * Get a specific version of an avatar from its history. 2154 2174 * -
trunk/src/bp-core/classes/class-bp-admin.php
r13209 r13215 907 907 printf( 908 908 /* translators: 1: heart dashicons. 2: BP Credits screen url. 3: number of BuddyPress contributors to this version. */ 909 _n( 'Built with %1$s by <a href="%2$s">%3$d volunteer</a>.', 'Built with %1$s by <a href="%2$s">%3$d volunteers</a>.', 3 8, 'buddypress' ),909 _n( 'Built with %1$s by <a href="%2$s">%3$d volunteer</a>.', 'Built with %1$s by <a href="%2$s">%3$d volunteers</a>.', 39, 'buddypress' ), 910 910 '<span class="dashicons dashicons-heart"></span>', 911 911 esc_url( bp_get_admin_url( 'admin.php?page=bp-credits' ) ), 912 number_format_i18n( 3 8)912 number_format_i18n( 39 ) 913 913 ); 914 914 ?> … … 1089 1089 <a href="https://profiles.wordpress.org/oztaser/">Adil Öztaşer (oztaser)</a>, 1090 1090 <a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>, 1091 <a href="https://profiles.wordpress.org/sbrajesh/">Brajesh Singh (sbrajesh)</a>, 1091 1092 <a href="https://profiles.wordpress.org/needle/">Christian Wach (needle)</a>, 1092 1093 <a href="https://profiles.wordpress.org/comminski/">comminski</a>, -
trunk/src/bp-core/classes/class-bp-attachment-avatar.php
r13175 r13215 247 247 } 248 248 249 // Delete the existing avatar files for the object. 250 $existing_avatar = bp_core_fetch_avatar( array( 251 'object' => $args['object'], 252 'item_id' => $args['item_id'], 253 'html' => false, 254 ) ); 249 // Get the existing avatar files for the object. 250 $existing_avatar = bp_core_fetch_avatar( 251 array( 252 'object' => $args['object'], 253 'item_id' => $args['item_id'], 254 'html' => false, 255 ) 256 ); 255 257 256 258 /** … … 259 261 */ 260 262 if ( ! empty( $existing_avatar ) && $existing_avatar !== $this->url . $relative_path ) { 261 // Add a new revision for the existing avatar. 262 $avatars = bp_attachments_list_directory_files( $avatar_folder_dir ); 263 264 if ( $avatars ) { 265 foreach ( $avatars as $avatar_file ) { 266 if ( ! isset( $avatar_file->name, $avatar_file->id, $avatar_file->path ) ) { 267 continue; 268 } 269 270 $is_full = preg_match( "/-bpfull/", $avatar_file->name ); 271 $is_thumb = preg_match( "/-bpthumb/", $avatar_file->name ); 272 273 if ( $is_full || $is_thumb ) { 274 $revision = $this->add_revision( 275 'avatar', 276 array( 277 'file_abspath' => $avatar_file->path, 278 'file_id' => $avatar_file->id, 279 ) 280 ); 281 282 if ( is_wp_error( $revision ) ) { 283 error_log( $revision->get_error_message() ); 263 // Avatar history is disabled, simply delete the existing avatar files. 264 if ( bp_avatar_history_is_disabled() ) { 265 bp_core_delete_existing_avatar( 266 array( 267 'object' => $args['object'], 268 'item_id' => $args['item_id'], 269 'avatar_path' => $avatar_folder_dir, 270 ) 271 ); 272 } else { 273 // Add a new revision for the existing avatar. 274 $avatars = bp_attachments_list_directory_files( $avatar_folder_dir ); 275 276 if ( $avatars ) { 277 foreach ( $avatars as $avatar_file ) { 278 if ( ! isset( $avatar_file->name, $avatar_file->id, $avatar_file->path ) ) { 279 continue; 280 } 281 282 $is_full = preg_match( "/-bpfull/", $avatar_file->name ); 283 $is_thumb = preg_match( "/-bpthumb/", $avatar_file->name ); 284 285 if ( $is_full || $is_thumb ) { 286 $revision = $this->add_revision( 287 'avatar', 288 array( 289 'file_abspath' => $avatar_file->path, 290 'file_id' => $avatar_file->id, 291 ) 292 ); 293 294 if ( is_wp_error( $revision ) ) { 295 error_log( $revision->get_error_message() ); 296 } 284 297 } 285 298 }
Note: See TracChangeset
for help on using the changeset viewer.