Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/27/2023 06:19:06 PM (23 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-templates/bp-legacy/buddypress/activity/index.php

    r12907 r13442  
    77 * @package BuddyPress
    88 * @subpackage bp-legacy
    9  * @version 3.0.0
     9 * @version 12.0.0
    1010 */
    1111
     
    8282
    8383                        <li id="activity-friends">
    84                             <a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/'; ?>">
     84                            <a href="<?php bp_loggedin_user_link( array( bp_get_activity_slug(), bp_get_friends_slug() ) ); ?>">
    8585                                <?php
    8686                                /* translators: %s: number of friends */
    87                                 printf( __( 'My Friends %s', 'buddypress' ), '<span>' . bp_get_total_friend_count( bp_loggedin_user_id() ) . '</span>' );
     87                                printf( esc_html__( 'My Friends %s', 'buddypress' ), '<span>' . bp_get_total_friend_count( bp_loggedin_user_id() ) . '</span>' );
    8888                                ?>
    8989                            </a>
     
    107107                    <?php if ( bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) : ?>
    108108
    109                         <?php
    110                         printf(
    111                             '<li id="activity-groups"><a href="%1$s">%2$s</a></li>',
    112                             esc_url( bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/' ),
    113                             sprintf(
     109                        <li id="activity-groups">
     110                            <a href="<?php bp_loggedin_user_link( array( bp_get_activity_slug(), bp_get_groups_slug() ) ); ?>">
     111                                <?php
    114112                                /* translators: %s: current user groups count */
    115                                 __( 'My Groups %s', 'buddypress' ),
    116                                 '<span>' . bp_get_total_group_count_for_user( bp_loggedin_user_id() ) . '</span>'
    117                             )
    118                         );
    119                         ?>
     113                                printf( esc_html__( 'My Groups %s', 'buddypress' ), '<span>' . bp_get_total_group_count_for_user( bp_loggedin_user_id() ) . '</span>' );
     114                                ?>
     115                            </a>
     116                        </li>
    120117
    121118                    <?php endif; ?>
     
    135132
    136133                    <li id="activity-favorites">
    137                         <a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/favorites/'; ?>">
     134                        <a href="<?php bp_loggedin_user_link( array( bp_get_activity_slug(), 'favorites' ) ); ?>">
    138135                            <?php
    139136                            /* translators: %s: number of favorites */
    140                             printf( __( 'My Favorites %s', 'buddypress' ), '<span>' . bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) . '</span>' );
     137                            printf( esc_html__( 'My Favorites %s', 'buddypress' ), '<span>' . bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) . '</span>' );
    141138                            ?>
    142139                        </a>
     
    157154
    158155                    <li id="activity-mentions">
    159                         <a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/'; ?>">
    160                             <?php _e( 'Mentions', 'buddypress' ); ?>
     156                        <a href="<?php bp_loggedin_user_link( array( bp_get_activity_slug(), 'mentions' ) ); ?>">
     157                            <?php esc_html_e( 'Mentions', 'buddypress' ); ?>
    161158                            <?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?>
    162159                                &nbsp;
     
    165162                                        <?php
    166163                                        /* translators: %s: new mentions count */
    167                                         printf( _nx( '%s new', '%s new', bp_get_total_mention_count_for_user( bp_loggedin_user_id() ), 'Number of new activity mentions', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) );
     164                                        printf( esc_html( _nx( '%s new', '%s new', bp_get_total_mention_count_for_user( bp_loggedin_user_id() ), 'Number of new activity mentions', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) );
    168165                                        ?>
    169166                                    </span>
Note: See TracChangeset for help on using the changeset viewer.