Skip to:
Content

BuddyPress.org

Changeset 13679


Ignore:
Timestamp:
12/24/2023 04:34:15 AM (9 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)

Location:
branches/12.0/src/bp-core
Files:
3 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
  • branches/12.0/src/bp-core/bp-core-functions.php

    r13648 r13679  
    776776
    777777        // Set pages as standard class.
    778         $pages = new stdClass;
     778        $pages                 = new stdClass;
     779        $switched_to_root_blog = false;
     780
     781        // Make sure the current blog is set to the root blog.
     782        if ( ! bp_is_root_blog() && ! bp_is_multiblog_mode() ) {
     783            switch_to_blog( bp_get_root_blog_id() );
     784            $switched_to_root_blog = true;
     785        }
    779786
    780787        // Get pages and IDs.
     
    816823                }
    817824            }
     825        }
     826
     827        if ( $switched_to_root_blog ) {
     828            restore_current_blog();
    818829        }
    819830
  • branches/12.0/src/bp-core/bp-core-rewrites.php

    r13461 r13679  
    5252 */
    5353function bp_delete_rewrite_rules() {
    54     delete_option( 'rewrite_rules' );
     54    bp_delete_option( 'rewrite_rules' );
    5555}
    5656
Note: See TracChangeset for help on using the changeset viewer.