Skip to content

Commit

Permalink
i18n and escaping improvements when building toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Nov 15, 2024
1 parent f0658d4 commit 0135215
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions includes/network-toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,9 +895,9 @@ public function add_invites_menu( $wp_admin_bar ) {
* INVITATIONS
*/

$title = 'Invitations';
$title = __( 'Invitations', 'commons-in-a-box' );
if ( ! empty( $invites['groups'] ) ) {
$title .= '<span class="see-all pull-right"><a class="regular" href="' . esc_attr( bp_loggedin_user_url( bp_members_get_path_chunks( [ bp_get_groups_slug(), 'invites' ] ) ) ) . '">' . __( 'See All Invites', 'commons-in-a-box' ) . '</a></span>';
$title .= '<span class="see-all pull-right"><a class="regular" href="' . esc_attr( bp_loggedin_user_url( bp_members_get_path_chunks( [ bp_get_groups_slug(), 'invites' ] ) ) ) . '">' . esc_html__( 'See All Invites', 'commons-in-a-box' ) . '</a></span>';
}
// "Invitations" title
$wp_admin_bar->add_node(
Expand Down Expand Up @@ -934,7 +934,7 @@ public function add_invites_menu( $wp_admin_bar ) {
$title .= '<div class="col-sm-18"><p class="item-title"><a class="bold" href="' . esc_url( bp_get_group_url( $group ) ) . '">' . esc_html( stripslashes( $group->name ) ) . '</a></p>';

// accept/reject buttons
$title .= '<p class="actions clearfix"><a class="btn btn-primary link-btn accept" href="' . bp_get_group_accept_invite_link( $group ) . '">' . __( 'Accept', 'commons-in-a-box' ) . '</a> &nbsp; <a class="btn btn-default link-btn reject" href="' . bp_get_group_reject_invite_link( $group ) . '">' . __( 'Reject', 'commons-in-a-box' ) . '</a></p></div></div>';
$title .= '<p class="actions clearfix"><a class="btn btn-primary link-btn accept" href="' . esc_url( bp_get_group_accept_invite_link( $group ) ) . '">' . __( 'Accept', 'commons-in-a-box' ) . '</a> &nbsp; <a class="btn btn-default link-btn reject" href="' . bp_get_group_reject_invite_link( $group ) . '">' . esc_html__( 'Reject', 'commons-in-a-box' ) . '</a></p></div></div>';

$wp_admin_bar->add_node(
array(
Expand All @@ -956,7 +956,7 @@ public function add_invites_menu( $wp_admin_bar ) {
array(
'parent' => 'invites',
'id' => 'group-invites-none',
'title' => '<div class="row"><div class="col-sm-24"><p>No new invitations.</p></div></div>',
'title' => '<div class="row"><div class="col-sm-24"><p>' . esc_html__( 'No new invitations.', 'commons-in-a-box' ) . '</p></div></div>',
'meta' => array(
'class' => 'nav-no-items nav-content-item',
),
Expand All @@ -979,7 +979,7 @@ public function add_messages_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu(
array(
'id' => 'messages',
'title' => '<span class="toolbar-item-icon fa fa-envelope" aria-hidden="true"></span><span class="sr-only">Messages</span>' . $total_count,
'title' => '<span class="toolbar-item-icon fa fa-envelope" aria-hidden="true"></span><span class="sr-only">' . esc_html__( 'Messages', 'commons-in-a-box' ) . '</span>' . $total_count,
'meta' => array(
'class' => 'hidden-xs',
'tabindex' => 0,
Expand Down Expand Up @@ -1011,16 +1011,16 @@ public function add_messages_menu( $wp_admin_bar ) {
) . '" alt="Profile picture of ' . $messages_template->thread->last_sender_id . '"/></a></div></div>';

// subject
$title .= '<div class="col-sm-18"><p class="item"><a class="bold" href="' . bp_get_message_thread_view_link() . '">' . bp_create_excerpt( bp_get_message_thread_subject(), 30 ) . '</a>';
$title .= '<div class="col-sm-18"><p class="item"><a class="bold" href="' . esc_url( bp_get_message_thread_view_link() ) . '">' . esc_html( bp_create_excerpt( bp_get_message_thread_subject(), 30 ) ) . '</a>';

// last sender
$title .= '<span class="last-sender"><a href="' . bp_members_get_user_url( $messages_template->thread->last_sender_id ) . '">' . bp_core_get_user_displayname( $messages_template->thread->last_sender_id ) . '</a></span></p>';
$title .= '<span class="last-sender"><a href="' . esc_url( bp_members_get_user_url( $messages_template->thread->last_sender_id ) ) . '">' . esc_html( bp_core_get_user_displayname( $messages_template->thread->last_sender_id ) ) . '</a></span></p>';

// date and time
$title .= '<p class="message-excerpt">' . bp_format_time( strtotime( $messages_template->thread->last_message_date ) ) . '<br />';

// Message excerpt
$title .= wp_strip_all_tags( bp_create_excerpt( $messages_template->thread->last_message_content, 75 ) ) . ' <a class="message-excerpt-see-more" href="' . bp_get_message_thread_view_link() . '">' . __( 'See More', 'commons-in-a-box' ) . '<span class="sr-only">' . bp_create_excerpt( bp_get_message_thread_subject(), 30 ) . '</span></a></p></div></div>';
$title .= esc_html( wp_strip_all_tags( bp_create_excerpt( $messages_template->thread->last_message_content, 75 ) ) ) . ' <a class="message-excerpt-see-more" href="' . esc_url( bp_get_message_thread_view_link() ) . '">' . esc_html__( 'See More', 'commons-in-a-box' ) . '<span class="sr-only">' . esc_html( bp_create_excerpt( bp_get_message_thread_subject(), 30 ) ) . '</span></a></p></div></div>';

$wp_admin_bar->add_node(
array(
Expand All @@ -1043,7 +1043,7 @@ public function add_messages_menu( $wp_admin_bar ) {
array(
'parent' => 'messages',
'id' => 'messages-none',
'title' => '<div class="row"><div class="col-sm-24"><p>' . __( 'No new messages.', 'commons-in-a-box' ) . '</p></div></div>',
'title' => '<div class="row"><div class="col-sm-24"><p>' . esc_html__( 'No new messages.', 'commons-in-a-box' ) . '</p></div></div>',
'meta' => array(
'class' => 'nav-content-item nav-no-items',
),
Expand All @@ -1056,7 +1056,7 @@ public function add_messages_menu( $wp_admin_bar ) {
array(
'parent' => 'messages',
'id' => 'messages-more',
'title' => '<span class="see-all">' . __( 'See All Messages', 'commons-in-a-box' ) . '</span>',
'title' => '<span class="see-all">' . esc_html__( 'See All Messages', 'commons-in-a-box' ) . '</span>',
'href' => trailingslashit( bp_loggedin_user_url( bp_members_get_path_chunks( [ bp_get_messages_slug() ] ) ) ),
'meta' => array(
'class' => 'menu-bottom-link',
Expand All @@ -1072,7 +1072,7 @@ public function add_activity_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu(
array(
'id' => 'activity',
'title' => sprintf( '<span class="toolbar-item-name fa fa-bullhorn" aria-hidden="true"></span><span class="sr-only">%s</span>', __( 'Activity', 'commons-in-a-box' ) ),
'title' => sprintf( '<span class="toolbar-item-name fa fa-bullhorn" aria-hidden="true"></span><span class="sr-only">%s</span>', esc_html__( 'Activity', 'commons-in-a-box' ) ),
'meta' => array(
'class' => 'hidden-xs',
'tabindex' => 0,
Expand Down

0 comments on commit 0135215

Please sign in to comment.