bp_attachments_uploads_dir_get( string $data = '' )
Get the Attachments Uploads dir data.
Description
Parameters
- $data
-
(Optional) The data to get. Possible values are: 'dir', 'basedir' & 'baseurl'. Leave empty to get all datas.
Default value: ''
Return
(string|array) The needed Upload dir data.
Source
File: bp-core/bp-core-attachments.php
function bp_attachments_uploads_dir_get( $data = '' ) {
$attachments_dir = 'buddypress';
$retval = '';
if ( 'dir' === $data ) {
$retval = $attachments_dir;
} else {
$upload_data = bp_upload_dir();
// Return empty string, if Uploads data are not available.
if ( ! $upload_data ) {
return $retval;
}
// Build the Upload data array for BuddyPress attachments.
foreach ( $upload_data as $key => $value ) {
if ( 'basedir' === $key || 'baseurl' === $key ) {
$upload_data[ $key ] = trailingslashit( $value ) . $attachments_dir;
// Fix for HTTPS.
if ( 'baseurl' === $key && is_ssl() ) {
$upload_data[ $key ] = str_replace( 'http://', 'https://', $upload_data[ $key ] );
}
} else {
unset( $upload_data[ $key ] );
}
}
// Add the dir to the array.
$upload_data['dir'] = $attachments_dir;
if ( empty( $data ) ) {
$retval = $upload_data;
} elseif ( isset( $upload_data[ $data ] ) ) {
$retval = $upload_data[ $data ];
}
}
/**
* Filter here to edit the Attachments upload dir data.
*
* @since BuddyPress 2.4.0
*
* @param string|array $retval The needed Upload dir data or the full array of data
* @param string $data The data requested
*/
return apply_filters( 'bp_attachments_uploads_dir_get', $retval, $data );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.4.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.