Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/29/2020 03:38:06 PM (16 months ago)
Author:
imath
Message:

Move Avatars & Cover from xProfile to Members component : step 3

Move the Avatar upload directory filter from the xProfile functions to the Members functions.
Move the Avatar template functions from xProfile to the Members component.

See #8156

File:
1 edited

Legend:

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

    r12503 r12555  
    28492849    return apply_filters( 'bp_get_current_member_type', buddypress()->current_member_type );
    28502850}
     2851
     2852/**
     2853 * Setup the avatar upload directory for a user.
     2854 *
     2855 * @since 6.0.0
     2856 *
     2857 * @param string $directory The root directory name. Optional.
     2858 * @param int    $user_id   The user ID. Optional.
     2859 * @return array Array containing the path, URL, and other helpful settings.
     2860 */
     2861function bp_members_avatar_upload_dir( $directory = 'avatars', $user_id = 0 ) {
     2862
     2863    // Use displayed user if no user ID was passed.
     2864    if ( empty( $user_id ) ) {
     2865        $user_id = bp_displayed_user_id();
     2866    }
     2867
     2868    // Failsafe against accidentally nooped $directory parameter.
     2869    if ( empty( $directory ) ) {
     2870        $directory = 'avatars';
     2871    }
     2872
     2873    $path      = bp_core_avatar_upload_path() . '/' . $directory. '/' . $user_id;
     2874    $newbdir   = $path;
     2875    $newurl    = bp_core_avatar_url() . '/' . $directory. '/' . $user_id;
     2876    $newburl   = $newurl;
     2877    $newsubdir = '/' . $directory. '/' . $user_id;
     2878
     2879    /**
     2880     * Filters the avatar upload directory for a user.
     2881     *
     2882     * @since 6.0.0
     2883     *
     2884     * @param array $value Array containing the path, URL, and other helpful settings.
     2885     */
     2886    return apply_filters( 'bp_members_avatar_upload_dir', array(
     2887        'path'    => $path,
     2888        'url'     => $newurl,
     2889        'subdir'  => $newsubdir,
     2890        'basedir' => $newbdir,
     2891        'baseurl' => $newburl,
     2892        'error'   => false
     2893    ) );
     2894}
Note: See TracChangeset for help on using the changeset viewer.