wppaste
WordPress

network_edit_site_nav( array $args = array() )

Since
4.6.0
Source
wp-admin/includes/ms.php:1043
Outputs the HTML for a network's "Edit Site" tabular interface.

Compatibility

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

$argsarrayoptional
Array or string of Query parameters. Default empty array.Default: array()
  • $blog_idintdefault: is the current site

    The site ID.
  • $linksarray

    The tabs to include with (label|url|cap) keys.
  • $selectedstring

    The ID of the selected link.

Performance profile

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

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
60–64

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

Plugin surface
1 hook

Third-party callbacks on 'network_edit_site_nav_links' 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 callbacksapply_filters()called directly

Further down the call graph this can also reach option, query, cache, serialize 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 network_edit_site_nav() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always60–64__(), __(), __(), __(), label(), blog_id(), esc_attr__()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev12460–646
8.512460–646
8.412460–6466 fewer instructions than PHP 8.3
8.313063–676
8.213063–676
8.113063–6762 fewer instructions than PHP 7.4
7.413263–686

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

One hook fires while network_edit_site_nav() runs, in this order:

  1. apply_filters( network_edit_site_nav_links )filterline 1064 (+21 into the body)

    Filters the links that appear on site-editing network pages.

Uses · 10

Source code

function network_edit_site_nav( $args = array() ) { 	/**	 * Filters the links that appear on site-editing network pages.	 *	 * Default links: 'site-info', 'site-users', 'site-themes', and 'site-settings'.	 *	 * @since 4.6.0	 *	 * @param array $links {	 *     An array of link data representing individual network admin pages.	 *	 *     @type array $link_slug {	 *         An array of information about the individual link to a page.	 *	 *         $type string $label Label to use for the link.	 *         $type string $url   URL, relative to `network_admin_url()` to use for the link.	 *         $type string $cap   Capability required to see the link.	 *     }	 * }	 */	$links = apply_filters(		'network_edit_site_nav_links',		array(			'site-info'     => array(				'label' => __( 'Info' ),				'url'   => 'site-info.php',				'cap'   => 'manage_sites',			),			'site-users'    => array(				'label' => __( 'Users' ),				'url'   => 'site-users.php',				'cap'   => 'manage_sites',			),			'site-themes'   => array(				'label' => __( 'Themes' ),				'url'   => 'site-themes.php',				'cap'   => 'manage_sites',			),			'site-settings' => array(				'label' => __( 'Settings' ),				'url'   => 'site-settings.php',				'cap'   => 'manage_sites',			),		)	); 	// Parse arguments.	$parsed_args = wp_parse_args(		$args,		array(			'blog_id'  => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,			'links'    => $links,			'selected' => 'site-info',		)	); 	// Setup the links array.	$screen_links = array(); 	// Loop through tabs.	foreach ( $parsed_args['links'] as $link_id => $link ) { 		// Skip link if user can't access.		if ( ! current_user_can( $link['cap'], $parsed_args['blog_id'] ) ) {			continue;		} 		// Link classes.		$classes = array( 'nav-tab' ); 		// Aria-current attribute.		$aria_current = ''; 		// Selected is set by the parent OR assumed by the $pagenow global.		if ( $parsed_args['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {			$classes[]    = 'nav-tab-active';			$aria_current = ' aria-current="page"';		}

Changelog

Introduced in 4.6.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.8.8 tag, from src/wp-admin/includes/ms.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.