Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/16/2023 02:57:37 PM (18 months ago)
Author:
imath
Message:

Improve the BP_Group_Extension to support the BP Rewrites API

  • Do the needed adaptations so that slugs used by plugins extending the

BP_Group_Extension can be customizable from the BP URls WP Admin
settings screen.

  • Do some code formatting cleanup in various class methods.

This commit also introduces a new filter bp_rewrites_pre_get_slug the BP
Classic plugin will be able to use to skip any slug customizations.

Props Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-rewrites.php

    r13441 r13452  
    6868
    6969/**
    70  * Returns the slug to use for the view belonging to the requested component.
     70 * Returns the slug to use for the screen belonging to the requested component.
    7171 *
    7272 * @since 12.0.0
    7373 *
    7474 * @param string $component_id The BuddyPress component's ID.
    75  * @param string $rewrite_id   The view rewrite ID, used to find the custom slugs.
     75 * @param string $rewrite_id   The screen rewrite ID, used to find the custom slugs.
    7676 *                             Eg: `member_profile_edit` will try to find the xProfile edit's slug.
    77  * @param string $default_slug The view default slug, used as a fallback.
    78  * @return string The slug to use for the view belonging to the requested component.
     77 * @param string $default_slug The screen default slug, used as a fallback.
     78 * @return string The slug to use for the screen belonging to the requested component.
    7979 */
    8080function bp_rewrites_get_slug( $component_id = '', $rewrite_id = '', $default_slug = '' ) {
     81    /**
     82     * This filter is used by the BP Classic plugin to force `$default_slug` usage.
     83     *
     84     * Using the "Classic" BuddyPress means deprecated functions building URL concatening
     85     * URL chunks are available, we cannot use the BP Rewrites API in this case & as a result
     86     * slug customization is bypassed.
     87     *
     88     * The BP Classic plugin is simply returning the `$default_slug` to bypass slug customization.
     89     *
     90     * @since 12.0.0
     91     *
     92     * @param string $value        An empty string to use as to know whether slug customization should be used.
     93     * @param string $default_slug The screen default slug, used as a fallback.
     94     * @param string $rewrite_id   The screen rewrite ID, used to find the custom slugs.
     95     * @param string $component_id The BuddyPress component's ID.
     96     */
     97    $classic_slug = apply_filters( 'bp_rewrites_pre_get_slug', '', $default_slug, $rewrite_id, $component_id );
     98    if ( $classic_slug ) {
     99        return $classic_slug;
     100    }
     101
    81102    $directory_pages = bp_core_get_directory_pages();
    82103    $slug            = $default_slug;
Note: See TracChangeset for help on using the changeset viewer.