Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/24/2023 04:34:15 AM (6 months ago)
Author:
imath
Message:

Make sure slugs are customizable for the BP root site

On multisite configs the BP root site can be different than the current WordPress site. It's necessary to eventually switch to the BP root site before saving custom slugs or retrieving them.

Props perchenet

Fixes #9048 (branch 12.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/12.0/src/bp-core/admin/bp-core-admin-rewrites.php

    r13675 r13679  
    3939        }
    4040
     41        $switched_to_root_blog = false;
     42
     43        // Make sure the current blog is set to the root blog.
     44        if ( ! bp_is_root_blog() ) {
     45            switch_to_blog( bp_get_root_blog_id() );
     46            $switched_to_root_blog = true;
     47        }
     48
    4149        $directory_pages     = (array) bp_core_get_directory_pages();
    4250        $current_page_slugs  = wp_list_pluck( $directory_pages, 'slug', 'id' );
     
    96104        if ( $reset_rewrites ) {
    97105            bp_delete_rewrite_rules();
     106        }
     107
     108        if ( $switched_to_root_blog ) {
     109            restore_current_blog();
    98110        }
    99111
Note: See TracChangeset for help on using the changeset viewer.