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-members/classes/class-bp-members-component.php

    r13414 r13432  
    276276     * Set up bp-members global settings.
    277277     *
    278      * The BP_MEMBERS_SLUG constant is deprecated, and only used here for
    279      * backwards compatibility.
     278     * The BP_MEMBERS_SLUG constant is deprecated.
    280279     *
    281280     * @since 1.5.0
     
    288287        global $wpdb;
    289288
    290         $bp = buddypress();
     289        $bp           = buddypress();
     290        $default_slug = $this->id;
    291291
    292292        /** Component Globals ************************************************
    293293         */
    294294
    295         // Define a slug, as a fallback for backpat.
    296         if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
    297             define( 'BP_MEMBERS_SLUG', $this->id );
     295        // @deprecated.
     296        if ( defined( 'BP_MEMBERS_SLUG' ) ) {
     297            _doing_it_wrong( 'BP_MEMBERS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' );
     298            $default_slug = BP_MEMBERS_SLUG;
    298299        }
    299300
     
    304305        // Override any passed args.
    305306        $args = array(
    306             'slug'            => BP_MEMBERS_SLUG,
    307             'root_slug'       => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
     307            'slug'            => $default_slug,
     308            'root_slug'       => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $default_slug,
    308309            'has_directory'   => true,
     310            'rewrite_ids'     => array(
     311                'directory'                    => 'members',
     312                'directory_type'               => 'members_type',
     313                'single_item'                  => 'member',
     314                'single_item_component'        => 'member_component',
     315                'single_item_action'           => 'member_action',
     316                'single_item_action_variables' => 'member_action_variables',
     317                'member_register'              => 'register',
     318                'member_activate'              => 'activate',
     319                'member_activate_key'          => 'activate_key',
     320            ),
    309321            'directory_title' => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title,
    310322            'search_string'   => __( 'Search Members...', 'buddypress' ),
Note: See TracChangeset for help on using the changeset viewer.