WP_MS_Users_List_Table::column_blogs( WP_User $user )

In this article

Handles the sites column output.

Parameters

$userWP_Userrequired
The current WP_User object.

Source

public function column_blogs( $user ) {
	$blogs = get_blogs_of_user( $user->ID, true );
	if ( ! is_array( $blogs ) ) {
		return;
	}

	foreach ( $blogs as $site ) {
		if ( ! can_edit_network( $site->site_id ) ) {
			continue;
		}

		$path         = ( '/' === $site->path ) ? '' : $site->path;
		$site_classes = array( 'site-' . $site->site_id );
		/**
		 * Filters the span class for a site listing on the mulisite user list table.
		 *
		 * @since 5.2.0
		 *
		 * @param string[] $site_classes Array of class names 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 WP_User  $user         WP_User object.
		 */
		$site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $site->userblog_id, $site->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="' . esc_attr( implode( ' ', $site_classes ) ) . '">';
		} else {
			echo '<span>';
		}
		echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $site->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $site->domain . $path ) . '</a>';
		echo ' <small class="row-actions">';
		$actions         = array();
		$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $site->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>';

		$class = '';
		if ( 1 === (int) $site->spam ) {
			$class .= 'site-spammed ';
		}
		if ( 1 === (int) $site->mature ) {
			$class .= 'site-mature ';
		}
		if ( 1 === (int) $site->deleted ) {
			$class .= 'site-deleted ';
		}
		if ( 1 === (int) $site->archived ) {
			$class .= 'site-archived ';
		}

		$actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $site->userblog_id ) ) . '">' . __( 'View' ) . '</a>';

		/**
		 * Filters the action links displayed next the sites a user belongs to
		 * in the Network Admin Users list table.
		 *
		 * @since 3.1.0
		 *
		 * @param string[] $actions     An array of action links to be displayed. Default 'Edit', 'View'.
		 * @param int      $userblog_id The site ID.
		 */
		$actions = apply_filters( 'ms_user_list_site_actions', $actions, $site->userblog_id );

		$action_count = count( $actions );

		$i = 0;

		foreach ( $actions as $action => $link ) {
			++$i;

			$separator = ( $i < $action_count ) ? ' | ' : '';

			echo "<span class='$action'>{$link}{$separator}</span>";
		}

		echo '</small></span><br />';
	}
}

Hooks

apply_filters( ‘ms_user_list_site_actions’, string[] $actions, int $userblog_id )

Filters the action links displayed next the sites a user belongs to in the Network Admin Users list table.

apply_filters( ‘ms_user_list_site_class’, string[] $site_classes, int $site_id, int $network_id, WP_User $user )

Filters the span class for a site listing on the mulisite user list table.

Changelog

VersionDescription
4.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.