diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
index 227237b..072a98d 100644
|
|
function bp_upload_dir() { |
2597 | 2597 | $bp = buddypress(); |
2598 | 2598 | |
2599 | 2599 | if ( empty( $bp->upload_dir ) ) { |
2600 | | $need_switch = (bool) ( is_multisite() && ! bp_is_root_blog() ); |
| 2600 | $current_site_id = 0; |
| 2601 | |
| 2602 | if ( isset( $GLOBALS['current_site']->blog_id ) ) { |
| 2603 | $current_site_id = (int) $GLOBALS['current_site']->blog_id; |
| 2604 | $need_switch = (int) bp_get_root_blog_id() !== $current_site_id; |
| 2605 | } else { |
| 2606 | $need_switch = (bool) ( is_multisite() && ! bp_is_root_blog() ); |
| 2607 | } |
2601 | 2608 | |
2602 | 2609 | // Maybe juggle to root blog. |
2603 | 2610 | if ( true === $need_switch ) { |
2604 | | switch_to_blog( bp_get_root_blog_id() ); |
| 2611 | $blog_id = bp_get_root_blog_id(); |
| 2612 | |
| 2613 | /** |
| 2614 | * Using this filter, Multiblog setups can use a common uploads dir. |
| 2615 | * |
| 2616 | * @since 2.6.0 |
| 2617 | * |
| 2618 | * @param $value False to use separate uploads dir for each site. |
| 2619 | * True to use a common uploads dir accross the network. |
| 2620 | */ |
| 2621 | if ( true === (bool) apply_filters( 'bp_multiblog_common_upload_dir', false ) && ! empty( $current_site_id ) && bp_is_multiblog_mode() ) { |
| 2622 | $blog_id = $current_site_id; |
| 2623 | } |
| 2624 | |
| 2625 | switch_to_blog( $blog_id ); |
2605 | 2626 | } |
2606 | 2627 | |
2607 | 2628 | // Get the upload directory (maybe for root blog). |