Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/01/2023 04:04:56 PM (3 years ago)
Author:
dcavins
Message:

Introduce BP_Members_Invitations_Component.

Introduce a slim BP_Members_Invitations_Component
to handle the addition and management of member and admin bar navigation items for the member invitations feature.

Fixes #9013.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-adminbar.php

    r13614 r13629  
    281281}
    282282add_action( 'add_admin_bar_menus', 'bp_members_remove_edit_page_menu' );
    283 
    284 /**
    285  * Add the "Invitations" menu and submenus.
    286  *
    287  * @since 8.0.0
    288  *
    289  * @global WP_Admin_Bar $wp_admin_bar WordPress object implementing a Toolbar API.
    290  */
    291 function bp_members_admin_bar_add_invitations_menu() {
    292         global $wp_admin_bar;
    293 
    294         // Bail if this is an ajax request.
    295         if ( wp_doing_ajax() ) {
    296                 return;
    297         }
    298 
    299         if ( bp_current_user_can( 'bp_members_invitations_view_screens' ) ) {
    300                 $bp          = buddypress();
    301                 $invite_slug = bp_get_members_invitations_slug();
    302 
    303                 $wp_admin_bar->add_node(
    304                         array(
    305                                 'id'     => $bp->my_account_menu_id . '-invitations',
    306                                 'parent' => $bp->my_account_menu_id,
    307                                 'title'  => __( 'Invitations', 'buddypress' ),
    308                                 'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $invite_slug ) ) ),
    309                                 'meta'   => array(
    310                                         'class'  => 'ab-sub-secondary'
    311                                 )
    312                         )
    313                 );
    314 
    315                 if ( bp_current_user_can( 'bp_members_invitations_view_send_screen' ) ) {
    316                         $wp_admin_bar->add_node(
    317                                 array(
    318                                         'id'     => $bp->my_account_menu_id . '-invitations-send',
    319                                         'parent' => $bp->my_account_menu_id . '-invitations',
    320                                         'title'  => __( 'Send Invites', 'buddypress' ),
    321                                         'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $invite_slug, 'send-invites' ) ) ),
    322                                         'meta'   => array(
    323                                                 'class'  => 'ab-sub-secondary'
    324                                         )
    325                                 )
    326                         );
    327                 }
    328 
    329                 $wp_admin_bar->add_node(
    330                         array(
    331                                 'id'     => $bp->my_account_menu_id . '-invitations-list',
    332                                 'parent' => $bp->my_account_menu_id . '-invitations',
    333                                 'title'  => __( 'Pending Invites', 'buddypress' ),
    334                                 'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $invite_slug, 'list-invites' ) ) ),
    335                                 'meta'   => array(
    336                                         'class'  => 'ab-sub-secondary'
    337                                 )
    338                         )
    339                 );
    340         }
    341 }
    342 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_add_invitations_menu', 90 );
Note: See TracChangeset for help on using the changeset viewer.