diff --git src/bp-core/admin/bp-core-admin-schema.php src/bp-core/admin/bp-core-admin-schema.php
index 87ec012..28af0e2 100644
|
|
|
function bp_core_install_emails() { |
| 688 | 688 | 'groups-membership-request-rejected' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ), |
| 689 | 689 | ); |
| 690 | 690 | |
| | 691 | /** |
| | 692 | * Emails are inserted on the root blog |
| | 693 | */ |
| | 694 | bp_switch_to_root_blog(); |
| | 695 | |
| 691 | 696 | // Add these emails to the database. |
| 692 | 697 | foreach ( $emails as $id => $email ) { |
| 693 | 698 | $post_id = wp_insert_post( bp_parse_args( $email, $defaults, 'install_email_' . $id ) ); |
| … |
… |
function bp_core_install_emails() { |
| 704 | 709 | } |
| 705 | 710 | |
| 706 | 711 | /** |
| | 712 | * Restore current blog if needed |
| | 713 | */ |
| | 714 | bp_restore_current_blog(); |
| | 715 | |
| | 716 | /** |
| 707 | 717 | * Fires after BuddyPress adds the posts for its emails. |
| 708 | 718 | * |
| 709 | 719 | * @since 2.5.0 |
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
index dc93da4..0bd2a3b 100644
|
|
|
function bp_is_network_activated() { |
| 1923 | 1923 | return (bool) apply_filters( 'bp_is_network_activated', $retval ); |
| 1924 | 1924 | } |
| 1925 | 1925 | |
| | 1926 | /** |
| | 1927 | * Switch to root blog if necessary |
| | 1928 | * |
| | 1929 | * @since 2.5.0 |
| | 1930 | */ |
| | 1931 | function bp_switch_to_root_blog() { |
| | 1932 | if ( ! is_multisite() || (int) get_current_blog_id() === (int) bp_get_root_blog_id() ) { |
| | 1933 | return; |
| | 1934 | } |
| | 1935 | |
| | 1936 | switch_to_blog( bp_get_root_blog_id() ); |
| | 1937 | |
| | 1938 | // Make sure BuddyPress post types are registered |
| | 1939 | if ( ! post_type_exists( bp_get_email_post_type() ) ) { |
| | 1940 | bp_register_post_types(); |
| | 1941 | } |
| | 1942 | |
| | 1943 | // Make sure BuddyPress taxonomies are registered |
| | 1944 | if ( ! taxonomy_exists( bp_get_email_tax_type() ) ) { |
| | 1945 | bp_register_taxonomies(); |
| | 1946 | } |
| | 1947 | |
| | 1948 | buddypress()->core->blog_is_switched = true; |
| | 1949 | } |
| | 1950 | |
| | 1951 | /** |
| | 1952 | * Reset current blog if necessary |
| | 1953 | * |
| | 1954 | * @since 2.5.0 |
| | 1955 | */ |
| | 1956 | function bp_restore_current_blog() { |
| | 1957 | $bp = buddypress(); |
| | 1958 | |
| | 1959 | if ( isset( $bp->core->blog_is_switched ) && true === $bp->core->blog_is_switched ) { |
| | 1960 | restore_current_blog(); |
| | 1961 | |
| | 1962 | $bp->core->blog_is_switched = false; |
| | 1963 | } |
| | 1964 | } |
| | 1965 | |
| 1926 | 1966 | /** Global Manipulators *******************************************************/ |
| 1927 | 1967 | |
| 1928 | 1968 | /** |
diff --git src/bp-core/bp-core-taxonomy.php src/bp-core/bp-core-taxonomy.php
index dedf1ce..6ee4803 100644
|
|
|
add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' ); |
| 60 | 60 | * @return array Array of term taxonomy IDs. |
| 61 | 61 | */ |
| 62 | 62 | function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { |
| 63 | | $is_root_blog = bp_is_root_blog(); |
| 64 | | |
| 65 | | if ( ! $is_root_blog ) { |
| 66 | | switch_to_blog( bp_get_root_blog_id() ); |
| 67 | | } |
| | 63 | bp_switch_to_root_blog(); |
| 68 | 64 | |
| 69 | 65 | $retval = wp_set_object_terms( $object_id, $terms, $taxonomy, $append ); |
| 70 | 66 | |
| 71 | | if ( ! $is_root_blog ) { |
| 72 | | restore_current_blog(); |
| 73 | | } |
| | 67 | bp_restore_current_blog(); |
| 74 | 68 | |
| 75 | 69 | return $retval; |
| 76 | 70 | } |
| … |
… |
function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { |
| 88 | 82 | * @return array |
| 89 | 83 | */ |
| 90 | 84 | function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) { |
| 91 | | $is_root_blog = bp_is_root_blog(); |
| 92 | | |
| 93 | | if ( ! $is_root_blog ) { |
| 94 | | switch_to_blog( bp_get_root_blog_id() ); |
| 95 | | } |
| | 85 | bp_switch_to_root_blog(); |
| 96 | 86 | |
| 97 | 87 | $retval = wp_get_object_terms( $object_ids, $taxonomies, $args ); |
| 98 | 88 | |
| 99 | | if ( ! $is_root_blog ) { |
| 100 | | restore_current_blog(); |
| 101 | | } |
| | 89 | bp_restore_current_blog(); |
| 102 | 90 | |
| 103 | 91 | return $retval; |
| 104 | 92 | } |
| … |
… |
function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) { |
| 116 | 104 | * @return bool|WP_Error True on success, false or WP_Error on failure. |
| 117 | 105 | */ |
| 118 | 106 | function bp_remove_object_terms( $object_id, $terms, $taxonomy ) { |
| 119 | | $is_root_blog = bp_is_root_blog(); |
| 120 | | |
| 121 | | if ( ! $is_root_blog ) { |
| 122 | | switch_to_blog( bp_get_root_blog_id() ); |
| 123 | | } |
| | 107 | bp_switch_to_root_blog(); |
| 124 | 108 | |
| 125 | 109 | $retval = wp_remove_object_terms( $object_id, $terms, $taxonomy ); |
| 126 | 110 | |
| 127 | | if ( ! $is_root_blog ) { |
| 128 | | restore_current_blog(); |
| 129 | | } |
| | 111 | bp_restore_current_blog(); |
| 130 | 112 | |
| 131 | 113 | return $retval; |
| 132 | 114 | } |