Fixed the top navigation mainlevel counter.
authorLaury GvR <laury@gaslightmedia.com>
Mon, 30 Apr 2018 20:57:16 +0000 (16:57 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Mon, 30 Apr 2018 20:57:16 +0000 (16:57 -0400)
commitc30fdc5ad22f355fcc6445b0dfe4c8e3f77131a7
tree093c9c73f63db096a6652c2bec23bd9c878068d3
parent06ec1085cc53ac37fb0b0c8b6ac6c3c4a1c86d9c
Fixed the top navigation mainlevel counter.

It was not resetting when a new menu was called due to the nature
of the static variable being used to keep track of how many main
level items have been iterated ($mainLevelCounter)

The solution was another static var ($topbar_id_old) comparing the
old topbar id to the current topbar id (derived from $args), and if
they differ reset the mainlevel counter.

This avoids the problem where the mainlevelcounter starts counting
up in the Top Links, causing the Drop-left class to be improperly
applied (since that looks at $mainLevelCounter < 3 but by the time
it gets there, if a Top Links menu exists, it's already at 2 or 3)
lib/menu-walker.php