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-members/bp-members-template.php

    r13441 r13442  
    19531953 *
    19541954 * @since 1.2.4
    1955  */
    1956 function bp_loggedin_user_link() {
    1957     echo esc_url( bp_loggedin_user_url() );
     1955 * @since 12.0.0 Introduced the `$chunk` argument.
     1956 *
     1957 * @param array $chunk A list of slugs to append to the URL.
     1958 */
     1959function bp_loggedin_user_link( $chunks = array() ) {
     1960    $path_chunks = array();
     1961    $chunks      = (array) $chunks;
     1962
     1963    if ( $chunks ) {
     1964        $single_item_component = array_shift( $chunks );
     1965        if ( $single_item_component ) {
     1966            $path_chunks['single_item_component'] = bp_rewrites_get_slug( 'members', 'member_' . $single_item_component, $single_item_component );
     1967        }
     1968
     1969        $single_item_action = array_shift( $chunks );
     1970        if ( $single_item_action ) {
     1971            $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $single_item_component . '_' . $single_item_action, $single_item_action );
     1972        }
     1973
     1974        if ( $chunks ) {
     1975            foreach ( $chunks as $chunk ) {
     1976                $path_chunks['single_item_action_variables'][] = bp_rewrites_get_slug( 'members', 'member_' . $single_item_component . '_' . $single_item_action . '_' . $chunk, $chunk );
     1977            }
     1978        }
     1979    }
     1980
     1981    echo esc_url( bp_loggedin_user_url( $path_chunks ) );
    19581982}
    19591983
Note: See TracChangeset for help on using the changeset viewer.