WordPress开发函数add_menu_classes()

WordPress开发函数add_menu_classes()用法: add_menu_classes( ar…

WordPress开发函数add_menu_classes()用法:

add_menu_classes( array $menu )

参数:

$menu

(array) (必需)

返回

(array)

来源:

文件: wp-admin/includes/menu.php

function add_menu_classes( $menu ) {

$first = false;

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

}

类别:WordPress入门

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT

登录 账号发表你的看法,还没有账号?立即免费 注册