add_menu_classes() - WordPress 函数参考中文文档

返回介绍

add_menu_classes()

发布于 2017-07-28 字数1602 浏览 1118 评论 0

add_menu_classes( array $menu )

参数

$menu
(array)
(Required)

返回值

(array)


源代码

File: wp-admin/includes/menu.php

function add_menu_classes($menu) {
	$first = $lastorder = false;
	$i = 0;
	$mc = count($menu);
	foreach ( $menu as $order => $top ) {
		$i++;

		if ( 0 == $order ) { // dashboard is always shown/single
			$menu[0][4] = add_cssclass('menu-top-first', $top[4]);
			$lastorder = 0;
			continue;
		}

		if ( 0 === strpos($top[2], 'separator') && false !== $lastorder ) { // if separator
			$first = true;
			$c = $menu[$lastorder][4];
			$menu[$lastorder][4] = add_cssclass('menu-top-last', $c);
			continue;
		}

		if ( $first ) {
			$c = $menu[$order][4];
			$menu[$order][4] = add_cssclass('menu-top-first', $c);
			$first = false;
		}

		if ( $mc == $i ) { // last item
			$c = $menu[$order][4];
			$menu[$order][4] = add_cssclass('menu-top-last', $c);
		}

		$lastorder = $order;
	}

	/**
	 * Filters administration menus array with classes added for top-level items.
	 *
	 * @since 2.7.0
	 *
	 * @param array $menu Associative array of administration menu items.
	 */
	return apply_filters( 'add_menu_classes', $menu );
}

相关函数

Uses

  • wp-admin/includes/menu.php:add_cssclass()
  • wp-admin/includes/menu.php:add_menu_classes
  • wp-includes/plugin.php:apply_filters()

上一篇:add_media_page()

下一篇:add_menu_page()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!