364 $blogs = get_blogs_of_user( $user->ID, true ); |
368 $blogs = get_blogs_of_user( $user->ID, true ); |
365 if ( ! is_array( $blogs ) ) { |
369 if ( ! is_array( $blogs ) ) { |
366 return; |
370 return; |
367 } |
371 } |
368 |
372 |
369 foreach ( $blogs as $val ) { |
373 foreach ( $blogs as $site ) { |
370 if ( ! can_edit_network( $val->site_id ) ) { |
374 if ( ! can_edit_network( $site->site_id ) ) { |
371 continue; |
375 continue; |
372 } |
376 } |
373 |
377 |
374 $path = ( '/' === $val->path ) ? '' : $val->path; |
378 $path = ( '/' === $site->path ) ? '' : $site->path; |
375 $site_classes = array( 'site-' . $val->site_id ); |
379 $site_classes = array( 'site-' . $site->site_id ); |
376 /** |
380 /** |
377 * Filters the span class for a site listing on the mulisite user list table. |
381 * Filters the span class for a site listing on the mulisite user list table. |
378 * |
382 * |
379 * @since 5.2.0 |
383 * @since 5.2.0 |
380 * |
384 * |
381 * @param string[] $site_classes Array of class names used within the span tag. Default "site-#" with the site's network ID. |
385 * @param string[] $site_classes Array of class names used within the span tag. Default "site-#" with the site's network ID. |
382 * @param int $site_id Site ID. |
386 * @param int $site_id Site ID. |
383 * @param int $network_id Network ID. |
387 * @param int $network_id Network ID. |
384 * @param WP_User $user WP_User object. |
388 * @param WP_User $user WP_User object. |
385 */ |
389 */ |
386 $site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $val->userblog_id, $val->site_id, $user ); |
390 $site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $site->userblog_id, $site->site_id, $user ); |
387 if ( is_array( $site_classes ) && ! empty( $site_classes ) ) { |
391 if ( is_array( $site_classes ) && ! empty( $site_classes ) ) { |
388 $site_classes = array_map( 'sanitize_html_class', array_unique( $site_classes ) ); |
392 $site_classes = array_map( 'sanitize_html_class', array_unique( $site_classes ) ); |
389 echo '<span class="' . esc_attr( implode( ' ', $site_classes ) ) . '">'; |
393 echo '<span class="' . esc_attr( implode( ' ', $site_classes ) ) . '">'; |
390 } else { |
394 } else { |
391 echo '<span>'; |
395 echo '<span>'; |
392 } |
396 } |
393 echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>'; |
397 echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $site->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $site->domain . $path ) . '</a>'; |
394 echo ' <small class="row-actions">'; |
398 echo ' <small class="row-actions">'; |
395 $actions = array(); |
399 $actions = array(); |
396 $actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>'; |
400 $actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $site->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>'; |
397 |
401 |
398 $class = ''; |
402 $class = ''; |
399 if ( 1 == $val->spam ) { |
403 if ( 1 === (int) $site->spam ) { |
400 $class .= 'site-spammed '; |
404 $class .= 'site-spammed '; |
401 } |
405 } |
402 if ( 1 == $val->mature ) { |
406 if ( 1 === (int) $site->mature ) { |
403 $class .= 'site-mature '; |
407 $class .= 'site-mature '; |
404 } |
408 } |
405 if ( 1 == $val->deleted ) { |
409 if ( 1 === (int) $site->deleted ) { |
406 $class .= 'site-deleted '; |
410 $class .= 'site-deleted '; |
407 } |
411 } |
408 if ( 1 == $val->archived ) { |
412 if ( 1 === (int) $site->archived ) { |
409 $class .= 'site-archived '; |
413 $class .= 'site-archived '; |
410 } |
414 } |
411 |
415 |
412 $actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>'; |
416 $actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $site->userblog_id ) ) . '">' . __( 'View' ) . '</a>'; |
413 |
417 |
414 /** |
418 /** |
415 * Filters the action links displayed next the sites a user belongs to |
419 * Filters the action links displayed next the sites a user belongs to |
416 * in the Network Admin Users list table. |
420 * in the Network Admin Users list table. |
417 * |
421 * |
418 * @since 3.1.0 |
422 * @since 3.1.0 |
419 * |
423 * |
420 * @param string[] $actions An array of action links to be displayed. Default 'Edit', 'View'. |
424 * @param string[] $actions An array of action links to be displayed. Default 'Edit', 'View'. |
421 * @param int $userblog_id The site ID. |
425 * @param int $userblog_id The site ID. |
422 */ |
426 */ |
423 $actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id ); |
427 $actions = apply_filters( 'ms_user_list_site_actions', $actions, $site->userblog_id ); |
424 |
428 |
425 $action_count = count( $actions ); |
429 $action_count = count( $actions ); |
426 |
430 |
427 $i = 0; |
431 $i = 0; |
428 |
432 |
440 |
444 |
441 /** |
445 /** |
442 * Handles the default column output. |
446 * Handles the default column output. |
443 * |
447 * |
444 * @since 4.3.0 |
448 * @since 4.3.0 |
445 * |
449 * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support. |
446 * @param WP_User $user The current WP_User object. |
450 * |
|
451 * @param WP_User $item The current WP_User object. |
447 * @param string $column_name The current column name. |
452 * @param string $column_name The current column name. |
448 */ |
453 */ |
449 public function column_default( $user, $column_name ) { |
454 public function column_default( $item, $column_name ) { |
450 /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ |
455 /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ |
451 echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); |
456 echo apply_filters( |
|
457 'manage_users_custom_column', |
|
458 '', // Custom column output. Default empty. |
|
459 $column_name, |
|
460 $item->ID // User ID. |
|
461 ); |
452 } |
462 } |
453 |
463 |
454 public function display_rows() { |
464 public function display_rows() { |
455 foreach ( $this->items as $user ) { |
465 foreach ( $this->items as $user ) { |
456 $class = ''; |
466 $class = ''; |
487 |
497 |
488 /** |
498 /** |
489 * Generates and displays row action links. |
499 * Generates and displays row action links. |
490 * |
500 * |
491 * @since 4.3.0 |
501 * @since 4.3.0 |
492 * |
502 * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support. |
493 * @param WP_User $user User being acted upon. |
503 * |
|
504 * @param WP_User $item User being acted upon. |
494 * @param string $column_name Current column name. |
505 * @param string $column_name Current column name. |
495 * @param string $primary Primary column name. |
506 * @param string $primary Primary column name. |
496 * @return string Row actions output for users in Multisite, or an empty string |
507 * @return string Row actions output for users in Multisite, or an empty string |
497 * if the current column is not the primary column. |
508 * if the current column is not the primary column. |
498 */ |
509 */ |
499 protected function handle_row_actions( $user, $column_name, $primary ) { |
510 protected function handle_row_actions( $item, $column_name, $primary ) { |
500 if ( $primary !== $column_name ) { |
511 if ( $primary !== $column_name ) { |
501 return ''; |
512 return ''; |
502 } |
513 } |
503 |
514 |
|
515 // Restores the more descriptive, specific name for use within this method. |
|
516 $user = $item; |
504 $super_admins = get_super_admins(); |
517 $super_admins = get_super_admins(); |
505 |
518 |
506 $actions = array(); |
519 $actions = array(); |
507 |
520 |
508 if ( current_user_can( 'edit_user', $user->ID ) ) { |
521 if ( current_user_can( 'edit_user', $user->ID ) ) { |