Skip to:
Content

BuddyPress.org

Changeset 4569


Ignore:
Timestamp:
06/27/2011 12:36:51 PM (13 years ago)
Author:
boonebgorges
Message:

Migrates User Admin moderation menu to the WP Admin Bar. References #3294

File:
1 edited

Legend:

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

    r4567 r4569  
    9696add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_menu', 4 );
    9797
     98function bp_members_user_admin_menu() {
     99    global $wp_admin_bar;
     100
     101    // Only show if viewing a user
     102    if ( !bp_is_user() )
     103        return false;
     104
     105    // Don't show this menu to non site admins or if you're viewing your own profile
     106    if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
     107        return false;
     108
     109    // Add the top-level User Admin button
     110    $wp_admin_bar->add_menu( array(
     111        'id'    => 'user-admin',
     112        'title' => __( 'User Admin', 'buddypress' ),
     113        'href'  => bp_displayed_user_domain()
     114    ) );
     115
     116    // User Admin > Edit this user's profile
     117    $wp_admin_bar->add_menu( array(
     118        'parent' => 'user-admin',
     119        'id'     => 'edit-profile',
     120        'title'  => sprintf( __( "Edit %s's Profile", 'buddypress' ), bp_get_displayed_user_fullname() ),
     121        'href'   => bp_get_members_component_link( 'profile', 'edit' )
     122    ) );
     123   
     124    // User Admin > Edit this user's avatar
     125    $wp_admin_bar->add_menu( array(
     126        'parent' => 'user-admin',
     127        'id'     => 'change-avatar',
     128        'title'  => sprintf( __( "Edit %s's Avatar", 'buddypress' ), bp_get_displayed_user_fullname() ),
     129        'href'   => bp_get_members_component_link( 'profile', 'change-avatar' )
     130    ) );
     131   
     132    // User Admin > Edit this user's avatar
     133    $wp_admin_bar->add_menu( array(
     134        'parent' => 'user-admin',
     135        'id'     => 'change-avatar',
     136        'title'  => sprintf( __( "Edit %s's Avatar", 'buddypress' ), bp_get_displayed_user_fullname() ),
     137        'href'   => bp_get_members_component_link( 'profile', 'change-avatar' )
     138    ) );
     139   
     140    // User Admin > Spam/unspam
     141    if ( !bp_core_is_user_spammer( bp_displayed_user_id() ) ) {
     142        $wp_admin_bar->add_menu( array(
     143            'parent' => 'user-admin',
     144            'id'     => 'spam-user',
     145            'title'  => __( "Mark as Spammer", 'buddypress' ),
     146            'href'   => wp_nonce_url( bp_displayed_user_domain() . 'admin/mark-spammer/', 'mark-unmark-spammer' ),
     147            'meta'   => array( 'onclick' => 'confirm(" ' . __( 'Are you sure you want to mark this user as a spammer?', 'buddypress' ) . '");' )
     148        ) );   
     149    } else {
     150        $wp_admin_bar->add_menu( array(
     151            'parent' => 'user-admin',
     152            'id'     => 'unspam-user',
     153            'title'  => __( "Not a Spammer", 'buddypress' ),
     154            'href'   => wp_nonce_url( bp_displayed_user_domain() . 'admin/unmark-spammer/', 'mark-unmark-spammer' ),
     155            'meta'   => array( 'onclick' => 'confirm(" ' . __( 'Are you sure you want to mark this user as not a spammer?', 'buddypress' ) . '");' )
     156        ) );
     157    }
     158   
     159    // User Admin > Delete Account
     160    $wp_admin_bar->add_menu( array(
     161        'parent' => 'user-admin',
     162        'id'     => 'delete-user',
     163        'title'  => sprintf( __( "Delete %s's Account", 'buddypress' ), bp_get_displayed_user_fullname() ),
     164        'href'   => wp_nonce_url( bp_displayed_user_domain() . 'admin/delete-user/', 'delete-user' ),
     165        'meta'   => array( 'onclick' => 'confirm(" ' . __( "Are you sure you want to delete this user's account?", 'buddypress' ) . '");' )
     166    ) );
     167}
     168add_action( 'bp_setup_admin_bar', 'bp_members_user_admin_menu', 99 );
     169
    98170/**
    99171 * Make sure the logout link is at the bottom of the "My Account" menu
Note: See TracChangeset for help on using the changeset viewer.