Plugin Directory

Changeset 537426


Ignore:
Timestamp:
04/27/2012 06:10:45 PM (14 years ago)
Author:
oltdev
Message:

Updated the subpages widget to support custom menus as well. Removed code WP2.7 support and also got rid of prettyPhoto.css which is not GPL.

Location:
subpage-navigation
Files:
1 deleted
4 edited
8 copied

Legend:

Unmodified
Added
Removed
  • subpage-navigation/trunk/readme.txt

    r390019 r537426  
    11=== Subpages Navigation ===
    2 Contributors: oltdev, godfreykfc, enej
     2Contributors: oltdev, godfreykfc, enej, ejackisch
    33Tags: pages, subpages, shortcode, widget, menu, navigation, collapsible, tree, sitemap
    44Requires at least: 2.8
     
    5858== Change log ==
    5959
     60= 1.2 =
     61* Added the ability to display custom nav menus
     62* [subpages] shortcode now supports the auto-expand current level feature (expand='true') and menu parameter (menu='menu name') to display a custom menu
     63* removed the ability to
     64
    6065= 1.1.1=
    6166* bugfix: some of the js and css files were not loaded properly.
  • subpage-navigation/trunk/subpages-navigation-admin.js

    r218414 r537426  
    88    });
    99   
    10     $('.olt-subpages-root').live('click',function(){
     10    $('.olt-subpages-root').live('change',function(){
    1111        var widget = $(this).parents('.widget-content:first');
    12         if($(this).val() != -1)
     12       
     13        if($(this).val() != -1){
    1314            $('.olt-subpages-siblings', widget).attr('disabled','disabled').css('color','#999');
    14         else
    15             $('.olt-subpages-siblings', widget).removeAttr('disabled').css('color','#000');
     15        }else{
     16            $('.olt-subpages-siblings', widget).removeAttr('disabled').css('color','#000');     
     17        }
    1618    });
    1719   
     
    2325            $('.olt-subpages-nested-options', widget).attr('disabled','disabled').css('color','#999');
    2426    }); 
     27   
    2528});
  • subpage-navigation/trunk/subpages-navigation.js

    r218414 r537426  
    3535        });
    3636   
     37   
     38    //(for some reason trying to consolidate these 2 selectors into one is giving me problems)
     39   
    3740    // Expand current level (widget only)
    3841    $('.subpages-navi-widget.subpages-navi-collapsible.subpages-navi-auto-expand li.subpages-navi-current-level')
     
    4144       .end()
    4245       .find('>.hitarea').click();
     46   
     47    //Expand current level shortcode
     48     $('.subpages-navi-shortcode.subpages-navi-collapsible.subpages-navi-auto-expand li.subpages-navi-current-level')
     49       .parents('li.parent:first')
     50           .find('>.hitarea').click().end()
     51       .end()
     52       .find('>.hitarea').click();
     53       
    4354});
  • subpage-navigation/trunk/subpages-navigation.php

    r390019 r537426  
    44 * Plugin URI: http://olt.ubc.ca
    55 * Description: Create subpages navigation menu with sidebar widgets and shortcodes.
    6  * Version: 1.1.1
     6 * Version: 1.2
    77 * Author: Enej Bajgoric / Godfrey Chan / Michael Ha / OLT
    88 * Author URI: http://blogs.ubc.ca/
     
    6262        global $post;
    6363       
    64        
    6564        if(is_page()):
    6665            /* Extract the arguments  */   
    6766            extract( $args );
    6867            extract( $instance);
    69            
    7068           
    7169            /* Find the root post */
    72             if($root == 0): #all pages
     70            if($root === '0'): #all pages
    7371                $root_id = "0";
    7472                $pages = get_pages("sort_column=menu_order");
     
    8987                endif;
    9088               
    91             else: # subpages of the current page
     89            elseif($root == -1): # subpages of the current page
    9290               
    9391               
     
    104102                    $title_link = get_permalink($post->ID);
    105103                endif;
    106                
    107                
     104            else:   
     105               
     106                if(function_exists('wp_get_nav_menu_items')):
     107                    $pages = wp_get_nav_menu_items(substr($root,5));
     108                    $using_menu=true;
     109                endif;
    108110            endif;
     111           
     112           
    109113           
    110114            if($top_title):
     
    120124                       
    121125            /* Prepare the walker */
    122             $walker = new SubpagesNavigationPageList;
     126           
     127            //$pages = wp_get_nav_menu_items('test-menu'); $menu=true;
     128           
     129            $walker = new SubpagesNavigationPageList($using_menu);
    123130           
    124131            if(is_array($pages) && !empty($pages)):
     
    184191        $instance['top_title'] = $new_instance['top_title'];
    185192        $instance['root'] = $new_instance['root'];
     193        //$instance['menu'] = $new_instance['menu'];
    186194        $instance['title_link'] = $new_instance['title_link'];
    187195        $instance['siblings'] = $new_instance['siblings'];
     
    244252            <option value="0"  <?php selected($instance['root'], 0); ?>><?php _e('all pages', 'olt_subpages_navigation'); ?></option>
    245253            <option value="1" <?php selected($instance['root'], 1); ?>><?php _e('subpages of the top-level page', 'olt_subpages_navigation'); ?></option>
     254           
     255            <?php
     256                $menus = get_terms('nav_menu');
     257                if(count($menus)):
     258                   
     259                    echo '<option value="" disabled="disabled">-- Custom Nav Menus--</option> \n';
     260                   
     261                    foreach($menus as $menu):
     262                      echo '<option value="menu_' . $menu->name . '"' . selected($instance['root'], 'menu_'.$menu->name) . '>' . $menu->name . '</option> \n';
     263                    endforeach;
     264                endif;
     265            ?>
     266           
    246267            </select>
    247268            <input type="checkbox" name="<?php echo $this->get_field_name( 'siblings' ); ?>" id="<?php echo $this->get_field_id( 'siblings' ); ?>" value="true" <?php checked($instance['siblings'], "true"); ?> <?php if($instance['root'] != -1) echo $dm; ?> class="olt-subpages-siblings"/>
    248269            <label for="<?php echo $this->get_field_id( 'siblings' ); ?>" <?php if($instance['root'] != -1) echo $dm; ?> class="olt-subpages-siblings"><?php _e('and its siblings', 'olt_subpages_navigation'); ?></label>
     270       
    249271        </p>
    250272       
     
    289311add_shortcode('subpages', 'subpages_navigation_shortcode');
    290312/*
    291  * Subpage naviagtion shortcode
     313 * Subpage navigation shortcode
    292314 *********************************************/
    293315function subpages_navigation_shortcode($atts) {
    294316        global $post;
     317        $using_menu=false;
    295318        extract(shortcode_atts(array(
    296319            'depth' => '0',
     
    298321            'collapsible' => 'true',
    299322            'exclusive' => 'false',
     323            'expand' => 'false',
     324            'menu' => '0',
    300325        ), $atts));
    301326       
    302327        // Get all subpages of the current page
    303328        $root = ($siblings == 'true')? $post->post_parent : $post->ID;
    304         $pages = get_pages("child_of={$root}&sort_column=menu_order");
    305        
     329        if($menu):
     330            $using_menu=true;
     331            $pages = wp_get_nav_menu_items($menu);
     332       
     333        else:
     334            $pages = get_pages("child_of={$root}&sort_column=menu_order");
     335        endif;
     336       
    306337        // Prepare the walker
    307         $walker = new SubpagesNavigationPageList;
    308        
    309         $output  = '<ul class="subpages-navi';
     338        $walker = new SubpagesNavigationPageList($using_menu);
     339       
     340        $output  = '<ul class="subpages-navi subpages-navi-shortcode';
    310341        if($collapsible == 'true')
    311342            $output .= ' subpages-navi-collapsible';
    312343        if($exclusive == 'true')
    313344            $output .= ' subpages-navi-exclusive';
     345        if($expand == 'true')
     346            $output .= ' subpages-navi-auto-expand';
    314347        $output .= "\">\n";
    315348        $output .= $walker->walk($pages, (int) $depth, array('current_level' => $post->ID));
     
    335368        if(SUBPAGE_NAVIGATION_SCRIPT)
    336369            wp_enqueue_script('subpages-navigation', plugins_url('/subpage-navigation/subpages-navigation.js'), array('jquery'));
    337        
     370           
    338371        if(SUBPAGE_NAVIGATION_STYLE){
    339372            if (file_exists(STYLESHEETPATH."/subpages-navigation.css") )
     
    359392class SubpagesNavigationPageList extends Walker {
    360393    var $tree_type = 'page';
     394    //var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
    361395    var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
     396    var $menu;
     397   
     398    function __construct($menu = false){
     399       
     400        if($menu):
     401            //If we're using a menu we need to retrieve slightly different info from the object we're traversing.
     402            $this->menu=true;
     403            $this->db_fields['parent'] = 'menu_item_parent';
     404        endif;
     405    }
    362406   
    363407    function start_lvl(&$output, $depth, $args) {
     
    373417    function start_el(&$output, $page, $depth, $args) {
    374418        extract($args);
    375        
    376         $title = esc_html($page->post_title);
    377         $link  = get_permalink($page->ID);
     419       
     420        if($this->menu):
     421            $title = esc_html($page->title);
     422            $link = $page->url;
     423        else:
     424            $title = esc_html($page->post_title);
     425            $link  = get_permalink($page->ID);
     426        endif;
     427       
     428       
    378429       
    379430        $indent  = str_repeat("    ", $depth)."  ";
    380431        $output .= $indent."<li class=\"subpages-navi-node subpages-navi-level-$depth";
    381         if ($current_level == $page->ID)
    382             $output .= ' subpages-navi-current-level';
     432        if( $this->menu ):
     433            if ($current_level == $page->object_id):
     434                $output .= ' subpages-navi-current-level';
     435            endif;
     436        else:
     437            if ($current_level == $page->ID):
     438                $output .= ' subpages-navi-current-level';
     439            endif;
     440        endif;
     441       
    383442        $output .= "\">\n";
    384443        $output .= $indent."  <a href=\"$link";
Note: See TracChangeset for help on using the changeset viewer.