Skip to:
Content

BuddyPress.org

Changeset 14152


Ignore:
Timestamp:
12/16/2025 05:15:31 PM (5 hours ago)
Author:
espellcaste
Message:

Add pre-filter hook for avatar history.

Add bp_pre_avatar_get_avatars_history filter to allow short-circuiting avatar history retrieval.
Fix typo @parma to @param in bp_core_avatar_handle_upload docblock.

Props GaryJ.

Closes https://github.com/buddypress/buddypress/pull/426/
Fixes #9311 (trunk)

Location:
trunk/src/bp-core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-attachments.php

    r14140 r14152  
    724724    // Enqueue me just once per page, please.
    725725    if ( did_action( 'bp_attachments_enqueue_scripts' ) ) {
    726         return;
     726        return null;
    727727    }
    728728
  • trunk/src/bp-core/bp-core-avatars.php

    r14140 r14152  
    973973     * Filters whether or not to handle uploading.
    974974     *
    975      * If you want to override this function, make sure you return false.
     975     * If you want to override this function, make sure you return `false`.
    976976     *
    977977     * @since 1.2.4
    978978     *
    979      * @param bool   $value             Whether or not to crop.
     979     * @param bool   $pre_filter        Whether or not to crop. Defaults to true.
    980980     * @param array  $file              Appropriate entry from $_FILES superglobal.
    981      * @parma string $upload_dir_filter A filter to be applied to 'upload_dir'.
     981     * @param string $upload_dir_filter A filter to be applied to 'upload_dir'.
    982982     */
    983983    if ( ! apply_filters( 'bp_core_pre_avatar_handle_upload', true, $file, $upload_dir_filter ) ) {
     
    22242224     *
    22252225     * @param bool $avatar_history True to disable avatar history. False otherwise.
    2226      *                    Default: `false`.
     2226     *                             Default: `false`.
    22272227     */
    22282228    return apply_filters( 'bp_disable_avatar_history', false );
     
    22762276 */
    22772277function bp_avatar_get_avatars_history( $item_id = 0, $object = 'user', $type = 'full' ) {
     2278    /**
     2279     * Filter to short-circuit the avatars history retrieval process.
     2280     *
     2281     * If you want to override this function, make sure you return something other than `null`.
     2282     *
     2283     * @since 14.5.0
     2284     *
     2285     * @param null|array $pre_filter Null to proceed with the default handling, or an array of avatars to override it.
     2286     * @param int        $item_id    The item ID we need the avatar version for.
     2287     * @param string     $object     The object the item ID relates to.
     2288     * @param string     $type       Get the `full`, `thumb` or `both` versions.
     2289     */
     2290    $pre_filter = apply_filters( 'bp_pre_avatar_get_avatars_history', null, $item_id, $object, $type );
     2291
     2292    if ( null !== $pre_filter ) {
     2293        return $pre_filter;
     2294    }
     2295
    22782296    if ( ! $item_id ) {
    22792297        return array();
Note: See TracChangeset for help on using the changeset viewer.