WordPress.org

Plugin Directory

Changeset 518076


Ignore:
Timestamp:
03/12/12 20:43:01 (2 years ago)
Author:
eddiemoya
Message:

bug fixes, changed from template_redirect hook to category_template filter, changes to some conditional tag logic

Location:
category-template-hierarchy/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • category-template-hierarchy/trunk/category-template-hierarchy.php

    r490797 r518076  
    2020     */ 
    2121    function init(){ 
    22         add_action('template_redirect', array( __CLASS__,'category_relationship')); 
     22        add_filter('category_template', array( __CLASS__,'category_relationship')); 
    2323    } 
    2424     
     
    3030    public function category_relationship() { 
    3131        if (is_category()) { 
     32            $parent_category = null; 
     33            $template_prefix = array(); 
    3234 
    3335            if (is_parent_category()) 
     
    3840                $template_prefix[] = "child"; 
    3941 
    40             $template_prefix[] = null; 
    41     
    42             self::category_template_redirect($template_prefix, $parent_category); 
     42            return self::category_template_redirect($template_prefix, $parent_category); 
    4343        } 
    4444    } 
     
    5353    private function category_template_redirect($template_prefix = array(), $parent_category = null) { 
    5454         
     55        $category = get_queried_object(); 
     56         
    5557        $template = "category"; 
    56          
    57         $category = (is_numeric($category)) ? get_the_category_by_ID($category) : $category; 
    58         $category = (is_string($category))  ? get_category_by_slug($category)   : $category; 
    59         $category = (is_null($category))    ? get_queried_object()              : $category; 
    60           
    6158         
    6259        if(in_array('child', $template_prefix)){ 
     
    7673        $templates[] = "index.php";  
    7774         
    78         include( get_query_template($template_name, $templates)); 
    79         exit; 
     75        return apply_filters('cth_category_template', locate_template( $templates )); 
    8076    } 
    8177     
     
    174170    $parent_category = (is_null($parent_category))      ? get_queried_object()                      : $parent_category; 
    175171 
    176     if(empty($child_category) || empty($parent_category) ) 
     172    if(!isset($child_category->parent) || !isset($parent_category->term_id) ) 
    177173        return false; 
    178174     
     
    205201    $child_category = (is_null($child_category))        ? get_queried_object()                      : $child_category; 
    206202 
    207     if(empty($child_category) || empty($parent_category) ) 
     203    if(!isset($child_category->parent) || !isset($parent_category->term_id) ) 
    208204        return false; 
    209205     
  • category-template-hierarchy/trunk/readme.txt

    r490650 r518076  
    33Donate link: http://eddiemoya.com 
    44Tags: plugin, theme development, theme, template, hierarchy, category, template hierarchy, subcategory, parent category, child category, parent category, category template 
    5 Requires at least: unknown 
     5Requires at least: 3.0 
    66Tested up to: 3.3.1 
    77Stable tag: trunk 
     
    218218 
    219219== Upgrade Notice == 
     220= 1.3 = 
     221Multiple Bug Fixes - [Fixed] global scope variables not being available in scope, and fixed bug where plugin was interfering with other non-category parts of the native Template Hierarchy. See changelog for details. 
     222 
    220223= 1.2 = 
    221224Performance: Minor changes for `is_child_of_category_()` and `is_parent_of_category()`, no behavior change for either 
     
    240243 
    241244== Changelog == 
     245 
     246= 1.3 = 
     247* Bug: [FIXED] Template Hierarchy manipulation was interfering with other parts of the native Template Hierarchy, now uses 'category_template' filter instead of 'template_redirect'. 
     248* Bug: [FIXED] Child and Parent categories were not pulling $post and other normal globals into scope during the loop. 
     249* Minor Logic Change: `is_child_of_category()` and `is_parent_of_category` now check specifically for `$category_parent->parent` and `$parent_category->term_id`, because the way it was before, honestly did not make much sense.  
    242250 
    243251= 1.2 = 
Note: See TracChangeset for help on using the changeset viewer.