Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/27/2023 06:19:06 PM (18 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-core/bp-core-functions.php

    r13441 r13442  
    48824882    return (int) apply_filters( 'bp_get_post_type_site_id', $site_id );
    48834883}
     4884
     4885/**
     4886 * Returns registered navigation items for all or a specific component.
     4887 *
     4888 * @since 12.0.0
     4889 *
     4890 * @param string $component The component ID.
     4891 * @return array            The list of registered navigation items.
     4892 */
     4893function bp_get_component_navigations( $component = '' ) {
     4894    $args = array();
     4895    if ( $component ) {
     4896        $args['id'] = $component;
     4897    }
     4898
     4899    $components  = bp_core_get_active_components( $args, 'objects' );
     4900    $navigations = array();
     4901
     4902    foreach ( $components as $key_component => $component ) {
     4903        if ( isset( $component->main_nav['rewrite_id'] ) ) {
     4904            $navigations[ $key_component ]['main_nav'] = $component->main_nav;
     4905        }
     4906
     4907        if ( isset( $component->sub_nav ) && is_array( $component->sub_nav ) && $component->sub_nav ) {
     4908            $navigations[ $key_component ]['sub_nav'] = $component->sub_nav;
     4909        }
     4910    }
     4911
     4912    return $navigations;
     4913}
Note: See TracChangeset for help on using the changeset viewer.