Plugin Directory

Changeset 822687


Ignore:
Timestamp:
12/15/2013 09:11:37 PM (12 years ago)
Author:
pmenard
Message:

Pages Children 1.5.2.1

Location:
pages-children/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pages-children/trunk/pages-children.php

    r514077 r822687  
    55Description: Display hierarchical post types and taxonomies a single level pages at a time.
    66Author: Paul Menard
    7 Version: 1.5.2
     7Version: 1.5.2.1
    88Author URI: http://www.codehooligans.com
    99*/
     
    1515    var $post_type_object;
    1616   
    17     function PagesChildren() {
     17    function __construct() {
    1818
    1919        $this->object_post_taxonomy = null;
    2020        $this->terms_args_cnt = 0;
     21
     22        if (!defined('PAGES_CHILDREN_TAXONOMY'))
     23            define('PAGES_CHILDREN_TAXONOMY', 3);
    2124       
    2225        add_action( 'init',                         array(&$this, 'init' ));
     
    2831    }
    2932   
     33    function PagesChildren() {
     34        $this->__construct();
     35    }
     36       
    3037    function init() {
    3138        $plugin_dir = basename(dirname(__FILE__))."/lang";
     
    4754        }
    4855        $this->filter_admin_menu();
    49 
     56       
    5057        if (isset($_GET['post_type']))
    5158            $this->object_post_taxonomy = get_post_type_object($_GET['post_type']);
     
    8491                                    if (!isset($qs_vars['order']))
    8592                                        $qs_vars['order'] = 'asc';
    86                                        
     93                                   
     94                                    $qs = '';   
    8795                                    foreach($qs_vars as $qs_idx => $qs_val)
    8896                                    {                       
     
    372380    function get_terms_args_filter($args, $taxonomies)
    373381    {       
    374         if (($this->check_uri('wp-admin/edit-tags.php')) && ( isset($_GET['taxonomy'])) && (is_taxonomy_hierarchical($_GET['taxonomy'])))
    375         {
    376             if ((isset($_GET['action'])) && ($_GET['action'] == "edit")) return $args;
    377            
    378             $this->terms_args_cnt += 1;
    379             #1 the table pager
    380             #2 the table listing itself
    381             #3 the dropdown on the entry form.
    382             if ($this->terms_args_cnt > 2)
    383             {   
    384 //              echo "terms_args_cnt=[". $this->terms_args_cnt ."]<br />";
    385 //              echo "args<pre>"; print_r($args); echo "</pre>";
    386                 return $args;
    387             }
    388 
    389             $parent_id = 0;
    390            
    391             if (isset($_GET['parent']))
    392                 $parent_id = intval($_GET['parent']);
    393             else if (isset($_COOKIE['pages-children-'. $_GET['taxonomy'] .'-parent-id']))
    394                 $parent_id = intval($_COOKIE['pages-children-'. $_GET['taxonomy'] .'-parent-id']);
    395 
    396             remove_filter('get_terms_args',             array($this, 'get_terms_args_filter'), 10, 2);
    397 
    398             $terms_args = array(
    399                 'hide_empty'    =>  0,
    400                 'hierarchical'  =>  1,
    401                 'parent'        =>  $parent_id,
    402                 'child_of'      =>  $parent_id
    403             );
    404 
    405             $child_terms = get_terms( $_GET['taxonomy'], $terms_args);
    406            
    407             add_filter('get_terms_args',                array($this, 'get_terms_args_filter'), 10, 2);
    408             if ($child_terms)
    409             {
    410                 $args['hide_empty']     = 0;
    411                 $args['parent']         = $parent_id;
    412                 $args['child_of']       = $parent_id;
    413                 $args['hierarchical']   = 1;
    414             }
     382        //if (($this->check_uri('wp-admin/edit-tags.php')) && ( isset($_GET['taxonomy'])) && (is_taxonomy_hierarchical($_GET['taxonomy'])))
     383        if (!$this->check_uri('wp-admin/edit-tags.php'))
     384            return $args;
     385           
     386        if ( !isset($_GET['taxonomy']))
     387            return $args;
     388
     389        if (!is_taxonomy_hierarchical($_GET['taxonomy']))
     390            return args;
     391       
     392        if ((isset($_GET['action'])) && ($_GET['action'] == "edit")) return $args;
     393       
     394        // Check if there is a defin for this taxonomy.
     395        if (!defined('PAGES_CHILDREN_TAXONOMY_'. strtoupper($_GET['taxonomy']))) {
     396            // If not use the default 'PAGES_CHILDREN_TAXONOMY' define (3)
     397            define('PAGES_CHILDREN_TAXONOMY_'. strtoupper($_GET['taxonomy']), PAGES_CHILDREN_TAXONOMY);
     398        }
     399        $taxonomy_counter = constant('PAGES_CHILDREN_TAXONOMY_'. strtoupper($_GET['taxonomy']));
     400
     401        $this->terms_args_cnt += 1;
     402       
     403        if ($this->terms_args_cnt != $taxonomy_counter)
     404            return $args;
     405
     406        $parent_id = 0;
     407       
     408        if (isset($_GET['parent']))
     409            $parent_id = intval($_GET['parent']);
     410        else if (isset($_COOKIE['pages-children-'. $_GET['taxonomy'] .'-parent-id']))
     411            $parent_id = intval($_COOKIE['pages-children-'. $_GET['taxonomy'] .'-parent-id']);
     412
     413        remove_filter('get_terms_args',             array($this, 'get_terms_args_filter'), 10, 2);
     414
     415        $terms_args = array(
     416            'hide_empty'    =>  0,
     417            'hierarchical'  =>  1,
     418            'parent'        =>  $parent_id,
     419            'child_of'      =>  $parent_id
     420        );
     421
     422        $child_terms = get_terms( $_GET['taxonomy'], $terms_args);
     423       
     424        add_filter('get_terms_args',                array($this, 'get_terms_args_filter'), 10, 2);
     425        if ($child_terms)
     426        {
     427            $args['hide_empty']     = 0;
     428            $args['parent']         = $parent_id;
     429            $args['child_of']       = $parent_id;
     430            $args['hierarchical']   = 1;
    415431        }
    416432        return $args;
  • pages-children/trunk/readme.txt

    r514077 r822687  
    33Donate link: http://www.codehooligans.com/donations/
    44Tags: pages, post types, taxonomies, page management, edit, display, hierarchical
    5 Requires at least: 3.1.3
    6 Tested up to: 3.3.1
    7 Stable tag: 1.5.2
     5Requires at least: 3.7
     6Tested up to: 3.8
     7Stable tag: 1.5.2.1
    88
    99== Description ==
     
    5353== Changelog ==
    5454
     55= 1.5.2.1 =
     56* 2013-12-15:
     57* Minor bug. Fixed issue with taxonomy nested items not working on 3.7 and newer. Thanks Euan!
     58* Also checked UI functionality for WP 3.8.
     59
    5560= 1.5.2 =
    56 *2012-03-03: Minor bug fixes when mixed Published and Draft Pages. The bug prevented getting down to or moving up the hierarchy if the child or parent were in draft status.
     61* 2012-03-03: Minor bug fixes when mixed Published and Draft Pages. The bug prevented getting down to or moving up the hierarchy if the child or parent were in draft status.
    5762
    5863= 1.5.1 =
Note: See TracChangeset for help on using the changeset viewer.