Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/15/2023 08:16:46 AM (13 months ago)
Author:
imath
Message:

Make more BuddyPress generated links ready for BP Rewrites

  • Improve the Members component adding permastructs and custom rewrite

rules for registration and activation pages.

  • Improve the Blogs component adding custom rewrite rule to handle the

Blogs create page.

  • Make a huge progress about replacing all occurrences of

bp_get_root_domain() (45 replacements were performed).

  • Deprecate bp_groups_directory_permalink(),

bp_get_groups_directory_permalink(), bp_blogs_directory_permalink() &
bp_get_blogs_directory_permalink() and replace them with these new
functions: bp_groups_directory_url(), bp_get_groups_directory_url(),
bp_blogs_directory_url() & bp_get_blogs_directory_url().

  • Although bp_loggedin_user_domain() & bp_displayed_user_domain()

should also be deprecated, we're leaving them as aliases of the right
functions to use. Plugin authors shouldn't use them to build other links
than member's profile home url.

NB: these deprecations are required because these functions were used
to build BuddyPress URLs concatenating URL chunks. Once the BP Classic
plugin will be built we will adapt the code to remove these deprecation
notices.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

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

    r13433 r13436  
    338338        }
    339339
    340         $domain = bp_members_get_user_url( $user_id );
     340        $url = bp_members_get_user_url(
     341            $user_id,
     342            array(
     343                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     344                'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_messages_view', 'view' ),
     345                'single_item_action_variables' => array( $thread_id ),
     346            )
     347        );
    341348
    342349        /**
     
    347354         * @since 2.9.0 Added the `$user_id` parameter.
    348355         *
    349          * @param string $value     Permalink of a particular thread.
     356         * @param string $url       Permalink of a particular thread.
    350357         * @param int    $thread_id ID of the thread.
    351358         * @param int    $user_id   ID of the user.
    352359         */
    353         return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( $domain . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id, $user_id );
     360        return apply_filters( 'bp_get_message_thread_view_link', $url, $thread_id, $user_id );
    354361    }
    355362
     
    383390        }
    384391
    385         $domain = bp_members_get_user_url( $user_id );
     392        $current_action_slug         = bp_current_action();
     393        $current_action_rewrite_id   = 'member_messages_' . $current_action_slug;
     394        $action_variable_delete_slug = bp_rewrites_get_slug( 'members', $current_action_rewrite_id . '_delete', 'delete' );
     395
     396        $url = bp_members_get_user_url(
     397            $user_id,
     398            array(
     399                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     400                'single_item_action'           => bp_rewrites_get_slug( 'members', $current_action_rewrite_id, $current_action_slug ),
     401                'single_item_action_variables' => array( $action_variable_delete_slug, $messages_template->thread->thread_id ),
     402            )
     403        );
    386404
    387405        /**
     
    390408         * @since 1.0.0
    391409         *
    392          * @param string $value   URL for deleting the current thread.
     410         * @param string $url   URL for deleting the current thread.
    393411         * @param int    $user_id ID of the user relative to whom the link should be generated.
    394412         */
    395         return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ), $user_id );
     413        return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( $url, 'messages_delete_thread' ), $user_id );
    396414    }
    397415
     
    435453        }
    436454
    437         $domain = bp_members_get_user_url( $user_id );
     455        $current_action_slug         = bp_current_action();
     456        $current_action_rewrite_id   = 'member_messages_' . $current_action_slug;
     457        $action_variable_unread_slug = bp_rewrites_get_slug( 'members', $current_action_rewrite_id . '_unread', 'unread' );
    438458
    439459        // Base unread URL.
    440         $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
     460        $url = bp_members_get_user_url(
     461            $user_id,
     462            array(
     463                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     464                'single_item_action'           => bp_rewrites_get_slug( 'members', $current_action_rewrite_id, $current_action_slug ),
     465                'single_item_action_variables' => array( $action_variable_unread_slug ),
     466            )
     467        );
    441468
    442469        // Add the args to the URL.
     
    497524        }
    498525
    499         $domain = bp_members_get_user_url( $user_id );
     526        $current_action_slug         = bp_current_action();
     527        $current_action_rewrite_id   = 'member_messages_' . $current_action_slug;
     528        $action_variable_read_slug = bp_rewrites_get_slug( 'members', $current_action_rewrite_id . '_read', 'read' );
    500529
    501530        // Base read URL.
    502         $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
     531        $url = bp_members_get_user_url(
     532            $user_id,
     533            array(
     534                'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     535                'single_item_action'           => bp_rewrites_get_slug( 'members', $current_action_rewrite_id, $current_action_slug ),
     536                'single_item_action_variables' => array( $action_variable_read_slug ),
     537            )
     538        );
    503539
    504540        // Add the args to the URL.
Note: See TracChangeset for help on using the changeset viewer.