WP_MS_Users_List_Table::column_blogs( WP_User $user )

Handles the sites column output.


Description Description


Parameters Parameters

$user

(WP_User) (Required) The current WP_User object.


Top ↑

Source Source

File: wp-admin/includes/class-wp-ms-users-list-table.php

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

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

			$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="' . esc_attr( 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();
			$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>';

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

			$actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->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, $val->userblog_id );

			$i            = 0;
			$action_count = count( $actions );
			foreach ( $actions as $action => $link ) {
				++$i;
				$sep = ( $i == $action_count ) ? '' : ' | ';
				echo "<span class='$action'>$link$sep</span>";
			}
			echo '</small></span><br/>';
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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