Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/01/2023 08:17:11 AM (3 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-groups/classes/class-bp-groups-component.php

    r13414 r13432  
    439439     * Set up component global data.
    440440     *
    441      * The BP_GROUPS_SLUG constant is deprecated, and only used here for
    442      * backwards compatibility.
     441     * The BP_GROUPS_SLUG constant is deprecated.
    443442     *
    444443     * @since 1.5.0
     
    449448     */
    450449    public function setup_globals( $args = array() ) {
    451         $bp = buddypress();
    452 
    453         // Define a slug, if necessary.
    454         if ( ! defined( 'BP_GROUPS_SLUG' ) ) {
    455             define( 'BP_GROUPS_SLUG', $this->id );
     450        $bp           = buddypress();
     451        $default_slug = $this->id;
     452
     453        // @deprecated.
     454        if ( defined( 'BP_GROUPS_SLUG' ) ) {
     455            _doing_it_wrong( 'BP_GROUPS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' );
     456            $default_slug = BP_GROUPS_SLUG;
    456457        }
    457458
     
    475476        // Note that global_tables is included in this array.
    476477        $args = array(
    477             'slug'                  => BP_GROUPS_SLUG,
    478             'root_slug'             => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,
     478            'slug'                  => $default_slug,
     479            'root_slug'             => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : $default_slug,
    479480            'has_directory'         => true,
     481            'rewrite_ids'           => array(
     482                'directory'                    => 'groups',
     483                'directory_type'               => 'groups_type',
     484                'create_single_item'           => 'group_create',
     485                'create_single_item_variables' => 'group_create_variables',
     486                'single_item'                  => 'group',
     487                'single_item_action'           => 'group_action',
     488                'single_item_action_variables' => 'group_action_variables',
     489            ),
    480490            'directory_title'       => isset( $bp->pages->groups->title ) ? $bp->pages->groups->title : $default_directory_title,
    481491            'notification_callback' => 'groups_format_notifications',
Note: See TracChangeset for help on using the changeset viewer.