Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/01/2023 08:17:11 AM (2 years ago)
Author:
imath
Message:

BP Rewrites: introduce the bp_rewrites_get_url() function

Its role is to build every BuddyPress URL using the BP Rewrites API.

This commit also deprecates softly some key functions like bp_get_root_domain() to let us review (thanks to deprecated notices) all BuddyPress links during 12.0 development cycle and make them use the introduced bp_rewrites_get_url() function or a wrapper of it. Once all replacements achieved, we'll need to fully deprecate:

  • bp_get_root_domain()
  • bp_root_domain()
  • bp_core_get_root_domain()

Slug constants have also been completely deprecated as we will be able to customize every slugs from the future "URL" tab of the BuddyPress settings page.

The $bp->root_domain BuddyPress global has been deprecated in favor of $bp->root_url.

Finally, the Components $rewrite_ids properties are now in place and corresponding rewrite rules are successfully generated.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/69
See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r13395 r13432  
    2525    return (bool) ! empty( $bp->pages->members->id );
    2626}
    27 
    28 /**
    29  * Define the slug constants for the Members component.
    30  *
    31  * Handles the three slug constants used in the Members component -
    32  * BP_MEMBERS_SLUG, BP_REGISTER_SLUG, and BP_ACTIVATION_SLUG. If these
    33  * constants are not overridden in wp-config.php or bp-custom.php, they are
    34  * defined here to match the slug of the corresponding WP pages.
    35  *
    36  * In general, fallback values are only used during initial BP page creation,
    37  * when no slugs have been explicitly defined.
    38  *
    39  * @since 1.5.0
    40  */
    41 function bp_core_define_slugs() {
    42     $bp = buddypress();
    43 
    44     // No custom members slug.
    45     if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
    46         if ( !empty( $bp->pages->members ) ) {
    47             define( 'BP_MEMBERS_SLUG', $bp->pages->members->slug );
    48         } else {
    49             define( 'BP_MEMBERS_SLUG', 'members' );
    50         }
    51     }
    52 
    53     // No custom registration slug.
    54     if ( !defined( 'BP_REGISTER_SLUG' ) ) {
    55         if ( !empty( $bp->pages->register ) ) {
    56             define( 'BP_REGISTER_SLUG', $bp->pages->register->slug );
    57         } else {
    58             define( 'BP_REGISTER_SLUG', 'register' );
    59         }
    60     }
    61 
    62     // No custom activation slug.
    63     if ( !defined( 'BP_ACTIVATION_SLUG' ) ) {
    64         if ( !empty( $bp->pages->activate ) ) {
    65             define( 'BP_ACTIVATION_SLUG', $bp->pages->activate->slug );
    66         } else {
    67             define( 'BP_ACTIVATION_SLUG', 'activate' );
    68         }
    69     }
    70 }
    71 add_action( 'bp_setup_globals', 'bp_core_define_slugs', 11 );
    7227
    7328/**
     
    15481503    );
    15491504
    1550     // Core constants.
     1505    // @todo replace slug constants with custom slugs.
    15511506    $slug_constants = array(
    1552         'BP_GROUPS_SLUG',
    1553         'BP_MEMBERS_SLUG',
    15541507        'BP_FORUMS_SLUG',
    1555         'BP_BLOGS_SLUG',
    1556         'BP_ACTIVITY_SLUG',
    1557         'BP_XPROFILE_SLUG',
    1558         'BP_FRIENDS_SLUG',
    15591508        'BP_SEARCH_SLUG',
    1560         'BP_SETTINGS_SLUG',
    1561         'BP_NOTIFICATIONS_SLUG',
    1562         'BP_REGISTER_SLUG',
    1563         'BP_ACTIVATION_SLUG',
    15641509    );
    15651510    foreach ( $slug_constants as $constant ) {
Note: See TracChangeset for help on using the changeset viewer.