network_edit_site_nav( array $args = array() )
- Since
- 4.6.0
- Source
wp-admin/includes/ms.php:1043
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 siteThe site ID.$linksarrayThe tabs to include with (label|url|cap) keys.$selectedstringThe 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
- Scaling
- Scales with input
- Instructions
- 60–64
- Plugin surface
- 1 hook
- Called by
- 0
Touches nothing outside its own arguments.
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 124.
Third-party callbacks on 'network_edit_site_nav_links' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 60–64 | __(), __(), __(), __(), label(), blog_id(), esc_attr__() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 124 | 60–64 | 6 | |
| 8.5 | 124 | 60–64 | 6 | |
| 8.4 | 124 | 60–64 | 6 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 130 | 63–67 | 6 | |
| 8.2 | 130 | 63–67 | 6 | |
| 8.1 | 130 | 63–67 | 6 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 132 | 63–68 | 6 |
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:
- 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
- apply_filters()Calls the callback functions that have been added to a filter hook.
- __()Retrieves the translation of $text.
- wp_parse_args()Merges user defined arguments into defaults array.
- current_user_can()Returns whether the current user has the specified capability.
- add_query_arg()Retrieves a modified URL query string.
- network_admin_url()Retrieves the URL to the admin area for the network.
- esc_url()Checks and cleans a URL.
- esc_attr()Escaping for HTML attributes.
- esc_html()Escaping for HTML blocks.
- esc_attr__()Retrieves the translation of $text and escapes it for safe use in an attribute.
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.
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.