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

    r13414 r13432  
    4444     * Set up global settings for the blogs component.
    4545     *
    46      * The BP_BLOGS_SLUG constant is deprecated, and only used here for
    47      * backwards compatibility.
     46     * The BP_BLOGS_SLUG constant is deprecated.
    4847     *
    4948     * @since 1.5.0
     
    5453     */
    5554    public function setup_globals( $args = array() ) {
    56         $bp = buddypress();
    57 
    58         if ( ! defined( 'BP_BLOGS_SLUG' ) ) {
    59             define ( 'BP_BLOGS_SLUG', $this->id );
     55        $bp           = buddypress();
     56        $default_slug = $this->id;
     57
     58        // @deprecated.
     59        if ( defined( 'BP_BLOGS_SLUG' ) ) {
     60            _doing_it_wrong( 'BP_BLOGS_SLUG', esc_html__( 'Slug constants are deprecated.', 'buddypress' ), 'BuddyPress 12.0.0' );
     61            $default_slug = BP_BLOGS_SLUG;
    6062        }
    6163
     
    7678        // All globals for blogs component.
    7779        $args = array(
    78             'slug'                  => BP_BLOGS_SLUG,
    79             'root_slug'             => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
     80            'slug'                  => $default_slug,
     81            'root_slug'             => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : $default_slug,
    8082            'has_directory'         => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site.
     83            'rewrite_ids'           => array(
     84                'directory'                    => 'blogs',
     85                'single_item_action'           => 'blogs_action',
     86                'single_item_action_variables' => 'blogs_action_variables',
     87            ),
    8188            'directory_title'       => isset( $bp->pages->blogs->title ) ? $bp->pages->blogs->title : $default_directory_title,
    8289            'notification_callback' => 'bp_blogs_format_notifications',
Note: See TracChangeset for help on using the changeset viewer.