Advertisements

add_menu_classes

Definition:
function add_menu_classes($menu) {}

Parameters

  • $menu

Defined filters

  • add_menu_classes
    apply_filters( 'add_menu_classes', $menu )

Source code

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') ) { // 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;

	}



	return apply_filters( 'add_menu_classes', $menu );

}

8947

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: