Networks and Sites: Introduce the `ms_user_list_site_class` filter.

In the network admin user table on multisite installs (`WP_MS_Users_List_Table`), this filter allows the classes for the `<span>` tag surrounding each site link to be modified.

Props kraftbj, flixos90, johnjamesjacoby.
Fixes #41146.

git-svn-id: https://develop.svn.wordpress.org/trunk@44977 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2019-03-21 23:54:05 +00:00
parent 531d83a2f0
commit f170c1dd31
1 changed files with 19 additions and 2 deletions

View File

@ -337,8 +337,25 @@ class WP_MS_Users_List_Table extends WP_List_Table {
continue;
}
$path = ( $val->path === '/' ) ? '' : $val->path;
echo '<span class="site-' . $val->site_id . '" >';
$path = ( $val->path === '/' ) ? '' : $val->path;
$site_classes = array( 'site-' . $val->site_id );
/**
* Filters the span class for a site listing on the mulisite user list table.
*
* @since 5.2.0
*
* @param array $site_classes Class used within the span tag. Default "site-#" with the site's network ID.
* @param int $site_id Site ID.
* @param int $network_id Network ID.
* @param object $user WP_User object.
*/
$site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $val->userblog_id, $val->site_id, $user );
if ( is_array( $site_classes ) && ! empty( $site_classes ) ) {
$site_classes = array_map( 'sanitize_html_class', array_unique( $site_classes ) );
echo '<span class="' . sanitize_html_class( implode( ' ', $site_classes ) ) . '">';
} else {
echo '<span>';
}
echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
echo ' <small class="row-actions">';
$actions = array();