Skip to:
Content

BuddyPress.org

Changeset 13541


Ignore:
Timestamp:
08/03/2023 05:23:18 AM (2 years ago)
Author:
imath
Message:

Improve the function to get the Avatar uploads path and url

Update the bp_core_get_upload_dir() function so that it rightly uses the bp_upload_dir() one. The latter is returning false when an error occured while WordPress tried to set the site's uploads directory instead of an array containing an error key.

Props fawp

Fixes #8966
Closes https://github.com/buddypress/buddypress/pull/147

File:
1 edited

Legend:

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

    r13497 r13541  
    16241624 */
    16251625function bp_core_get_upload_dir( $type = 'upload_path' ) {
    1626     $bp = buddypress();
     1626    $bp     = buddypress();
     1627    $retval = '';
    16271628
    16281629    switch ( $type ) {
     
    16401641
    16411642        default :
    1642             return false;
     1643            return $retval;
    16431644
    16441645            break;
     
    16681669            }
    16691670
    1670             // Directory does not exist and cannot be created.
    1671             if ( ! empty( $upload_dir['error'] ) ) {
    1672                 $retval = '';
    1673 
    1674             } else {
    1675                 $retval = $upload_dir[$key];
     1671            // Upload directory exists.
     1672            if ( isset( $upload_dir[ $key ] ) ) {
     1673                $retval = $upload_dir[ $key ];
    16761674
    16771675                // If $key is 'baseurl', check to see if we're on SSL
    16781676                // Workaround for WP13941, WP15928, WP19037.
    1679                 if ( $key == 'baseurl' && is_ssl() ) {
     1677                if ( $key === 'baseurl' && is_ssl() ) {
    16801678                    $retval = str_replace( 'http://', 'https://', $retval );
    16811679                }
    16821680            }
    1683 
    16841681        }
    16851682
Note: See TracChangeset for help on using the changeset viewer.