network_edit_site_nav

Outputs the HTML for a network's "Edit Site" tabular interface.

Description

network_edit_site_nav( (array) $args = array() ); 

Parameters (1)

0. $args — Optional. (array) => array()
Array or string of Query parameters. Default empty array.

Options

  • blog_id (int) => is the current site

    The site ID.

  • links (array) => null

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

array(

    /**
     * The site ID.
     *
     * @type int
     * @default is the current site
     */
    'blog_id' => is the current site,

    /**
     * The tabs to include with (label|url|cap) keys.
     *
     * @type array
     * @default null
     */
    'links' => null
);        


Usage

  1. if ( !function_exists( 'network_edit_site_nav' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ms.php'; 
  3.  
  4. // Optional. Array or string of Query parameters. Default empty array. 
  5. $args = array( 
  6. 'blog_id' => is the current site, 
  7. 'links' => null 
  8. ); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = network_edit_site_nav($args); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ms.php  
  1. function network_edit_site_nav( $args = array() ) { 
  2.  
  3. /** 
  4. * Filters the links that appear on site-editing network pages. 
  5. * Default links: 'site-info', 'site-users', 'site-themes', and 'site-settings'. 
  6. * @since 4.6.0 
  7. * @param array $links { 
  8. * An array of link data representing individual network admin pages. 
  9. * @type array $link_slug { 
  10. * An array of information about the individual link to a page. 
  11. * $type string $label Label to use for the link. 
  12. * $type string $url URL, relative to `network_admin_url()` to use for the link. 
  13. * $type string $cap Capability required to see the link. 
  14. * } 
  15. * } 
  16. */ 
  17. 'site-info' => array( 'label' => __( 'Info' ), 'url' => 'site-info.php', 'cap' => 'manage_sites' ),  
  18. 'site-users' => array( 'label' => __( 'Users' ), 'url' => 'site-users.php', 'cap' => 'manage_sites' ),  
  19. 'site-themes' => array( 'label' => __( 'Themes' ), 'url' => 'site-themes.php', 'cap' => 'manage_sites' ),  
  20. 'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' ) 
  21. ) ); 
  22.  
  23. // Parse arguments 
  24. $r = wp_parse_args( $args, array( 
  25. 'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,  
  26. 'links' => $links,  
  27. 'selected' => 'site-info',  
  28. ) ); 
  29.  
  30. // Setup the links array 
  31. $screen_links = array(); 
  32.  
  33. // Loop through tabs 
  34. foreach ( $r['links'] as $link_id => $link ) { 
  35.  
  36. // Skip link if user can't access 
  37. if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) { 
  38. continue; 
  39.  
  40. // Link classes 
  41. $classes = array( 'nav-tab' ); 
  42.  
  43. // Selected is set by the parent OR assumed by the $pagenow global 
  44. if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) { 
  45. $classes[] = 'nav-tab-active'; 
  46.  
  47. // Escape each class 
  48. $esc_classes = implode( ' ', $classes ); 
  49.  
  50. // Get the URL for this link 
  51. $url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) ); 
  52.  
  53. // Add link to nav links 
  54. $screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '">' . esc_html( $link['label'] ) . '</a>'; 
  55.  
  56. // All done! 
  57. echo '<h2 class="nav-tab-wrapper wp-clearfix">'; 
  58. echo implode( '', $screen_links ); 
  59. echo '</h2>';