Skip to content

Instantly share code, notes, and snippets.

@frasten
Created May 5, 2010 00:00
Show Gist options
  • Save frasten/390208 to your computer and use it in GitHub Desktop.
Save frasten/390208 to your computer and use it in GitHub Desktop.
--- lib/core.php (revisione 12229)
+++ lib/core.php (copia locale)
@@ -128,7 +128,7 @@
// menu walker
class mystique_MenuWalker extends Walker {
var $tree_type = array('post_type', 'taxonomy', 'custom');
- var $db_fields = array('parent' => 'post_parent', 'id' => 'object_id');
+ var $db_fields = array('parent' => 'menu_item_parent', 'id' => 'db_id');
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
@@ -145,8 +145,16 @@
$indent = ($depth) ? str_repeat("\t", $depth) : '';
$classes = $value = '';
$classes = array('type-'. $item->type, $item->classes);
- if ('custom' != $item->object) $classes[] = 'object-'. $item->object;
- if ($item->object_id == $wp_query->get_queried_object_id()) $classes[] = 'active';
+ if ('custom' != $item->object) {
+ $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $item_url = strpos( $item->url, '#' ) ? substr( $item->url, 0, strpos( $item->url, '#' ) ) : $item->url;
+ if ( $item_url == $current_url )
+ $classes[] = 'active';
+ } else {
+ $classes[] = 'object-'. $item->object;
+ if ( $item->object_id == $wp_query->get_queried_object_id() )
+ $classes[] = 'active';
+ }
// @todo add classes for parent/child relationships
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment