Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/27/2023 06:19:06 PM (13 months ago)
Author:
imath
Message:

Improve Components Member's single item navigation generation

  • Edit the BP_Component Class so that it globalize navigation items before registering it.
  • Introduce bp_get_component_navigations(), a new function that will be used to get Member's single navigation customizable slugs within the BuddyPress settings area.
  • Perform all remaining bp_loggedin_user_domain() replacements (55) in favor of the bp_loggedin_user_url() function which uses BP Rewrites to build URLs.
  • Improve bp_loggedin_user_link() by adding a new $chunks array of arguments to output escaped URL in templates.
  • Adapt some PHPUnit testcases.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

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

    r13096 r13442  
    4444
    4545        // Setup the link to the logged-in user's messages.
    46         $member_messages = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() );
     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        );
    4751
    4852        // Site-wide notice.
     
    5155            // Attempt to save the notice and redirect to notices.
    5256            if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) {
    53                 $success     = true;
    54                 $feedback    = __( 'Notice successfully created.', 'buddypress' );
    55                 $redirect_to = trailingslashit( $member_messages . 'notices' );
     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 );
    5661
    5762            // Notice could not be sent.
     
    8893            // Send the message and redirect to it.
    8994            if ( true === is_int( $send ) ) {
    90                 $success     = true;
    91                 $feedback    = __( 'Message successfully sent.', 'buddypress' );
    92                 $view        = trailingslashit( $member_messages . 'view' );
    93                 $redirect_to = trailingslashit( $view . $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 );
    94100
    95101            // Message could not be sent.
Note: See TracChangeset for help on using the changeset viewer.