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
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 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() ) { } } 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.