wppaste
WordPress

wp_network_dashboard_right_now()

Since
3.1.0
Source
wp-admin/includes/dashboard.php:447

Compatibility

WordPress
since 3.1.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.

Performance profile

How much work a call to wp_network_dashboard_right_now() 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

Reads stored settings via get_network_option(), cached per request but not free on a cold cache.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
111–143

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 151.

Plugin surface
3 hooks

Third-party callbacks on 'wpmuadminresult', 'mu_rightnow_end', 'mu_activity_box_end' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksdo_action()called directly
  • optionnetwork optionget_network_option()one call below wp_network_dashboard_right_now()

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 · 4 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_network_dashboard_right_now() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!current_user_can()111–119current_user_can(), current_user_can(), get_user_count(), get_blog_count(), _n(), number_format_i18n(), sprintf(), _n(), number_format_i18n(), sprintf(), __(), sprintf(), do_action(), network_admin_url(), esc_url(), _e(), __(), submit_button(), network_admin_url(), esc_url(), _e(), __(), submit_button(), do_action(), do_action()
always123–131current_user_can(), current_user_can(), network_admin_url(), __(), get_user_count(), get_blog_count(), _n(), number_format_i18n(), sprintf(), _n(), number_format_i18n(), sprintf(), __(), sprintf(), do_action(), network_admin_url(), esc_url(), _e(), __(), submit_button(), network_admin_url(), esc_url(), _e(), __(), submit_button(), do_action(), do_action()
always123–131current_user_can(), network_admin_url(), __(), current_user_can(), get_user_count(), get_blog_count(), _n(), number_format_i18n(), sprintf(), _n(), number_format_i18n(), sprintf(), __(), sprintf(), do_action(), network_admin_url(), esc_url(), _e(), __(), submit_button(), network_admin_url(), esc_url(), _e(), __(), submit_button(), do_action(), do_action()
current_user_can()135–143current_user_can(), network_admin_url(), __(), current_user_can(), network_admin_url(), __(), get_user_count(), get_blog_count(), _n(), number_format_i18n(), sprintf(), _n(), number_format_i18n(), sprintf(), __(), sprintf(), do_action(), network_admin_url(), esc_url(), _e(), __(), submit_button(), network_admin_url(), esc_url(), _e(), __(), submit_button(), do_action(), do_action()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev151111–1435
8.5151111–1435
8.4151111–14353 fewer instructions than PHP 8.3
8.3154111–1465
8.2154111–1465
8.1154111–1465
7.4154111–1465

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 · 3

3 hooks fire while wp_network_dashboard_right_now() runs, in this order:

  1. do_action( wpmuadminresult )actionline 489 (+42 into the body)

    Fires in the Network Admin 'Right Now' dashboard widget just before the user and site search form fields.

  2. do_action( mu_rightnow_end )actionline 523 (+76 into the body)

    Fires at the end of the 'Right Now' widget in the Network Admin dashboard.

  3. do_action( mu_activity_box_end )actionline 530 (+83 into the body)

    Fires at the end of the 'Right Now' widget in the Network Admin dashboard.

Uses · 11

  • current_user_can()Returns whether the current user has the specified capability.
  • network_admin_url()Retrieves the URL to the admin area for the network.
  • __()Retrieves the translation of $text.
  • get_user_count()Returns the number of active users in your installation.
  • get_blog_count()Gets the number of active sites on the installation.
  • _n()Translates and retrieves the singular or plural form based on the supplied number.
  • number_format_i18n()Converts float number to format based on the locale.
  • do_action()Calls the callback functions that have been added to an action hook.
  • esc_url()Checks and cleans a URL.
  • _e()Displays translated text.
  • submit_button()Echoes a submit button, with provided text and appropriate class(es).

Source code

function wp_network_dashboard_right_now() {	$actions = array(); 	if ( current_user_can( 'create_sites' ) ) {		$actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>';	}	if ( current_user_can( 'create_users' ) ) {		$actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>';	} 	$c_users = get_user_count();	$c_blogs = get_blog_count(); 	/* translators: %s: Number of users on the network. */	$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );	/* translators: %s: Number of sites on the network. */	$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); 	/* translators: 1: Text indicating the number of sites on the network, 2: Text indicating the number of users on the network. */	$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); 	if ( $actions ) {		echo '<ul class="subsubsub">';		foreach ( $actions as $class => $action ) {			$actions[ $class ] = "\t<li class='$class'>$action";		}		echo implode( " |</li>\n", $actions ) . "</li>\n";		echo '</ul>';	}	?>	<br class="clear" /> 	<p class="youhave"><?php echo $sentence; ?></p>  	<?php		/**		 * Fires in the Network Admin 'Right Now' dashboard widget		 * just before the user and site search form fields.		 *		 * @since MU (3.0.0)		 */		do_action( 'wpmuadminresult' );	?> 	<form action="<?php echo esc_url( network_admin_url( 'users.php' ) ); ?>" method="get">		<p>			<label class="screen-reader-text" for="search-users">				<?php				/* translators: Hidden accessibility text. */				_e( 'Search Users' );				?>			</label>			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users" />			<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>		</p>	</form> 	<form action="<?php echo esc_url( network_admin_url( 'sites.php' ) ); ?>" method="get">		<p>			<label class="screen-reader-text" for="search-sites">				<?php				/* translators: Hidden accessibility text. */				_e( 'Search Sites' );				?>			</label>			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites" />			<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>		</p>	</form>	<?php	/**	 * Fires at the end of the 'Right Now' widget in the Network Admin dashboard.	 *	 * @since MU (3.0.0)	 */	do_action( 'mu_rightnow_end' ); 	/**	 * Fires at the end of the 'Right Now' widget in the Network Admin dashboard.

Changelog

Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-admin/includes/dashboard.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.