Plugin Directory

Changeset 1503345


Ignore:
Timestamp:
09/27/2016 06:25:34 AM (10 years ago)
Author:
Studiofreya
Message:

Always expanded menu feature with grandchildren

Location:
sf-bootstrap-menu
Files:
26 added
2 edited

Legend:

Unmodified
Added
Removed
  • sf-bootstrap-menu/trunk/readme.txt

    r1494737 r1503345  
    1212SF Bootstrap Menu is an easy customizable widget to show hierarchical pages. The menu uses the latest Bootstrap 3.0 framework and provides responsive design for desktops, phones and tablets.
    1313
    14 [Plugin website](http://studiofreya.com/wordpress/wordpress-plugins/sf-bootstrap-menu/)
     14[Plugin website](https://studiofreya.com/wordpress/sf-bootstrap-menu/)
    1515
    1616The plugin allows the user to insert the widget into any widget area.
     
    2525* Supports up to 3 levels
    2626* Mute top-level pages
    27 
    28 This plugin was created to suit the SF Parent theme.
     27* Expanded vertical menus. These can be used for online books like our <a href="https://studiofreya.com/cpp/concepts/">C++ Concepts book</a>.
    2928
    3029== Installation ==
     
    3736== Frequently Asked Questions ==
    3837
    39 [SF Bootstrap Menu FAQ](http://studiofreya.com/wordpress/wordpress-plugins/sf-bootstrap-menu/faq/)
     38[SF Bootstrap Menu FAQ](https://studiofreya.com/wordpress/sf-bootstrap-menu/faq/)
    4039
    4140
     
    45443. Horizontal and vertical menus on one page
    4645
    47 [...more screenshots](http://studiofreya.com/wordpress-plugins/sf-bootstrap-menu/screenshots/)
     46[...more screenshots](https://studiofreya.com/wordpress/sf-bootstrap-menu/screenshots/)
    4847
    4948== ChangeLog ==
    5049
    51 [SF Bootstrap Menu Changelog](http://studiofreya.com/wordpress/wordpress-plugins/sf-bootstrap-menu/changelog/)
     50[SF Bootstrap Menu Changelog](https://studiofreya.com/wordpress/sf-bootstrap-menu/changelog/)
    5251
    5352== Upgrade Notice ==
  • sf-bootstrap-menu/trunk/sf-menu-widget.php

    r1494737 r1503345  
    5555    if (!empty($my_includes)) {   
    5656        foreach($my_includes as $parent) {
    57        
    5857            if (isset($args['show_root']) && $args['show_root'] == 'yes') {
    5958                array_push($pageids, $parent);
     
    6160           
    6261            $args_child=array(
    63                 'child_of' => $parent
     62                'post_type'   => 'page',
     63                'post_parent' => $parent,
     64                'orderby'     => 'menu_order',
     65                'order'   => 'ASC',
    6466            );
    65             $pages = get_pages($args_child);
    66            
    67             foreach ($pages as $page) {
    68                 array_push($pageids, $page->ID);
     67            $child_pages = new WP_Query( $args_child );
     68           
     69            while ( $child_pages->have_posts() ) {
     70                $child_pages->the_post();
     71                $r = get_the_ID();
     72                //echo "pp: $r, ";
     73                array_push($pageids, $r);
    6974            }
     75           
    7076        }
    7177    }
     
    8288      <?php
    8389     
     90    if($args['expanded'] == true) {
     91        $this->show_expanded($pageids);
     92               
     93        return $output;
     94    }
    8495
    8596    if (!empty($pageids)) {         
     
    90101                    'include' => $pageids,
    91102                    'exclude' => $args['exclude'],
    92                     'walker'  => new sf_bootstrap_walker_page($args['expanded'])
     103                    'walker'  => new sf_bootstrap_walker_page()
    93104                ) );                                   
    94105       
     
    98109                    'sort_order' => $args['sort_order'],
    99110                    'exclude' => $args['exclude'],
    100                     'walker'  => new sf_bootstrap_walker_page($args['expanded'])
     111                    'walker'  => new sf_bootstrap_walker_page()
    101112                ) );
    102113    }
     
    104115    return $output;
    105116}
     117
     118function show_expanded($pageids) {
     119    echo '<ul class="child_page_row">';
     120    foreach($pageids as $p) {
     121        echo $this->show_children_of_expanded($p);
     122    }
     123    echo '</ul>';
     124}
     125
     126function show_children_of_expanded($id) {
     127       
     128    $this->list_page($id);
     129   
     130    global $post;
     131    $child_pages_query_args = array(
     132        'post_type'   => 'page',
     133        'child_of' => $id,
     134        'orderby'     => 'menu_order',
     135        'order'   => 'ASC',
     136    );
     137     
     138    $child_pages = get_pages( $child_pages_query_args );
     139   
     140    $c =  count($child_pages);
     141    if ( $child_pages && $c > 0) :
     142       
     143        echo '<ul class="always-open">';
     144        foreach($child_pages as $page) {
     145            $this->list_page($page->ID);
     146            //$this->show_children_of_expanded($page);
     147        }
     148        echo '</ul>';
     149    endif;
     150    wp_reset_postdata();
     151}
     152     
     153function list_page($p) {
     154    global $post;
     155    $class_names = "";
     156   
     157    $r = $post->ID;
     158    $rr = $p;
     159    //echo "r: $r, rr: $rr";
     160   
     161    if($post->ID == $p) {
     162        $class_names .= ' active';
     163    }
     164   
     165    echo '<li class="'. $class_names .'"><a href="';
     166    echo  get_permalink($p);
     167    echo  '">';
     168    echo  get_the_title($p);
     169    echo  '</a></li>';
     170}
     171 
    106172
    107173function list_horizontal($args = '') {
Note: See TracChangeset for help on using the changeset viewer.