WordPress.org

Plugin Directory

Changeset 589634


Ignore:
Timestamp:
08/24/12 04:58:12 (20 months ago)
Author:
Viper007Bond
Message:

v1.2.0: WordPress 3.5 compatibility

Location:
add-descendants-as-submenu-items/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • add-descendants-as-submenu-items/trunk

    • Property svn:ignore set to
      deploy.sh
      README.md
      .git
      .gitignore
  • add-descendants-as-submenu-items/trunk/add-descendants-as-submenu-items.php

    r436991 r589634  
    66Plugin URI:   http://www.viper007bond.com/wordpress-plugins/add-descendants-as-submenu-items/ 
    77Description:  Automatically all of a nav menu item's descendants as submenu items. Designed for pages but will work with any hierarchical post type or taxonomy. 
    8 Version:      1.1.0 
     8Version:      1.2.0 
    99Author:       Alex Mills (Viper007Bond) 
    1010Author URI:   http://www.viper007bond.com/ 
     
    1515************************************************************************** 
    1616 
    17 Copyright (C) 2011 Alex Mills (Viper007Bond) 
     17Copyright (C) 2011-2012 Alex Mills (Viper007Bond) 
    1818 
    1919This program is free software: you can redistribute it and/or modify 
     
    315315 
    316316        // Only need to fix items added by this plugin 
    317         if ( empty( $this->added[$queried_object_id] ) ) 
     317        if ( empty( $queried_object_id ) || empty( $this->added[$queried_object_id] ) ) 
    318318            return $items; 
    319319 
    320320        // Get ancestors of currently displayed item 
    321         if ( is_category() || is_tag() || is_tax() ) { 
     321        if ( isset( $queried_object->term_id ) ) { 
    322322            $ancestors = get_ancestors( $queried_object->term_id, $queried_object->taxonomy ); 
    323323            $parent_field = 'parent'; 
     324            $type = 'taxonomy'; 
     325        } elseif ( is_singular() ) { 
     326            $ancestors = get_post_ancestors( $queried_object_id ); 
     327            $parent_field = 'post_parent'; 
     328            $type = 'post_type'; 
    324329        } else { 
    325             _get_post_ancestors( $queried_object ); 
    326             $ancestors = $queried_object->ancestors; 
    327             $parent_field = 'post_parent'; 
     330            return $items; 
    328331        } 
    329332 
     
    332335        foreach ( $items as $item ) { 
    333336            if ( ! in_array( $item->object_id, $ancestors ) ) 
     337                continue; 
     338 
     339            // Only highlight things of the same type because IDs can collide 
     340            if ( $item->type !== $type ) 
    334341                continue; 
    335342 
  • add-descendants-as-submenu-items/trunk/readme.txt

    r436591 r589634  
    22Contributors: Viper007Bond 
    33Tags: menu, nav menu, children, descendants 
    4 Tested up to: 3.3 
    5 Stable tag: trunk 
     4Tested up to: 3.5 
     5Stable tag: 1.2.0 
    66 
    77Automatically all of a nav menu item's descendants as submenu items. Designed for pages but will work with any hierarchical post type or taxonomy. 
     
    2424== ChangeLog == 
    2525 
     26= Version 1.2.0 = 
     27* `_get_post_ancestors()` will/was deprecated in WordPress 3.5 and no longer works. Parts of this plugin have been rewritten to more properly get post ancestors. 
     28* Bug fix: Don't highlight parents of different types. Post types and terms can have the same IDs. 
     29 
    2630= Version 1.1.0 = 
    2731* Support for hierarchical taxonomies (i.e. categories). Props WPAddiction for the idea. 
     
    3741 
    3842= 1.1.0 = 
    39 Support for hierarchical taxonomies (i.e. categories). Props WPAddiction for the idea. 
     43Various bug fixes. 
Note: See TracChangeset for help on using the changeset viewer.