Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (2 years ago)
Author:
imath
Message:

BP Rewrites: optimize the code used to build URLs

The bp_members_get_path_chunks() & bp_groups_get_path_chunks() functions are making sure URL chunks are customized according to the slugs settings. Instead of redoing at many places all or some of the operations performed by these functions, update the code to build URLs so that it uses these functions.

See #4954
Fixes #8923
Closes https://github.com/buddypress/buddypress/pull/117

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/actions/compose.php

    r13442 r13503  
    4444
    4545        // Setup the link to the logged-in user's messages.
    46         $message_slug        = bp_get_messages_slug();
    47         $custom_message_slug = bp_rewrites_get_slug( 'members', 'member_' . $message_slug, $message_slug );
    48         $path_chunks         = array(
    49             'single_item_component' => $custom_message_slug,
    50         );
     46        $path_chunks = array( bp_get_messages_slug() );
    5147
    5248        // Site-wide notice.
     
    5551            // Attempt to save the notice and redirect to notices.
    5652            if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) {
    57                 $success                           = true;
    58                 $feedback                          = __( 'Notice successfully created.', 'buddypress' );
    59                 $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $message_slug . '_notices', 'notices' );
    60                 $redirect_to = bp_loggedin_user_url( $path_chunks );
     53                $success       = true;
     54                $feedback      = __( 'Notice successfully created.', 'buddypress' );
     55                $path_chunks[] = 'notices';
     56                $redirect_to   = bp_loggedin_user_url( bp_members_get_path_chunks( $path_chunks ) );
    6157
    6258            // Notice could not be sent.
     
    9389            // Send the message and redirect to it.
    9490            if ( true === is_int( $send ) ) {
    95                 $success                                     = true;
    96                 $feedback                                    = __( 'Message successfully sent.', 'buddypress' );
    97                 $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_' . $message_slug . '_view', 'view' );
    98                 $path_chunks['single_item_action_variables'] = array( $send );
    99                 $redirect_to                                 = bp_loggedin_user_url( $path_chunks );
     91                $success       = true;
     92                $feedback      = __( 'Message successfully sent.', 'buddypress' );
     93                $path_chunks[] = 'view';
     94                $path_chunks[] = array( $send );
     95                $redirect_to   = bp_loggedin_user_url( bp_members_get_path_chunks( $path_chunks ) );
    10096
    10197            // Message could not be sent.
Note: See TracChangeset for help on using the changeset viewer.