Changeset 8441 for trunk/src/bp-members/bp-members-admin.php
- Timestamp:
- 05/21/2014 10:36:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-admin.php
r8432 r8441 1 1 <?php 2 2 3 // Exit if accessed directly 3 4 if ( !defined( 'ABSPATH' ) ) exit; … … 65 66 */ 66 67 public static function register_members_admin() { 67 if ( ! is_admin() )68 if ( ! is_admin() ) { 68 69 return; 70 } 69 71 70 72 $bp = buddypress(); 71 73 72 if ( empty( $bp->members->admin ) ) {74 if ( empty( $bp->members->admin ) ) { 73 75 $bp->members->admin = new self; 74 76 } … … 109 111 $this->user_page = ''; 110 112 113 // The Show Profile Screen id 114 $this->user_profile = is_network_admin() ? 'users' : 'profile'; 115 116 // The current user id 117 $this->current_user_id = get_current_user_id(); 118 119 // The user id being edited 120 $this->user_id = 0; 121 122 // Is a member editing their own profile 123 $this->is_self_profile = false; 124 111 125 // The screen ids to load specific css for 112 126 $this->screen_id = array(); … … 115 129 $this->stats_metabox = new StdClass(); 116 130 117 // The WordPress edit user url 118 $this->edit_url = bp_get_admin_url( 'user-edit.php' ); 119 120 // BuddyPress edit user's profile url 121 $this->edit_profile_url = add_query_arg( 'page', 'bp-profile-edit', bp_get_admin_url( 'users.php' ) ); 131 // BuddyPress edit user's profile args 132 $this->edit_profile_args = array( 'page' => 'bp-profile-edit' ); 133 $this->edit_profile_url = ''; 134 $this->edit_url = ''; 122 135 123 136 // Data specific to signups … … 144 157 private function setup_actions() { 145 158 146 /** Extended Profile *****************************************/ 159 /** Extended Profile **************************************************/ 160 161 // Enqueue all admin JS and CSS 162 add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 147 163 148 164 // Add some page specific output to the <head> 149 add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999);165 add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); 150 166 151 167 // Add menu item to all users menu 152 add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); 153 154 // Enqueue all admin JS and CSS 155 add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 168 add_action( 'admin_menu', array( $this, 'admin_menus' ), 5 ); 169 add_action( 'network_admin_menu', array( $this, 'admin_menus' ), 5 ); 170 add_action( 'user_admin_menu', array( $this, 'user_profile_menu' ), 5 ); 156 171 157 172 // Create the Profile Navigation (Profile/Extended Profile) 158 add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 173 add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 174 add_action( 'show_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 159 175 160 176 // Add a row action to users listing 161 add_filter( bp_core_do_network_admin() ? 'ms_user_row_actions' : 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); 162 163 /** Signups **************************************************************/ 177 if ( bp_core_do_network_admin() ) { 178 add_filter( 'ms_user_row_actions', array( $this, 'row_actions' ), 10, 2 ); 179 add_action( 'admin_init', array( $this, 'add_edit_profile_url_filter' ) ); 180 add_action( 'wp_after_admin_bar_render', array( $this, 'remove_edit_profile_url_filter' ) ); 181 } 182 183 // Add user row actions for single site 184 add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); 185 186 /** Signups ***********************************************************/ 164 187 165 188 if ( is_admin() ) { 189 190 // Filter non multisite user query to remove sign-up users 166 191 if ( ! is_multisite() ) { 167 add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query' ),10, 1 );192 add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query' ), 10, 1 ); 168 193 } 169 194 170 195 // Reorganise the views navigation in users.php and signups page 171 196 if ( current_user_can( $this->capability ) ) { 172 add_filter( "views_{$this->users_screen}", array( $this, 'signup_filter_view' ),10, 1 );197 add_filter( "views_{$this->users_screen}", array( $this, 'signup_filter_view' ), 10, 1 ); 173 198 add_filter( 'set-screen-option', array( $this, 'signup_screen_options' ), 10, 3 ); 174 199 } … … 177 202 178 203 /** 179 * Create the All Users > Edit Profile and Signups submenus. 180 * 181 * @access public 182 * @since BuddyPress (2.0.0) 183 * 184 * @uses add_users_page() To add the Edit Profile page in Users section. 185 */ 186 public function admin_menus() { 187 188 // Manage user's profile 189 $hooks['user'] = $this->user_page = add_users_page( 190 __( 'Edit Profile', 'buddypress' ), 191 __( 'Edit Profile', 'buddypress' ), 192 'bp_moderate', 193 'bp-profile-edit', 194 array( &$this, 'user_admin' ) 195 ); 196 197 // Manage signups 198 $hooks['signups'] = $this->signups_page = add_users_page( 199 __( 'Manage Signups', 'buddypress' ), 200 __( 'Manage Signups', 'buddypress' ), 201 $this->capability, 202 'bp-signups', 203 array( &$this, 'signups_admin' ) 204 ); 205 206 $edit_page = 'user-edit'; 207 $this->users_page = 'users'; 208 209 if ( bp_core_do_network_admin() ) { 210 $edit_page .= '-network'; 211 $this->users_page .= '-network'; 212 $this->user_page .= '-network'; 213 $this->signups_page .= '-network'; 214 } 215 216 $this->screen_id = array( $edit_page, $this->user_page ); 217 218 foreach ( $hooks as $key => $hook ) { 219 add_action( "load-$hook", array( $this, $key . '_admin_load' ) ); 220 } 221 222 add_action( "admin_head-$this->user_page", array( $this, 'modify_admin_menu_highlight' ) ); 223 224 } 225 226 /** 227 * Highlight the Users menu if on Edit Profile. 228 * 229 * @access public 230 * @since BuddyPress (2.0.0) 231 */ 232 public function modify_admin_menu_highlight() { 233 global $plugin_page, $submenu_file; 234 235 // Only Show the All users menu 236 if ( $plugin_page = 'bp-profile-edit' ) { 237 $submenu_file = 'users.php'; 238 } 239 } 240 241 /** 242 * Remove the Edit Profile page. 243 * 244 * We add these pages in order to integrate with WP's Users panel, but 245 * we want them to show up as a row action of the WP panel, not as separate 246 * subnav items under the Users menu. 247 * 248 * @access public 249 * @since BuddyPress (2.0.0) 250 */ 251 public function admin_head() { 252 // Remove submenu to force using Profile Navigation 253 remove_submenu_page( 'users.php', 'bp-profile-edit' ); 254 } 255 256 /** Community Profile ************************************************/ 257 258 /** 259 * Add some specific styling to the Edit User and Edit User's Profile page. 260 * 261 * @access public 262 * @since BuddyPress (2.0.0) 263 */ 264 public function enqueue_scripts() { 265 if ( ! in_array( get_current_screen()->id, $this->screen_id ) ) { 266 return; 267 } 268 269 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 270 271 $css = $this->css_url . "admin{$min}.css"; 272 $css = apply_filters( 'bp_members_admin_css', $css ); 273 wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() ); 274 275 // Only load javascript for BuddyPress profile 276 if ( get_current_screen()->id == $this->user_page ) { 277 $js = $this->js_url . "admin{$min}.js"; 278 $js = apply_filters( 'bp_members_admin_js', $js ); 279 wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true ); 280 } 281 282 // Plugins may want to hook here to load some css/js 283 do_action( 'bp_members_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id ); 284 } 285 286 /** 287 * Create the Profile navigation in Edit User & Edit Profile pages. 288 * 289 * @access public 290 * @since BuddyPress (2.0.0) 291 */ 292 public function profile_nav( $user = null, $active = 'WordPress' ) { 293 294 if ( empty( $user->ID ) ) { 295 return; 296 } 297 298 // Don't display here if this is not where other BP 299 // administration takes place 300 if ( bp_core_do_network_admin() && ! is_network_admin() ) { 301 return; 302 } 303 304 $query_args = array( 'user_id' => $user->ID ); 305 306 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { 307 $query_args['wp_http_referer'] = urlencode( stripslashes_deep( $_REQUEST['wp_http_referer'] ) ); 308 } 309 310 $community_url = add_query_arg( $query_args, $this->edit_profile_url ); 311 $wordpress_url = add_query_arg( $query_args, $this->edit_url ); 312 313 $bp_active = false; 314 $wp_active = ' nav-tab-active'; 315 if ( 'BuddyPress' === $active ) { 316 $bp_active = ' nav-tab-active'; 317 $wp_active = false; 318 } ?> 319 320 <h2 id="profile-nav" class="nav-tab-wrapper"> 321 <?php 322 /** 323 * In configs where BuddyPress is not network activated, as regular 324 * admins do not have the capacity to edit other users, we must add 325 * this check. 326 */ 327 ?> 328 <?php if ( current_user_can( 'edit_user' ) ) : ?> 329 <a class="nav-tab<?php echo esc_attr( $wp_active ); ?>" href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'Profile', 'buddypress' ); ?></a> 330 <?php endif; ?> 331 <a class="nav-tab<?php echo esc_attr( $bp_active ); ?>" href="<?php echo esc_url( $community_url );?>"><?php _e( 'Extended Profile', 'buddypress' ); ?></a> 332 </h2> 333 334 <?php 335 } 336 337 /** 338 * Set up the user's profile admin page. 339 * 340 * Loaded before the page is rendered, this function does all initial 341 * setup, including: processing form requests, registering contextual 342 * help, and setting up screen options. 343 * 344 * @access public 345 * @since BuddyPress (2.0.0) 346 */ 347 public function user_admin_load() { 348 349 if ( ! $user_id = intval( $_GET['user_id'] ) ) { 350 wp_die( __( 'No users were found', 'buddypress' ) ); 351 } 352 353 // Build redirection URL 354 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] ); 355 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; 356 357 if ( ! empty( $_REQUEST['user_status'] ) ) { 358 $spam = ( 'spam' == $_REQUEST['user_status'] ) ? true : false ; 359 360 if ( $spam != bp_is_user_spammer( $user_id ) ) { 361 $doaction = $_REQUEST['user_status']; 362 } 363 } 364 365 // Call an action for plugins to hook in early 366 do_action_ref_array( 'bp_members_admin_load', array( $doaction, $_REQUEST ) ); 367 368 // Allowed actions 369 $allowed_actions = apply_filters( 'bp_members_admin_allowed_actions', array( 'update', 'delete_avatar', 'spam', 'ham' ) ); 370 371 // Prepare the display of the Community Profile screen 372 if ( ! in_array( $doaction, $allowed_actions ) ) { 373 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 374 375 get_current_screen()->add_help_tab( array( 376 'id' => 'bp-profile-edit-overview', 377 'title' => __( 'Overview', 'buddypress' ), 378 'content' => 379 '<p>' . __( 'This is the admin view of a user's profile.', 'buddypress' ) . '</p>' . 380 '<p>' . __( 'In the main column, you can edit the fields of the user's extended profile.', 'buddypress' ) . '</p>' . 381 '<p>' . __( 'In the right-hand column, you can update the user's status, delete the user's avatar, and view recent statistics.', 'buddypress' ) . '</p>' 382 ) ); 383 384 // Help panel - sidebar links 385 get_current_screen()->set_help_sidebar( 386 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 387 '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-user-profiles/">Managing Profiles</a>', 'buddypress' ) . '</p>' . 388 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 389 ); 390 391 // Register metaboxes for the edit screen. 392 add_meta_box( 'submitdiv', _x( 'Status', 'members user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_status_metabox' ), get_current_screen()->id, 'side', 'core' ); 393 394 // In case xprofile is not active 395 $this->stats_metabox->context = 'normal'; 396 $this->stats_metabox->priority = 'core'; 397 398 /** 399 * xProfile Hooks to load the profile fields if component is active 400 * Plugins should not use this hook, please use 'bp_members_admin_user_metaboxes' instead 401 */ 402 do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) ); 403 404 // If xProfile is inactive, difficult to know what's profile we're on 405 $display_name = false; 406 if ( 'normal' == $this->stats_metabox->context ) { 407 $display_name = ' - ' . esc_html( bp_core_get_user_displayname( $user_id ) ); 408 } 409 410 // User Stat metabox 411 add_meta_box( 'bp_members_admin_user_stats', _x( 'Stats' . $display_name, 'members user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_stats_metabox' ), get_current_screen()->id, sanitize_key( $this->stats_metabox->context ), sanitize_key( $this->stats_metabox->priority ) ); 412 413 // Custom metabox ? 414 do_action( 'bp_members_admin_user_metaboxes' ); 415 416 // Enqueue javascripts 417 wp_enqueue_script( 'postbox' ); 418 wp_enqueue_script( 'dashboard' ); 419 420 // Spam or Ham user 421 } else if ( in_array( $doaction, array( 'spam', 'ham' ) ) ) { 422 423 check_admin_referer( 'edit-bp-profile_' . $user_id ); 424 425 if ( bp_core_process_spammer_status( $user_id, $doaction ) ) { 426 $redirect_to = add_query_arg( 'updated', $doaction, $redirect_to ); 427 } else { 428 $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); 429 } 430 431 bp_core_redirect( $redirect_to ); 432 433 // Update other stuff once above ones are done 204 * Get the user ID 205 * 206 * Look for $_GET['user_id']. If anything else, force the user ID to the 207 * current user's ID so they aren't left without a user to edit. 208 * 209 * @since BuddyPress (2.1.0) 210 * 211 * @return int 212 */ 213 private function get_user_id() { 214 215 // No user ID to start 216 $user_id = 0; 217 218 // We'll need a user ID when not on the user admin 219 if ( ! empty( $_GET['user_id'] ) ) { 220 $user_id = $_GET['user_id']; 221 222 // Assume the current user ID 434 223 } else { 435 $this->redirect = $redirect_to; 436 437 do_action_ref_array( 'bp_members_admin_update_user', array( $doaction, $user_id, $_REQUEST, $this->redirect ) ); 438 439 bp_core_redirect( $this->redirect ); 440 } 441 } 442 443 /** 444 * Display the user's profile. 445 * 446 * @access public 447 * @since BuddyPress (2.0.0) 448 */ 449 public function user_admin() { 450 451 if ( ! current_user_can( 'bp_moderate' ) ) { 452 die( '-1' ); 453 } 454 455 $user = get_user_to_edit( $_GET['user_id'] ); 456 457 // Construct URL for form 458 $form_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] ); 459 $form_url = esc_url( add_query_arg( 'action', 'update', $form_url ) ); 460 $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $_REQUEST['wp_http_referer'] ); 461 462 // Prepare notice for admin 463 $notice = array(); 224 $user_id = get_current_user_id(); 225 } 226 227 return intval( $user_id ); 228 } 229 230 /** 231 * Can the current user edit the one displayed 232 * 233 * self profile editing / or bp_moderate check. 234 * This might be replaced by more granular capabilities 235 * in the future. 236 * 237 * @access public 238 * @since BuddyPress (2.1.0) 239 */ 240 private function member_can_edit( $user_id = 0 ) { 241 $retval = false; 242 243 // Bail if no user ID was passed 244 if ( empty( $user_id ) ) { 245 return $retval; 246 } 247 248 // Member can edit if they are viewing their own profile 249 if ( $this->current_user_id === $user_id ) { 250 $retval = true; 251 252 // Trust the 'bp_moderate' capability 253 } else { 254 $retval = bp_current_user_can( 'bp_moderate' ); 255 } 256 257 return $retval; 258 } 259 260 /** 261 * Get admin notice when saving a user or member profile 262 * 263 * @since BuddyPress (2.1.0) 264 * 265 * @return array 266 */ 267 private function get_user_notice() { 464 268 465 269 if ( ! empty( $_REQUEST['updated'] ) ) { … … 533 337 } 534 338 535 if ( ! empty( $notice ) ) : 536 if ( 'updated' === $notice['class'] ) : ?> 537 <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>"> 538 <?php else: ?> 539 <div class="<?php echo esc_attr( $notice['class'] ); ?>"> 339 return $notice; 340 } 341 342 /** 343 * Create the /user/ admin Profile submenus for all members. 344 * 345 * @access public 346 * @since BuddyPress (2.1.0) 347 * 348 * @uses add_submenu_page() To add the Edit Profile page in Profile section. 349 */ 350 public function user_profile_menu() { 351 352 // Setup the hooks array 353 $hooks = array(); 354 355 // Add the faux "Edit Profile" submenu page 356 $hooks['user'] = $this->user_page = add_submenu_page( 357 'profile.php', 358 __( 'Edit Profile', 'buddypress' ), 359 __( 'Edit Profile', 'buddypress' ), 360 'exist', 361 'bp-profile-edit', 362 array( $this, 'user_admin' ) 363 ); 364 365 // Setup the screen ID's 366 $this->screen_id = array( 367 $this->user_page . '-user', 368 $this->user_profile . '-user' 369 ); 370 371 // Loop through new hooks and add method actions 372 foreach ( $hooks as $key => $hook ) { 373 add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) ); 374 } 375 376 // Add the profile_admin_head method to proper admin_head actions 377 add_action( "admin_head-{$this->user_page}", array( $this, 'profile_admin_head' ) ); 378 add_action( "admin_head-profile.php", array( $this, 'profile_admin_head' ) ); 379 } 380 381 /** 382 * Create the All Users / Profile > Edit Profile and All Users Signups submenus. 383 * 384 * @access public 385 * @since BuddyPress (2.0.0) 386 * 387 * @uses add_submenu_page() To add the Edit Profile page in Users/Profile section. 388 */ 389 public function admin_menus() { 390 391 // Setup the hooks array 392 $hooks = array(); 393 394 // Manage user's profile 395 $hooks['user'] = $this->user_page = add_submenu_page( 396 $this->user_profile . '.php', 397 __( 'Edit Profile', 'buddypress' ), 398 __( 'Edit Profile', 'buddypress' ), 399 'read', 400 'bp-profile-edit', 401 array( $this, 'user_admin' ) 402 ); 403 404 // Only show sign-ups where they belong 405 if ( ! is_multisite() || is_network_admin() ) { 406 407 // Manage signups 408 $hooks['signups'] = $this->signups_page = add_users_page( 409 __( 'Manage Signups', 'buddypress' ), 410 __( 'Manage Signups', 'buddypress' ), 411 $this->capability, 412 'bp-signups', 413 array( $this, 'signups_admin' ) 414 ); 415 } 416 417 $edit_page = 'user-edit'; 418 $profile_page = 'profile'; 419 $this->users_page = 'users'; 420 421 // Self profile check is needed for this pages 422 $page_head = array( 423 $edit_page . '.php', 424 $profile_page . '.php', 425 $this->user_page, 426 $this->users_page . '.php', 427 ); 428 429 // Append '-network' to each array item if in network admin 430 if ( is_network_admin() ) { 431 $edit_page .= '-network'; 432 $profile_page .= '-network'; 433 $this->user_page .= '-network'; 434 $this->users_page .= '-network'; 435 $this->signups_page .= '-network'; 436 } 437 438 // Setup the screen ID's 439 $this->screen_id = array( 440 $edit_page, 441 $this->user_page, 442 $profile_page 443 ); 444 445 // Loop through new hooks and add method actions 446 foreach ( $hooks as $key => $hook ) { 447 add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) ); 448 } 449 450 // Add the profile_admin_head method to proper admin_head actions 451 foreach ( $page_head as $head ) { 452 add_action( "admin_head-{$head}", array( $this, 'profile_admin_head' ) ); 453 } 454 } 455 456 /** 457 * Highlight the Users menu if on Edit Profile. 458 * 459 * + Check if on the user's admin profile 460 * 461 * @access public 462 * @since BuddyPress (2.1.0) 463 */ 464 public function profile_admin_head() { 465 global $submenu_file, $parent_file; 466 467 // Is the user editing their own profile? 468 if ( is_user_admin() || ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) ) { 469 $this->is_self_profile = true; 470 471 // Is the user attempting to edit their own profile 472 } else { 473 $this->is_self_profile = (bool) ( $this->get_user_id() === $this->current_user_id ); 474 } 475 476 // Force the parent file to users.php to open the correct top level menu 477 $parent_file = 'users.php'; 478 $submenu_file = 'users.php'; 479 480 // Editing your own profile, so recheck some vars 481 if ( true === $this->is_self_profile ) { 482 483 // Use profile.php as the edit page 484 $edit_page = 'profile.php'; 485 486 // Set profile.php as the parent & sub files to correct the menu nav 487 if ( is_blog_admin() || is_user_admin() ) { 488 $parent_file = 'profile.php'; 489 $submenu_file = 'profile.php'; 490 } 491 492 // Not editing yourserf, so use user-edit.php 493 } else { 494 $edit_page = 'user-edit.php'; 495 } 496 497 if ( is_user_admin() ) { 498 $this->edit_profile_url = add_query_arg( $this->edit_profile_args, user_admin_url( 'profile.php' ) ); 499 $this->edit_url = user_admin_url( 'profile.php' ); 500 501 } elseif ( is_blog_admin() ) { 502 $this->edit_profile_url = add_query_arg( $this->edit_profile_args, admin_url( 'users.php' ) ); 503 $this->edit_url = admin_url( $edit_page ); 504 505 } elseif ( is_network_admin() ) { 506 $this->edit_profile_url = add_query_arg( $this->edit_profile_args, network_admin_url( 'users.php' ) ); 507 $this->edit_url = network_admin_url( $edit_page ); 508 } 509 } 510 511 /** 512 * Remove the Edit Profile page. 513 * 514 * We add these pages in order to integrate with WP's Users panel, but 515 * we want them to show up as a row action of the WP panel, not as separate 516 * subnav items under the Users menu. 517 * 518 * @access public 519 * @since BuddyPress (2.0.0) 520 */ 521 public function admin_head() { 522 remove_submenu_page( 'users.php', 'bp-profile-edit' ); 523 remove_submenu_page( 'profile.php', 'bp-profile-edit' ); 524 } 525 526 /** Community Profile *****************************************************/ 527 528 /** 529 * Add some specific styling to the Edit User and Edit User's Profile page. 530 * 531 * @access public 532 * @since BuddyPress (2.0.0) 533 */ 534 public function enqueue_scripts() { 535 if ( ! in_array( get_current_screen()->id, $this->screen_id ) ) { 536 return; 537 } 538 539 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 540 541 $css = $this->css_url . "admin{$min}.css"; 542 $css = apply_filters( 'bp_members_admin_css', $css ); 543 wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() ); 544 545 // Only load javascript for BuddyPress profile 546 if ( get_current_screen()->id == $this->user_page ) { 547 $js = $this->js_url . "admin{$min}.js"; 548 $js = apply_filters( 'bp_members_admin_js', $js ); 549 wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true ); 550 } 551 552 // Plugins may want to hook here to load some css/js 553 do_action( 'bp_members_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id ); 554 } 555 556 /** 557 * Create the Profile navigation in Edit User & Edit Profile pages. 558 * 559 * @access public 560 * @since BuddyPress (2.0.0) 561 */ 562 public function profile_nav( $user = null, $active = 'WordPress' ) { 563 564 // Bail if no user ID exists here 565 if ( empty( $user->ID ) ) { 566 return; 567 } 568 569 // Add the user ID to query agruments when not editing yourself 570 if ( false === $this->is_self_profile ) { 571 $query_args = array( 'user_id' => $user->ID ); 572 } else { 573 $query_args = array(); 574 } 575 576 // Conditionally add a referer if it exists in the existing request 577 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { 578 $query_args['wp_http_referer'] = urlencode( stripslashes_deep( $_REQUEST['wp_http_referer'] ) ); 579 } 580 581 // Setup the two distinct "edit" URL's 582 $community_url = add_query_arg( $query_args, $this->edit_profile_url ); 583 $wordpress_url = add_query_arg( $query_args, $this->edit_url ); 584 585 $bp_active = false; 586 $wp_active = ' nav-tab-active'; 587 if ( 'BuddyPress' === $active ) { 588 $bp_active = ' nav-tab-active'; 589 $wp_active = false; 590 } ?> 591 592 <h2 id="profile-nav" class="nav-tab-wrapper"> 593 <?php 594 /** 595 * In configs where BuddyPress is not network activated, as regular 596 * admins do not have the capacity to edit other users, we must add 597 * this check. 598 */ 599 if ( current_user_can( 'edit_user', $user->ID ) ) : ?> 600 601 <a class="nav-tab<?php echo esc_attr( $wp_active ); ?>" href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'Profile', 'buddypress' ); ?></a> 602 540 603 <?php endif; ?> 604 605 <a class="nav-tab<?php echo esc_attr( $bp_active ); ?>" href="<?php echo esc_url( $community_url );?>"><?php _e( 'Extended Profile', 'buddypress' ); ?></a> 606 </h2> 607 608 <?php 609 } 610 611 /** 612 * Set up the user's profile admin page. 613 * 614 * Loaded before the page is rendered, this function does all initial 615 * setup, including: processing form requests, registering contextual 616 * help, and setting up screen options. 617 * 618 * @access public 619 * @since BuddyPress (2.0.0) 620 */ 621 public function user_admin_load() { 622 623 // Get the user ID 624 $user_id = $this->get_user_id(); 625 626 // can current user edit this profile ? 627 if ( ! $this->member_can_edit( $user_id ) ) { 628 wp_die( __( 'You cannot edit the requested user.', 'buddypress' ) ); 629 } 630 631 // Build redirection URL 632 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] ); 633 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; 634 635 if ( ! empty( $_REQUEST['user_status'] ) ) { 636 $spam = (bool) ( 'spam' === $_REQUEST['user_status'] ); 637 638 if ( $spam !== bp_is_user_spammer( $user_id ) ) { 639 $doaction = $_REQUEST['user_status']; 640 } 641 } 642 643 // Call an action for plugins to hook in early 644 do_action_ref_array( 'bp_members_admin_load', array( $doaction, $_REQUEST ) ); 645 646 // Allowed actions 647 $allowed_actions = apply_filters( 'bp_members_admin_allowed_actions', array( 'update', 'delete_avatar', 'spam', 'ham' ) ); 648 649 // Prepare the display of the Community Profile screen 650 if ( ! in_array( $doaction, $allowed_actions ) ) { 651 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 652 653 get_current_screen()->add_help_tab( array( 654 'id' => 'bp-profile-edit-overview', 655 'title' => __( 'Overview', 'buddypress' ), 656 'content' => 657 '<p>' . __( 'This is the admin view of a user's profile.', 'buddypress' ) . '</p>' . 658 '<p>' . __( 'In the main column, you can edit the fields of the user's extended profile.', 'buddypress' ) . '</p>' . 659 '<p>' . __( 'In the right-hand column, you can update the user's status, delete the user's avatar, and view recent statistics.', 'buddypress' ) . '</p>' 660 ) ); 661 662 // Help panel - sidebar links 663 get_current_screen()->set_help_sidebar( 664 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 665 '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-user-profiles/">Managing Profiles</a>', 'buddypress' ) . '</p>' . 666 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 667 ); 668 669 // Register metaboxes for the edit screen. 670 add_meta_box( 671 'submitdiv', 672 _x( 'Status', 'members user-admin edit screen', 'buddypress' ), 673 array( $this, 'user_admin_status_metabox' ), 674 get_current_screen()->id, 675 'side', 676 'core' 677 ); 678 679 // In case xprofile is not active 680 $this->stats_metabox->context = 'normal'; 681 $this->stats_metabox->priority = 'core'; 682 683 /** 684 * xProfile Hooks to load the profile fields if component is active 685 * Plugins should not use this hook, please use 'bp_members_admin_user_metaboxes' instead 686 */ 687 do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) ); 688 689 // If xProfile is inactive, difficult to know what's profile we're on 690 $display_name = ''; 691 if ( 'normal' === $this->stats_metabox->context ) { 692 $display_name = ' - ' . bp_core_get_user_displayname( $user_id ); 693 } 694 695 // User Stat metabox 696 add_meta_box( 697 'bp_members_admin_user_stats', 698 sprintf( _x( 'Stats%s', 'members user-admin edit screen', 'buddypress' ), $display_name ), 699 array( $this, 'user_admin_stats_metabox' ), 700 get_current_screen()->id, 701 sanitize_key( $this->stats_metabox->context ), 702 sanitize_key( $this->stats_metabox->priority ) 703 ); 704 705 /** 706 * Custom metabox ? 707 * Plugins can restrict metabox to "bp_moderate" admins checking 708 * the first argument ($this->is_self_profile) is false in their hook 709 * They can also restruct their metabox to self profile editing 710 * by cheking it set to true. 711 */ 712 do_action( 'bp_members_admin_user_metaboxes', $this->is_self_profile, $user_id ); 713 714 // Enqueue javascripts 715 wp_enqueue_script( 'postbox' ); 716 wp_enqueue_script( 'dashboard' ); 717 718 // Spam or Ham user 719 } elseif ( in_array( $doaction, array( 'spam', 'ham' ) ) && empty( $this->is_self_profile ) ) { 720 721 check_admin_referer( 'edit-bp-profile_' . $user_id ); 722 723 if ( bp_core_process_spammer_status( $user_id, $doaction ) ) { 724 $redirect_to = add_query_arg( 'updated', $doaction, $redirect_to ); 725 } else { 726 $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); 727 } 728 729 bp_core_redirect( $redirect_to ); 730 731 // Update other stuff once above ones are done 732 } else { 733 $this->redirect = $redirect_to; 734 735 do_action_ref_array( 'bp_members_admin_update_user', array( $doaction, $user_id, $_REQUEST, $this->redirect ) ); 736 737 bp_core_redirect( $this->redirect ); 738 } 739 } 740 741 /** 742 * Display the user's profile. 743 * 744 * @access public 745 * @since BuddyPress (2.0.0) 746 */ 747 public function user_admin() { 748 749 if ( ! bp_current_user_can( 'bp_moderate' ) && empty( $this->is_self_profile ) ) { 750 die( '-1' ); 751 } 752 753 // Get the user ID 754 $user_id = $this->get_user_id(); 755 $user = get_user_to_edit( $user_id ); 756 757 // Construct title 758 if ( true === $this->is_self_profile ) { 759 $title = __( 'Profile', 'buddypress' ); 760 } else { 761 $title = __( 'Edit User', 'buddypress' ); 762 } 763 764 // Construct URL for form 765 $form_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] ); 766 $form_url = add_query_arg( 'action', 'update', $form_url ); 767 $wp_http_referer = false; 768 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { 769 $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $_REQUEST['wp_http_referer'] ); 770 } 771 772 // Prepare notice for admin 773 $notice = $this->get_user_notice(); 774 775 if ( ! empty( $notice ) ) : ?> 776 777 <div <?php if ( 'updated' === $notice['class'] ) : ?>id="message" <?php endif; ?>class="<?php echo esc_attr( $notice['class'] ); ?>"> 778 541 779 <p><?php echo esc_html( $notice['message'] ); ?></p> 780 542 781 <?php if ( !empty( $wp_http_referer ) && ( 'updated' === $notice['class'] ) ) : ?> 782 543 783 <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php esc_html_e( '← Back to Users', 'buddypress' ); ?></a></p> 784 544 785 <?php endif; ?> 786 545 787 </div> 788 546 789 <?php endif; ?> 547 790 548 <div class="wrap" 791 <div class="wrap" id="community-profile-page"> 549 792 <?php screen_icon( 'users' ); ?> 550 <h2> 551 <?php 552 _e( 'Edit User', 'buddypress' ); 553 if ( current_user_can( 'create_users' ) ) { ?> 554 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a> 555 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 556 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a> 557 <?php } 558 ?> 793 <h2><?php echo esc_html( $title ); ?> 794 795 <?php if ( empty( $this->is_self_profile ) ) : ?> 796 797 <?php if ( current_user_can( 'create_users' ) ) : ?> 798 799 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a> 800 801 <?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?> 802 803 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a> 804 805 <?php endif; ?> 806 807 <?php endif; ?> 559 808 </h2> 560 809 … … 563 812 $this->profile_nav( $user, 'BuddyPress' ); ?> 564 813 565 <form action="<?php echo esc_ attr( $form_url ); ?>" id="your-profile" method="post">814 <form action="<?php echo esc_url( $form_url ); ?>" id="your-profile" method="post"> 566 815 <div id="poststuff"> 567 816 … … 589 838 590 839 <?php else : ?> 840 591 841 <p><?php printf( __( 'No user found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), esc_url( bp_get_admin_url( 'users.php' ) ) ); ?></p> 842 592 843 <?php endif; ?> 593 844 … … 615 866 } 616 867 617 if ( ( isset( $user->user_status ) && 2 == $user->user_status ) ) { 618 echo '<p class="not-activated">' . esc_html__( 'User account has not yet been activated', 'buddypress' ) . '</p><br/>'; 619 return; 620 } 621 ?> 868 // Bail if user has not been activated yet (how didy ou get here?) 869 if ( isset( $user->user_status ) && ( 2 == $user->user_status ) ) : ?> 870 871 <p class="not-activated"><?php esc_html_e( 'User account has not yet been activated', 'buddypress' ); ?></p><br/> 872 873 <?php return; 874 875 endif; ?> 622 876 623 877 <div class="submitbox" id="submitcomment"> … … 637 891 * admins as spammers. 638 892 */ 639 if ( ( get_current_user_id() !== $user->ID ) && ( ! in_array( $user->user_login, get_super_admins() ) ) && empty( $this->subsite_activated ) || ( ! empty( $this->subsite_activated ) && current_user_can( 'manage_network_users' ) ) ) : ?> 893 if ( ( empty( $this->is_self_profile ) && ( ! in_array( $user->user_login, get_super_admins() ) ) && empty( $this->subsite_activated ) ) || ( ! empty( $this->subsite_activated ) && current_user_can( 'manage_network_users' ) ) ) : ?> 894 640 895 <div class="misc-pub-section" id="comment-status-radio"> 641 896 <label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( $is_spammer, false ); ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></label><br /> 642 897 <label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( $is_spammer, true ); ?>><?php esc_html_e( 'Spammer', 'buddypress' ); ?></label> 643 898 </div> 899 644 900 <?php endif ;?> 645 901 646 902 <div class="misc-pub-section curtime misc-pub-section-last"> 647 903 <?php 904 648 905 // translators: Publish box date format, see http://php.net/date 649 906 $datef = __( 'M j, Y @ G:i', 'buddypress' ); … … 680 937 */ 681 938 public function user_admin_spammer_metabox( $user = null ) { 682 939 ?> 683 940 <p><?php printf( __( '%s has been marked as a spammer. All BuddyPress data associated with the user has been removed', 'buddypress' ), esc_html( bp_core_get_user_displayname( $user->ID ) ) ) ;?></p> 684 941 <?php 685 942 } 686 943 … … 695 952 public function user_admin_stats_metabox( $user = null ) { 696 953 954 // Bail if no user ID 697 955 if ( empty( $user->ID ) ) { 698 956 return; … … 712 970 713 971 <ul> 714 <li class="bp-members-profile-stats"><?php printf( __( 'Last active: <strong>%1$s</strong>', 'buddypress' ), $date); ?></li>972 <li class="bp-members-profile-stats"><?php printf( __( 'Last active: %1$s', 'buddypress' ), '<strong>' . $date . '</strong>' ); ?></li> 715 973 716 974 <?php … … 737 995 public function row_actions( $actions = '', $user = null ) { 738 996 739 $edit_profile = add_query_arg( array( 740 'user_id' => $user->ID, 741 'wp_http_referer' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 742 ), $this->edit_profile_url ); 743 744 $edit_profile_link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $edit_profile ), esc_html__( 'Extended', 'buddypress' ) ); 745 746 /** 747 * Check the edit action is available 748 * and preserve the order edit | profile | remove/delete 749 */ 750 if ( ! empty( $actions['edit'] ) ) { 751 $edit_action = $actions['edit']; 752 unset( $actions['edit'] ); 753 754 $new_edit_actions = array( 755 'edit' => $edit_action, 756 'edit-profile' => $edit_profile_link, 757 ); 758 // if not available simply add the edit profile action 759 } else { 760 $new_edit_actions = array( 'edit-profile' => $edit_profile_link ); 761 } 762 763 return array_merge( $new_edit_actions, $actions ); 764 } 765 766 /** Signups Management ***********************************************/ 997 // Bail if no user ID 998 if ( empty( $user->ID ) ) { 999 return; 1000 } 1001 1002 // Setup args array 1003 $args = array(); 1004 1005 // Add the user ID if it's not for the current user 1006 if ( $user->ID !== $this->current_user_id ) { 1007 $args['user_id'] = $user->ID; 1008 } 1009 1010 // Add the referer 1011 $args['wp_http_referer'] = urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ); 1012 1013 // Add the "Extended" link if the current user can edit this user 1014 if ( current_user_can( 'edit_user', $user->ID ) || bp_current_user_can( 'bp_moderate' ) ) { 1015 1016 // Add query args and setup the Extended link 1017 $edit_profile = add_query_arg( $args, $this->edit_profile_url ); 1018 $edit_profile_link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $edit_profile ), esc_html__( 'Extended', 'buddypress' ) ); 1019 1020 /** 1021 * Check the edit action is available 1022 * and preserve the order edit | profile | remove/delete 1023 */ 1024 if ( ! empty( $actions['edit'] ) ) { 1025 $edit_action = $actions['edit']; 1026 unset( $actions['edit'] ); 1027 1028 $new_edit_actions = array( 1029 'edit' => $edit_action, 1030 'edit-profile' => $edit_profile_link, 1031 ); 1032 1033 // If not available simply add the edit profile action 1034 } else { 1035 $new_edit_actions = array( 'edit-profile' => $edit_profile_link ); 1036 } 1037 1038 $actions = array_merge( $new_edit_actions, $actions ); 1039 } 1040 1041 return $actions; 1042 } 1043 1044 /** 1045 * Add a filter to edit profile url in WP Admin Bar 1046 * 1047 * @access public 1048 * @since BuddyPress (2.1.0) 1049 */ 1050 public function add_edit_profile_url_filter() { 1051 add_filter( 'bp_members_edit_profile_url', array( $this, 'filter_adminbar_profile_link' ), 10, 3 ); 1052 } 1053 1054 /** 1055 * Filter the profile url 1056 * 1057 * @access public 1058 * @since BuddyPress (2.1.0) 1059 * 1060 * @uses user_admin_url() 1061 */ 1062 public function filter_adminbar_profile_link( $profile_link = '', $url = '', $user_id = 0 ) { 1063 if ( ! is_super_admin( $user_id ) && is_admin() ) { 1064 $profile_link = user_admin_url( 'profile.php' ); 1065 } 1066 return $profile_link; 1067 } 1068 1069 /** 1070 * Remove the filter to edit profile url in WP Admin Bar 1071 * 1072 * @access public 1073 * @since BuddyPress (2.1.0) 1074 */ 1075 public function remove_edit_profile_url_filter() { 1076 remove_filter( 'bp_members_edit_profile_url', array( $this, 'filter_adminbar_profile_link' ), 10, 3 ); 1077 } 1078 1079 /** Signups Management ****************************************************/ 767 1080 768 1081 /** … … 837 1150 */ 838 1151 public function signup_filter_view( $views = array() ) { 839 $class = ''; 840 841 $signups = BP_Signup::count_signups(); 842 843 // Remove the 'current' class from All if we're on the signups 844 // view 1152 1153 // Remove the 'current' class from All if we're on the signups view 845 1154 if ( $this->signups_page == get_current_screen()->id ) { 846 1155 $views['all'] = str_replace( 'class="current"', '', $views['all'] ); 847 $class = ' class="current"'; 848 } 849 850 $views['registered'] = '<a href="' . add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) . '"' . $class . '>' . sprintf( _x( 'Pending <span class="count">(%s)</span>', 'signup users', 'buddypress' ), number_format_i18n( $signups ) ) . '</a>'; 1156 $class = 'current'; 1157 } else { 1158 $class = ''; 1159 } 1160 1161 $signups = BP_Signup::count_signups(); 1162 $url = add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ); 1163 $text = sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $signups ) . ')</span>' ); 1164 1165 $views['registered'] = sprintf( '<a href="%1$s" class="%2$s">%3$s</a>', $url, $class, $text ); 851 1166 852 1167 return $views; … … 891 1206 // Build redirection URL 892 1207 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] ); 893 $doaction = bp_admin_list_table_current_bulk_action();1208 $doaction = bp_admin_list_table_current_bulk_action(); 894 1209 895 1210 // Call an action for plugins to hook in early … … 900 1215 901 1216 // Prepare the display of the Community Profile screen 902 if ( ! in_array( $doaction, $allowed_actions ) || -1 == $doaction) {1217 if ( ! in_array( $doaction, $allowed_actions ) || ( -1 == $doaction ) ) { 903 1218 904 1219 if ( bp_core_do_network_admin() ) { … … 944 1259 // Handle resent activation links 945 1260 if ( 'do_resend' == $doaction ) { 1261 946 1262 // nonce check 947 1263 check_admin_referer( 'signups_resend' ); … … 970 1286 // Handle activated accounts 971 1287 } else if ( 'do_activate' == $doaction ) { 1288 972 1289 // nonce check 973 1290 check_admin_referer( 'signups_activate' ); … … 996 1313 // Handle sign-ups delete 997 1314 } else if ( 'do_delete' == $doaction ) { 1315 998 1316 // nonce check 999 1317 check_admin_referer( 'signups_delete' ); … … 1037 1355 */ 1038 1356 public function signups_display_errors() { 1357 1358 // Look for sign-up errors 1359 $errors = get_transient( '_bp_admin_signups_errors' ); 1360 1039 1361 // Bail if no activation errors 1040 if ( ! $errors = get_transient( '_bp_admin_signups_errors') ) {1362 if ( empty( $errors ) ) { 1041 1363 return; 1042 1364 } 1043 1365 1044 foreach ( $errors as $error ) { 1045 ?> 1366 // Loop through errors and display them 1367 foreach ( $errors as $error ) : ?> 1368 1046 1369 <li><?php echo esc_html( $error[0] );?>: <?php echo esc_html( $error[1] );?></li> 1047 <?php 1048 }1370 1371 <?php endforeach; 1049 1372 1050 1373 // Delete the redirect transient … … 1053 1376 1054 1377 /** 1055 * Signups admin page router. 1056 * 1057 * Depending on the context, display 1058 * - the list of signups 1059 * - or the delete confirmation screen 1060 * - or the activate confirmation screen 1061 * - or the "resend" email confirmation screen 1062 * 1063 * Also prepare the admin notices. 1064 * 1065 * @since BuddyPress (2.0.0) 1066 */ 1067 public function signups_admin() { 1068 $doaction = bp_admin_list_table_current_bulk_action(); 1069 1070 // Prepare notices for admin 1378 * Get admin notice when viewing the sign-up page 1379 * 1380 * @since BuddyPress (2.1.0) 1381 * 1382 * @return array 1383 */ 1384 private function get_signup_notice() { 1385 1386 // Setup empty notice for return value 1071 1387 $notice = array(); 1072 1388 1389 // Updated 1073 1390 if ( ! empty( $_REQUEST['updated'] ) ) { 1074 1391 switch ( $_REQUEST['updated'] ) { … … 1203 1520 } 1204 1521 1522 return $notice; 1523 } 1524 1525 /** 1526 * Signups admin page router. 1527 * 1528 * Depending on the context, display 1529 * - the list of signups 1530 * - or the delete confirmation screen 1531 * - or the activate confirmation screen 1532 * - or the "resend" email confirmation screen 1533 * 1534 * Also prepare the admin notices. 1535 * 1536 * @since BuddyPress (2.0.0) 1537 */ 1538 public function signups_admin() { 1539 $doaction = bp_admin_list_table_current_bulk_action(); 1540 1541 // Prepare notices for admin 1542 $notice = $this->get_signup_notice(); 1543 1205 1544 // Display notices 1206 1545 if ( ! empty( $notice ) ) : 1207 1546 if ( 'updated' === $notice['class'] ) : ?> 1547 1208 1548 <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>"> 1549 1209 1550 <?php else: ?> 1551 1210 1552 <div class="<?php echo esc_attr( $notice['class'] ); ?>"> 1553 1211 1554 <?php endif; ?> 1555 1212 1556 <p><?php echo $notice['message']; ?></p> 1557 1213 1558 <?php if ( ! empty( $_REQUEST['notactivated'] ) || ! empty( $_REQUEST['notdeleted'] ) || ! empty( $_REQUEST['notsent'] ) ) :?> 1559 1214 1560 <ul><?php $this->signups_display_errors();?></ul> 1561 1215 1562 <?php endif ;?> 1563 1216 1564 </div> 1565 1217 1566 <?php endif; 1218 1567 … … 1282 1631 <div class="wrap"> 1283 1632 <?php screen_icon( 'users' ); ?> 1284 <h2> 1285 <?php 1286 _e( 'Users', 'buddypress' );1287 if ( current_user_can( 'create_users' ) ) { ?> 1633 <h2><?php _e( 'Users', 'buddypress' ); ?> 1634 1635 <?php if ( current_user_can( 'create_users' ) ) : ?> 1636 1288 1637 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a> 1289 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 1638 1639 <?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?> 1640 1290 1641 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a> 1291 <?php } 1642 1643 <?php endif; 1292 1644 1293 1645 if ( $usersearch ) { … … 1303 1655 <form id="bp-signups-search-form" action="<?php echo esc_url( $search_form_url ) ;?>"> 1304 1656 <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" /> 1305 <?php $bp_members_signup_list_table->search_box( __( 'Search Pending Accounts', 'buddypress' ), 'bp-signups' ); ?>1657 <?php $bp_members_signup_list_table->search_box( __( 'Search Pending Users', 'buddypress' ), 'bp-signups' ); ?> 1306 1658 </form> 1307 1659 … … 1391 1743 <ol class="bp-signups-list"> 1392 1744 <?php foreach ( $signups as $signup ) : 1393 $last_notified = mysql2date( 'Y/m/d g:i:s a', $signup->date_sent ) 1394 ?>1745 1746 $last_notified = mysql2date( 'Y/m/d g:i:s a', $signup->date_sent ); ?> 1395 1747 1396 1748 <li> … … 1398 1750 1399 1751 <?php if ( 'resend' == $action ) : ?> 1752 1400 1753 <p class="description"> 1401 1754 <?php printf( esc_html__( 'Last notified: %s', 'buddypress'), $last_notified ) ;?> 1402 1755 1403 1756 <?php if ( ! empty( $signup->recently_sent ) ) : ?> 1757 1404 1758 <span class="attention wp-ui-text-notification"> <?php esc_html_e( '(less than 24 hours ago)', 'buddypress' ); ?></span> 1759 1405 1760 <?php endif; ?> 1406 1761 </p> 1407 1762 1408 1763 <?php endif; ?> 1764 1409 1765 </li> 1410 1766 … … 1412 1768 </ol> 1413 1769 1414 <?php if ( 'resend' != $action ) : ?> 1770 <?php if ( 'delete' === $action ) : ?> 1771 1415 1772 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p> 1773 1416 1774 <?php endif ; ?> 1417 1775
Note: See TracChangeset
for help on using the changeset viewer.