Plugin Directory

Changeset 1267318


Ignore:
Timestamp:
10/16/2015 11:31:24 AM (10 years ago)
Author:
Studiofreya
Message:

version 2.0 with vertical and horizontal layouts

Location:
sf-bootstrap-menu
Files:
25 added
5 edited

Legend:

Unmodified
Added
Removed
  • sf-bootstrap-menu/trunk/css/style.css

    r1259663 r1267318  
    1 .nav-side-menu .toggle-btn {
    2   display: none;
    3 }
    4 .nav-side-menu ul,
    5 .nav-side-menu li {
    6   list-style: none;
    7   line-height: 35px !important;
    8   cursor: pointer;
    9 }
    10 
    11 .nav-side-menu ul :not(collapsed) .arrow:before,
    12 .nav-side-menu li :not(collapsed) .arrow:before {
    13   display: inline-block;
    14   padding-left: 10px;
    15   padding-right: 10px;
    16   vertical-align: middle;
    17   float: right;
    18 }
    19 .nav-side-menu ul .active,
    20 .nav-side-menu li .active {
    21   border-left: 3px solid #d19b3d;
    22   background-color: #505050;
    23 }
    24 
    25 .nav-side-menu li.active a {
    26   color: #fff;
    27 }
    28 
    29 .nav-side-menu ul .in{
    30   background-color:#f6f6f6;
    31 }
    32 .nav-side-menu ul .sub-menu li.active,
    33 .nav-side-menu li .sub-menu li.active {
    34   color: #d19b3d;
    35 }
    36 
    37 .nav-side-menu li .sub-menu li a {
    38   color: #505050;
    39 }
    40 
    41 .nav-side-menu ul .sub-menu li.active a,
    42 .nav-side-menu li .sub-menu li.active a {
    43   color: #d19b3d;
    44 }
    45 .nav-side-menu ul .sub-menu li,
    46 .nav-side-menu li .sub-menu li {
    47   background-color: #f6f6f6;
    48   line-height: 28px;
    49   border-bottom: 1px solid #e7e7e7;
    50   margin-left: 0px;
    51 }
    52 .nav-side-menu ul .sub-menu li:hover,
    53 .nav-side-menu li .sub-menu li:hover {
    54   background-color: #505050;
    55   color: #fff;
    56 }
    57 
    58 .nav-side-menu ul .sub-menu li a:hover,
    59 .nav-side-menu li .sub-menu li a:hover{
    60   color: #fff;
    61 }
    62 
    63 .nav-side-menu ul .sub-menu li:before,
    64 .nav-side-menu li .sub-menu li:before {
    65   display: inline-block;
    66   padding-left: 10px;
    67   padding-right: 10px;
    68   vertical-align: middle;
    69 }
    70 .nav-side-menu li {
    71   border-bottom: 1px solid #e7e7e7;
    72 }
    73 .nav-side-menu li a {
    74   padding-left: 10px;
    75   text-decoration: none;
    76   color: #454545;
    77   display: inline-block; width: 100%;
    78   line-height: 35px;
    79 }
    80 .nav-side-menu li:hover {
    81   color: #fff;
    82   border-left: 3px solid #505050;
    83   background-color: #505050;
    84   -webkit-transition: all 1s ease;
    85   -moz-transition: all 1s ease;
    86   -o-transition: all 1s ease;
    87   -ms-transition: all 1s ease;
    88   transition: all 1s ease;
    89 }
    90 .nav-side-menu li a:hover {
    91   color: #fff;
    92 }
    93 
    94 @media (max-width: 767px) {
    95   .nav-side-menu {
    96     position: relative;
    97     width: 100%;
    98     margin-bottom: 10px;
    99   }
    100   .nav-side-menu .toggle-btn {
    101     display: block;
    102     cursor: pointer;
    103     position: absolute;
    104     right: 10px;
    105     top: 10px;
    106     z-index: 10 !important;
    107     padding: 3px;
    108     background-color: #ffffff;
    109     color: #000;
    110     width: 40px;
    111     text-align: center;
    112   }
    113   .brand {
    114     text-align: left !important;
    115     font-size: 22px;
    116     padding-left: 20px;
    117     line-height: 50px !important;
    118   }
    119 }
    120 @media (min-width: 767px) {
    121   .nav-side-menu .menu-list .menu-content {
    122     display: block;
    123   }
    124 }
    125 
    126 .sf-menu-caret {
    127   float: right;
    128   margin-right:10px;
    129   margin-top: 12px;
    130 }
     1.nav-side-menu ol ol,.nav-side-menu ul ul{padding:0!important}#dynamic_menu_row .toggle-btn,.nav-side-menu .toggle-btn{display:none}.nav-side-menu li,.nav-side-menu ul{list-style:none;line-height:35px;cursor:pointer}.nav-side-menu li :not(collapsed) .arrow:before,.nav-side-menu ul :not(collapsed) .arrow:before{display:inline-block;padding-left:10px;padding-right:10px;vertical-align:middle;float:right}.nav-side-menu li .active,.nav-side-menu ul .active{border-left:3px solid #d19b3d;background-color:#505050}.nav-side-menu li.active a{color:#fff}.nav-side-menu ul .in{background-color:#f6f6f6}.nav-side-menu li .sub-menu li.active,.nav-side-menu ul .sub-menu li.active{color:#d19b3d}.nav-side-menu li .sub-menu li a{color:#505050}.nav-side-menu li .sub-menu li.active a,.nav-side-menu ul .sub-menu li.active a{color:#d19b3d}.nav-side-menu li .sub-menu li:hover,.nav-side-menu ul .sub-menu li:hover{background-color:#505050;color:#fff}.nav-side-menu li .sub-menu li a:hover,.nav-side-menu li li a:focus,.nav-side-menu ul .sub-menu li a:hover{color:#fff}.nav-side-menu li .sub-menu li:before,.nav-side-menu ul .sub-menu li:before{display:inline-block;padding-left:10px;padding-right:10px;vertical-align:middle}.nav-side-menu li{border-bottom:1px solid #e7e7e7}.nav-side-menu li a,.nav-side-menu li li a{padding-left:10px;text-decoration:none;color:#454545;display:inline-block;width:100%;line-height:35px}.nav-side-menu li a:focus,.nav-side-menu li a:hover,.nav-side-menu li li a:focus,.nav-side-menu li li a:hover,.nav-side-menu li:hover{color:#fff;background-color:#505050}.nav-side-menu li:hover{border-left:3px solid #505050;-webkit-transition:all 1s ease;-moz-transition:all 1s ease;-o-transition:all 1s ease;-ms-transition:all 1s ease;transition:all 1s ease}.sf-menu-caret{float:right;margin-right:10px;margin-top:12px}@media (max-width:767px){.nav-side-menu{position:relative;width:100%;margin-bottom:10px}.nav-side-menu .toggle-btn{display:block;cursor:pointer;position:absolute;right:10px;top:10px;z-index:10!important;padding:3px;background-color:#fff;color:#000;width:40px;text-align:center}.brand{text-align:left!important;font-size:22px;padding-left:20px;line-height:50px!important}}.dropdown-submenu,.nav-side-menu .open{position:relative}@media (min-width:767px){.nav-side-menu .menu-list .menu-content{display:block}}#dynamic_menu_row{border:none;border-radius:0;min-height:20px;z-index:1000;margin:0;background:0 0}#dynamic_menu_row .navbar-nav>li li a{padding-top:14px;padding-bottom:14px}#dynamic_menu_row .navbar-nav>.active>a,#dynamic_menu_row .navbar-nav>.active>a:hover,#dynamic_menu_row .navbar-nav>.open>a,#dynamic_menu_row .navbar-nav>.open>a:focus,#dynamic_menu_row .navbar-nav>.open>a:hover,#dynamic_menu_row .navbar-nav>li>a:hover,#dynamic_menu_row.navbar-nav>.active>a:focus{background-color:#505050}#dynamic_menu_row li a,#dynamic_menu_row li ul li a{color:#505050;font-size:16px;line-height:20px}#dynamic_menu_row .active a:focus,#dynamic_menu_row .navbar-nav>.open>a,#dynamic_menu_row .navbar-nav>.open>a:focus,#dynamic_menu_row a:hover,#dynamic_menu_row li.active>a{color:#fff;font-size:16px;line-height:20px}.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;-webkit-border-radius:0 6px 6px;-moz-border-radius:0 6px 6px;border-radius:0 6px 6px}.nav-side-menu .open>.dropdown-menu{top:35px;-webkit-border-radius:0 6px 6px;-moz-border-radius:0 6px 6px;border-radius:0 6px 6px}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu>a:after{display:block;content:" ";float:right;width:0;height:0;border-color:transparent transparent transparent #ccc;border-style:solid;border-width:5px 0 5px 5px;margin-top:5px;margin-right:-10px}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}
  • sf-bootstrap-menu/trunk/readme.txt

    r1259663 r1267318  
    11=== SF Bootstrap Menu ===
    22Contributors: Studiofreya
    3 Tags: child, pages, hierarchical, menu, sidebar, bootstrap, responsive, list
     3Tags: child, pages, hierarchical, menu, sidebar, horizontal, top, bootstrap, responsive, list
    44Requires at least: 3.8
    55Tested up to: 4.3.1
    66Stable tag: trunk
    77
    8 Responsive sidebar menu for hierarchical pages with Bootstrap 3.0.
     8Responsive sidebar menu wdiget for hierarchical pages with Bootstrap 3.0.
    99
    1010== Description ==
     
    1717
    1818= Features: =
     19* Choose between Horizontal and Vertical menu in each widget instance
    1920* New child pages are added to the menu automatically
    2021* Select your own colors
     
    2526* Mute top-level pages
    2627
     28This plugin was created to suit the SF Parent theme.
     29
    2730== Installation ==
    2831
    29 Install and activate the plugin as usual.
    30 
    31 = Then... =
    32 
    33 Go to Appearance > Widgets and drag SF Bootstrap Menu widget into place.
     32* Install and activate the plugin as usual.
     33* Go to Appearance > Widgets and drag SF Bootstrap Menu widget into place.
    3434
    3535Configure the settings for each menu instance.
     
    44442. Menu preview
    4545
     46[...more screenshots](http://studiofreya.com/wordpress-plugins/sf-bootstrap-menu/screenshots/)
     47
    4648== ChangeLog ==
    4749
  • sf-bootstrap-menu/trunk/sf-menu-widget.php

    r1254101 r1267318  
    99    $this->defaults = array(
    1010            'title'             => '',
     11            'alignment'         => '1',
    1112            'show_root'         => true,
    1213            'child_of'          => '',
    1314            'exclude'           => '',
    14             'sort_column'       => '',
     15            'sort_column'       => 'post_title',
    1516            'sort_order'        => 'ASC',
    1617            'post_status'       => '',
     
    2526   
    2627  }
    27 
    28 function sf_list_pages($args = '') {
    29     global $post;
    30     $output = '';
    31      
    32     if(!isset($args['exclude']) ) {
    33         $args['exclude'] = '';
    34     }
    35    
    36     if(!isset($args['sort_column'])) {
    37         $args['sort_column'] = '';
    38     }
    39 
    40     // Query pages.  NOTE: The array is sorted in alphabetical, or menu, order.
    41     $pages = get_pages($args);
    42      
    43     // Add pages that were selected
     28 
     29function list_vertical($args = '') {
     30     
    4431    $my_includes = Array();
    45 
    46     if ( $pages ) {
    47         $page_info = Array();
    48 
    49         foreach ( $pages as $page ) {
    50             $page_info[$page->ID]['parent'] = $page->post_parent;
    51             $page_info[$page->post_parent]['children'][] = $page->ID;
    52         }
    5332     
    5433      if (isset($args['child_of']) && $args['child_of']) {
     
    6039        }
    6140      } else {
    62         foreach ( $pages as $page ) {
    63             if (isset($page_info[$page->ID]['show']) && $page_info[$page->ID]['show']) {
    64               $my_includes[] = $page->ID;
    65             }
     41        // Query pages.  NOTE: The array is sorted in alphabetical, or menu, order.
     42        $pages = get_pages($args);
     43       
     44        foreach ( $pages as $page ) {
     45          $my_includes[] = $page->ID;
    6646          }
    6747      }
    68     }
    69      
    70       ?>
    71       <style type="text/css">
    72         .nav-side-menu {
    73           font-size: 12px;
    74           font-weight: 200;
    75           background-color: <?php echo $args['items_color']; ?>;
    76         }
    77         .nav-side-menu .brand {
    78           background-color: <?php echo $args['title_color']; ?>;
    79           line-height: 50px;
    80           display: block;
    81           text-align: center;
    82           font-size: 14px;
    83           color:#fff;
    84         }
    85       </style>
    86       <?php
    87      
    88 
     48   
     49    $pageids = array();
    8950    if (!empty($my_includes)) {   
    90         $pageids = array();
    9151        foreach($my_includes as $parent) {
    9252       
     
    10464            }
    10565        }
    106        
    107         // List pages, if any. Blank title_li suppresses unwanted elements.
    108         $output .= wp_list_pages( Array('title_li' => '',
     66    }
     67   
     68    $output = "";
     69    ?>
     70      <style type="text/css">
     71        .nav-side-menu {font-size: 12px;font-weight: 200;background-color: <?php echo $args['items_color']; ?>;     }
     72        .nav-side-menu .brand {background-color: <?php echo $args['title_color']; ?>;line-height: 50px;display: block;text-align: center;font-size: 14px; color:#fff;}
     73      </style>
     74      <?php
     75     
     76
     77    if (!empty($pageids)) {         
     78        // List pages, if any. Blank title_li suppresses unwanted elements.
     79        $output .= wp_list_pages( Array('title_li' => '',
    10980                    'sort_column' => $args['sort_column'],
    11081                    'sort_order' => $args['sort_order'],
     
    11283                    'exclude' => $args['exclude'],
    11384                    'walker'  => new sf_bootstrap_walker_page()
    114                 ) );                                   
    115        
    116     } else {
     85                ) );                                   
     86       
     87    } else {
    11788        $output .= wp_list_pages( Array('title_li' => '',
    11889                    'sort_column' => $args['sort_column'],
     
    12091                    'exclude' => $args['exclude'],
    12192                    'walker'  => new sf_bootstrap_walker_page()
    122                 ) );
    123     }
     93                ) );
     94    }
     95   
     96    return $output;
     97}
     98
     99function list_horizontal($args = '') {
     100     
     101    // Add pages that were selected
     102    $my_includes = Array();
     103
     104    if (isset($args['child_of']) && $args['child_of']) {
     105        $childs = $args['child_of'];
     106        $child_arr = explode(",", $childs);
     107       
     108        foreach($child_arr as $child) {
     109            $my_includes[] = $child;
     110        }
     111    } else {
     112            // Query pages.  NOTE: The array is sorted in alphabetical, or menu, order.
     113            $pages = get_pages($args);
     114            foreach ( $pages as $page ) {
     115                $my_includes[] = $page->ID;
     116            }
     117    }
     118   
     119    $pageids = array();
     120    if (!empty($my_includes)) {   
     121        foreach($my_includes as $parent) {
     122       
     123            if (isset($args['show_root']) && $args['show_root'] == 'yes') {
     124                array_push($pageids, $parent);
     125            }
     126           
     127            $args_child=array(
     128                'child_of' => $parent
     129            );
     130            $pages = get_pages($args_child);
     131           
     132            foreach ($pages as $page) {
     133                array_push($pageids, $page->ID);
     134            }
     135        }
     136    }
     137   
     138    $output = "";
     139    ?>
     140      <style type="text/css">
     141        .nav-side-menu {font-size: 12px;font-weight: 200;background-color: <?php echo $args['items_color']; ?>;}
     142      </style>
     143      <?php
     144     
     145
     146    if (!empty($pageids)) {   
     147        // List pages, if any. Blank title_li suppresses unwanted elements.
     148        $output .= wp_list_pages( Array('title_li' => '',
     149                    'sort_column' => $args['sort_column'],
     150                    'sort_order' => $args['sort_order'],
     151                    'include' => $pageids,
     152                    'exclude' => $args['exclude'],
     153                    'walker'  => new sf_bootstrap_walker_horizontal_menu()
     154                ) );                                   
     155       
     156    } else {
     157        $output .= wp_list_pages( Array('title_li' => '',
     158                    'sort_column' => $args['sort_column'],
     159                    'sort_order' => $args['sort_order'],
     160                    'exclude' => $args['exclude'],
     161                    'walker'  => new sf_bootstrap_walker_horizontal_menu()
     162                ) );
     163    }
     164   
     165    return $output;
     166}
     167
     168function sf_list_pages($args = '') {
     169    $output = '';
     170     
     171    if(!isset($args['exclude']) ) {
     172        $args['exclude'] = '';
     173    }
     174   
     175    if(!isset($args['sort_column'])) {
     176        $args['sort_column'] = '';
     177    }
     178   
     179     
     180    $output = "";
     181    if (isset($args['alignment']) && $args['alignment'] == '1') {
     182        $output = $this->list_vertical($args);
     183    } else {
     184        $output = $this->list_horizontal($args);
     185     }
    124186
    125187    $output = apply_filters('wp_list_pages', $output);
     
    141203    }
    142204         
     205    //Horizontal
     206    if(isset($instance['alignment']) && $instance['alignment'] == 2) {
    143207    ?>
     208    <nav id="dynamic_menu_row" class="navbar navbar-default" role="navigation">
     209        <button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target=".nav-horizontal-menu-collapse">
     210            <span class="sr-only">Toggle navigation</span>
     211            <span >Menu</span>
     212        </button>
     213        <div class="navbar-collapse nav-horizontal-menu-collapse collapse">
     214            <ul id="menu-horizontal" class="nav navbar-nav">                       
     215            <?php $this->sf_list_pages($page_options); ?>
     216            </ul>
     217        </div>
     218    </nav>
     219    <?php
     220    } else {
     221   
     222    //Vertical sidemenu
     223    ?>
    144224    <div class="nav-side-menu">
    145     <div class="brand"><?php echo "$title"; ?></div>
    146      <i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
    147     <div class="menu-list">
    148         <ul id="menu-content" class="menu-content collapse out">
    149                
    150     <?php
    151         $this->sf_list_pages($page_options);
    152     ?>
    153     </ul>
    154    
    155     </div>
     225        <div class="brand"><?php echo "$title"; ?></div>
     226        <i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
     227        <div class="menu-list">
     228            <ul id="menu-content" class="menu-content collapse out">                       
     229            <?php $this->sf_list_pages($page_options); ?>
     230            </ul>
     231        </div>
    156232    </div>
    157233    <?php
    158    
     234    }
    159235  }
    160236
     
    163239    $option_menu = array(
    164240            'title' => array('title' => __("Title:", $tdom)),
     241            'alignment' => array('title' => __("Menu alignment", $tdom),
     242                        'type' => 'select'),
    165243            'child_of' => array('title' => __("Root pages:", $tdom),
    166244                        'desc' => __("List of root page IDs to show", $tdom)),
     
    193271    $known_params = $this->known_params();
    194272    unset($instance['menu_order']);
     273   
    195274    foreach ($known_params as $param) {
    196275      $instance[$param] = strip_tags(stripslashes($new_instance[$param]));
     
    199278        $instance[$param]['value'] = $new_instance[$param]['value'];
    200279      }
     280     
     281      if($param == 'alignment') {
     282        $instance[$param] = $new_instance[$param];
     283      }
     284     
    201285    }
    202286    $instance['sort_order'] = strtolower($instance['sort_order']) == 'desc'?'DESC':'ASC';
     
    214298      $instance['sort_column'] = 'menu_order,post_title';
    215299    }
    216     if (empty($instance['sort_column'])) {
    217       $instance['sort_column'] = 'post_title';
    218     }
    219300
    220301    $option_menu = $this->known_params(1);
     
    227308
    228309    foreach ($option_menu as $option_name => $option) {
     310   
     311        $name = $this->get_field_name($option_name);
     312       
    229313        $checkval='';
    230314        $desc = '';
     315        $h = '';
     316        $v = '';
    231317        if (isset($option['desc']) && $option['desc']) {
    232318          $desc = '<br /><small>' . __($option['desc'], $tdom) . '</small>';
     
    247333              break;
    248334        }
    249        
    250         print '<p style="text-align:right;"><label for="' . $this->get_field_name($option_name) . '">' .
    251           __($option['title'], $tdom) .
    252           ' <input style="width: 200px;" id="' . $this->get_field_id($option_name) .
    253           '" name="' . $this->get_field_name($option_name) .
    254           "\" type=\"{$option['type']}\" {$checkval}value=\"{$param_display[$option_name]}\" /></label>$desc</p>";
    255     }
    256   }
    257 
     335           
     336        if($option['type'] == "select") {   
     337?>         
     338           
     339            <p style="text-align:right;">
     340            <label for="<?php echo $this->get_field_name($option_name); ?>"><?php echo __($option['title'], $tdom); ?>
     341            <select style="width: 200px;" id="<?php echo $this->get_field_id($option_name); ?>" name="<?php echo $this->get_field_name($option_name); ?>">
     342            <?php for ($i=1;$i<=2;$i++) {
     343                echo '<option value="'.$i.'"';
     344                if ($i==$instance['alignment']) echo ' selected="selected"';
     345                if($i==1) {
     346                    echo '>Vertical</option>';
     347                } else {
     348                    echo '>Horizontal</option>';
     349                }
     350             } ?>
     351            </select></label><?php echo $desc; ?></p>
     352<?php
     353        } else {
     354        print '<p style="text-align:right;">
     355            <label for="' . $this->get_field_name($option_name) . '">' .
     356          __($option['title'], $tdom) . '
     357            <input style="width: 200px;" id="' . $this->get_field_id($option_name) . '" name="' . $name . "\" type=\"{$option['type']}\" {$checkval}value=\"{$param_display[$option_name]}\" />
     358            </label>$desc</p>";
     359          }
     360    }
     361  }
     362   
    258363}
    259364
  • sf-bootstrap-menu/trunk/sf-menu.php

    r1259663 r1267318  
    33 * Plugin Name: SF Bootstrap Menu
    44 * Plugin URI: http://studiofreya.com/sf-bootstrap-menu
    5  * Description: Responsive menu for pages and posts with Bootstrap 3.0
    6  * Version: 1.2.1
     5 * Description: Responsive menu for child pages with Bootstrap 3.0
     6 * Version: 2.0
    77 * Author: Studiofreya AS
    88 * Author URI: http://studiofreya.com
     
    1313    require('sf-menu-widget.php' );
    1414    require('sf-navwalker.php');
     15    require('sf-navwalker-horizontal.php');
    1516   
    1617    register_widget('SfMenuWidget');
     
    3334   
    3435    if ( (!wp_script_is( $bootstrap, 'queue' ) ) && ( ! wp_script_is( $bootstrap, 'done' ) ) )  {
    35        wp_register_script( 'sf-bootstrap', plugin_dir_url(__FILE__).'js/bootstrap.min.js');
    36        wp_enqueue_script( 'sf-bootstrap' );
     36       wp_register_script( 'bootstrap', plugin_dir_url(__FILE__).'js/bootstrap.min.js', array('jquery'), false, true);
     37       wp_enqueue_script( 'bootstrap' );
    3738    }
    3839}
  • sf-bootstrap-menu/trunk/sf-navwalker.php

    r1259663 r1267318  
    1616
    1717    if ( !empty($this->curItem) && !empty($this->activeItem) && $this->curItem == $this->activeItem){
    18         $output .= "\n$indent<ul class='sub-menu collapse in' role='menu'>\n";
     18        $output .= "\n$indent<ul class='dropdown-menu sub-menu collapse in' role='menu'>\n";
    1919    } else {
    20         $output .= "\n$indent<ul class='sub-menu collapse' role='menu'>\n";
     20        $output .= "\n$indent<ul class='dropdown-menu sub-menu collapse' role='menu'>\n";
    2121    }
    2222}
     
    4747
    4848    extract($args, EXTR_SKIP);
    49     $css_class = array();//'page-item-'.$page->ID);
     49    $css_class = array();
    5050    $arrow = "";
    5151    $arrow_link = "";
    5252
    5353    if( isset( $args['pages_with_children'][ $page->ID ] ) ) {
    54         $css_class[] = 'collapsed';
    55     $arrow = "<span class='caret sf-menu-caret'></span>";
    56     $arrow_link=" data-toggle='collapse' data-target='#'";
    57 }
     54        if($depth > 0) {
     55            $css_class[] = 'dropdown-submenu';
     56        } else {
     57            $arrow = "<b class='caret sf-menu-caret'></b>";
     58            $arrow_link=" data-toggle='dropdown'";
     59        }
     60    }
    5861
    5962    if ( !empty($current_page) ) {
    6063        $_current_page = get_post( $current_page );
    61         if ( in_array( $page->ID, $_current_page->ancestors ) ) {
    62         $arrow = "<span class='caret sf-menu-caret'></span>";
    63     }
    64        
    65     if ( $page->ID == $current_page ) {
    66             $css_class[] = 'active';
    67         $this->activeItem = $page->ID;
    68     }
    69         elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
    70             $css_class[] = 'active';
    71         $this->activeItem = $current_page;
    72     }
    73     elseif (!empty($_current_page->post_parent) ) {
    74         $parent_page = get_post( $_current_page->post_parent );
    75         if (!empty($parent_page->post_parent) && $page->ID == $parent_page->post_parent ) {
    76             $css_class[] = 'active';
     64           
     65        if ( $page->ID == $current_page ) {
     66                $css_class[] = 'active';
     67            $this->activeItem = $page->ID;
     68        }
     69            elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
     70                $css_class[] = 'active';
    7771            $this->activeItem = $current_page;
    7872        }
    79     }
     73        elseif (!empty($_current_page->post_parent) ) {
     74            $parent_page = get_post( $_current_page->post_parent );
     75            if (!empty($parent_page->post_parent) && $page->ID == $parent_page->post_parent ) {
     76                //$css_class[] = 'active';
     77                $this->activeItem = $current_page;
     78            }
     79        }
    8080    } elseif ( $page->ID == get_option('page_for_posts') ) {
    8181        $css_class[] = '';
    8282    }
    8383
     84    $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $page->ID, $page, $args );
     85    $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
     86   
     87    $classes = empty( $css_class ) ? array() : (array) $css_class;
     88    $classes[] = 'menu-item-' . $page->ID;
     89    $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $page, $args ) );
     90   
     91
     92    if ( in_array( 'current-menu-item', $classes ) )
     93        $class_names .= ' active';
     94   
     95    $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
     96   
    8497    /**
    8598     * Filter the list of CSS classes to include with each page item in the list.
     
    103116
    104117   
    105     $output .= $indent . '<li class="' . $css_class . '"' . $arrow_link . '><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after .  $arrow .'</a>';
     118    $output .= $indent . '<li ' . $id . $class_names . '><a href="' . get_permalink($page->ID) . '"' . $arrow_link . '>' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after .  $arrow .'</a>';
    106119   
    107120
Note: See TracChangeset for help on using the changeset viewer.