Make WordPress Core

Changeset 44977


Ignore:
Timestamp:
03/21/2019 11:54:05 PM (5 years ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r44813 r44977  
    338338            }
    339339
    340             $path = ( $val->path === '/' ) ? '' : $val->path;
    341             echo '<span class="site-' . $val->site_id . '" >';
     340            $path         = ( $val->path === '/' ) ? '' : $val->path;
     341            $site_classes = array( 'site-' . $val->site_id );
     342            /**
     343             * Filters the span class for a site listing on the mulisite user list table.
     344             *
     345             * @since 5.2.0
     346             *
     347             * @param array  $site_classes Class used within the span tag. Default "site-#" with the site's network ID.
     348             * @param int    $site_id      Site ID.
     349             * @param int    $network_id   Network ID.
     350             * @param object $user         WP_User object.
     351             */
     352            $site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $val->userblog_id, $val->site_id, $user );
     353            if ( is_array( $site_classes ) && ! empty( $site_classes ) ) {
     354                $site_classes = array_map( 'sanitize_html_class', array_unique( $site_classes ) );
     355                echo '<span class="' . sanitize_html_class( implode( ' ', $site_classes ) ) . '">';
     356            } else {
     357                echo '<span>';
     358            }
    342359            echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
    343360            echo ' <small class="row-actions">';
Note: See TracChangeset for help on using the changeset viewer.