WP_MS_Users_List_Table::column_blogs( WP_User $user )
- Since
- 4.3.0
- Source
wp-admin/includes/class-wp-ms-users-list-table.php:373
Compatibility
- WordPress
- since 4.3.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$userWP_User- The current WP_User object.
Performance profile
How much work a call to WP_MS_Users_List_Table::column_blogs() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 11–14
- Plugin surface
- 2 hooks
- Called by
- 1
Reads stored settings via get_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 176.
Third-party callbacks on 'ms_user_list_site_class', 'ms_user_list_site_actions' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()one call below WP_MS_Users_List_Table::column_blogs()
Further down the call graph this can also reach cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_MS_Users_List_Table::column_blogs() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 11–14 | get_blogs_of_user() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 176 | 11–14 | 14 | |
| 8.5 | 176 | 11–14 | 14 | |
| 8.4 | 176 | 11–14 | 14 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 182 | 11–14 | 14 | |
| 8.2 | 182 | 11–14 | 14 | |
| 8.1 | 182 | 11–14 | 14 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 183 | 11–14 | 14 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 2
2 hooks fire while WP_MS_Users_List_Table::column_blogs() runs, in this order:
- apply_filters( ms_user_list_site_class )filterline 398 (+25 into the body)
Filters the span class for a site listing on the multisite user list table.
- apply_filters( ms_user_list_site_actions )filterline 438 (+65 into the body)
Filters the action links displayed next the sites a user belongs to in the Network Admin Users list table.
Uses · 9
- get_blogs_of_user()Gets the sites a user belongs to.
- can_edit_network()Determines whether or not this network from this page can be edited.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- esc_attr()Escaping for HTML attributes.
- esc_url()Checks and cleans a URL.
- network_admin_url()Retrieves the URL to the admin area for the network.
- get_network()Retrieves network data given a network ID or network object.
- __()Retrieves the translation of $text.
- get_home_url()Retrieves the URL for a given site where the front end is accessible.
Used by · 1
Source code
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 multisite 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 />';Changelog
Introduced in 4.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/class-wp-ms-users-list-table.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.