返回介绍

network_edit_site_nav()

发布于 2017-09-11 02:00:40 字数 4201 浏览 1110 评论 0 收藏 0

network_edit_site_nav( $args = array() )

Outputs the HTML for a network’s “Edit Site” tabular interface.


description


参数

$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()


源代码

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 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>';
}

更新日志

Versiondescription
4.6.0Introduced.

相关函数

Uses

  • wp-admin/includes/ms.php: network_edit_site_nav_links
  • wp-includes/capabilities.php: current_user_can()
  • wp-includes/l10n.php: __()
  • wp-includes/formatting.php: esc_url()
  • wp-includes/formatting.php: esc_attr()
  • wp-includes/formatting.php: esc_html()
  • wp-includes/functions.php: wp_parse_args()
  • wp-includes/functions.php: add_query_arg()
  • wp-includes/link-template.php: network_admin_url()
  • wp-includes/plugin.php: apply_filters()
  • Show 5 more uses Hide more uses

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文