bp_core_get_upload_dir( string $type = 'upload_path' )
Fetch data from the BP root blog’s upload directory.
Description
Parameters
- $type
-
(Optional) The variable we want to return from the $bp->avatars object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
Default value: 'upload_path'
Return
(string) The avatar upload directory path.
Source
File: bp-core/bp-core-avatars.php
1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 | function bp_core_get_upload_dir( $type = 'upload_path' ) { $bp = buddypress(); switch ( $type ) { case 'upload_path' : $constant = 'BP_AVATAR_UPLOAD_PATH' ; $key = 'basedir' ; break ; case 'url' : $constant = 'BP_AVATAR_URL' ; $key = 'baseurl' ; break ; default : return false; break ; } // See if the value has already been calculated and stashed in the $bp global. if ( isset( $bp ->avatar-> $type ) ) { $retval = $bp ->avatar-> $type ; } else { // If this value has been set in a constant, just use that. if ( defined( $constant ) ) { $retval = constant( $constant ); } else { // Use cached upload dir data if available. if ( ! empty ( $bp ->avatar->upload_dir ) ) { $upload_dir = $bp ->avatar->upload_dir; // No cache, so query for it. } else { // Get upload directory information from current site. $upload_dir = bp_upload_dir(); // Stash upload directory data for later use. $bp ->avatar->upload_dir = $upload_dir ; } // Directory does not exist and cannot be created. if ( ! empty ( $upload_dir [ 'error' ] ) ) { $retval = '' ; } else { $retval = $upload_dir [ $key ]; // If $key is 'baseurl', check to see if we're on SSL // Workaround for WP13941, WP15928, WP19037. if ( $key == 'baseurl' && is_ssl() ) { } } } // Stash in $bp for later use. $bp ->avatar-> $type = $retval ; } return $retval ; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.8.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.