network_edit_site_nav( $args = array() )
Outputs the HTML for a network’s “Edit Site” tabular interface.
Parameters
- $args
-
(Optional) Array or string of Query parameters.
- 'blog_id'
(int) The site ID. Default is the current site. - 'links'
(array) The tabs to include with (label|url|cap) keys. - 'selected'
(string) The ID of the selected link.
Default value: array()
- 'blog_id'
Source
File: wp-admin/includes/ms.php
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 WP-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
$r = 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 ( $r['links'] as $link_id => $link ) {
// Skip link if user can't access
if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) {
continue;
}
// Link classes
$classes = array( 'nav-tab' );
// Selected is set by the parent OR assumed by the $pagenow global
if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
$classes[] = 'nav-tab-active';
}
// Escape each class
$esc_classes = implode( ' ', $classes );
// Get the URL for this link
$url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
// Add link to nav links
$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '">' . esc_html( $link['label'] ) . '</a>';
}
// All done!
echo '<h2 class="nav-tab-wrapper wp-clearfix">';
echo implode( '', $screen_links );
echo '</h2>';
}
Changelog
Version | Description |
---|---|
WP-4.6.0 | Introduced. |