diff --git a/src/bp-core/bp-core-taxonomy.php b/src/bp-core/bp-core-taxonomy.php
index bd544b4..23a88df 100644
a
|
b
|
function bp_register_default_taxonomies() { |
45 | 45 | add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' ); |
46 | 46 | |
47 | 47 | /** |
| 48 | * Get the ID of the site that BP should use for taxonomy term storage. |
| 49 | * |
| 50 | * Defaults to the root blog ID. |
| 51 | * |
| 52 | * @return int |
| 53 | */ |
| 54 | function bp_get_taxonomy_term_site_id( $taxonomy = '' ) { |
| 55 | $site_id = bp_get_root_blog_id(); |
| 56 | |
| 57 | /** |
| 58 | * Filters the ID of the site where BP should store taxonomy terms. |
| 59 | * |
| 60 | * @param int $site_id |
| 61 | * @param string $taxonomy |
| 62 | */ |
| 63 | return (int) apply_filters( 'bp_get_taxonomy_term_site_id', $site_id, $taxonomy ); |
| 64 | } |
| 65 | |
| 66 | /** |
48 | 67 | * Set taxonomy terms on a BuddyPress object. |
49 | 68 | * |
50 | 69 | * @since 2.2.0 |
… |
… |
add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' ); |
58 | 77 | * @return array Array of term taxonomy IDs. |
59 | 78 | */ |
60 | 79 | function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { |
61 | | $is_root_blog = bp_is_root_blog(); |
| 80 | $site_id = bp_get_taxonomy_term_site_id( $taxonomy ); |
62 | 81 | |
63 | | if ( ! $is_root_blog ) { |
64 | | switch_to_blog( bp_get_root_blog_id() ); |
| 82 | $switched = false; |
| 83 | if ( $site_id !== get_current_blog_id() ) { |
| 84 | switch_to_blog( $site_id ); |
65 | 85 | bp_register_taxonomies(); |
| 86 | $switched = true; |
66 | 87 | } |
67 | 88 | |
68 | 89 | $retval = wp_set_object_terms( $object_id, $terms, $taxonomy, $append ); |
69 | 90 | |
70 | | if ( ! $is_root_blog ) { |
| 91 | if ( ! $switched ) { |
71 | 92 | restore_current_blog(); |
72 | 93 | } |
73 | 94 | |