Plugin Directory

Changeset 1272199


Ignore:
Timestamp:
10/24/2015 11:41:13 AM (10 years ago)
Author:
cip
Message:

v2.0.0: automatically show the enhanced content using category_description or get_the_archive_description filters

Location:
enhanced-category-pages/trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • enhanced-category-pages/trunk/classes/ecp/WP_Integration.php

    r1101510 r1272199  
    7878        //customize admin area
    7979        add_action("admin_init", array(&$this, 'admin_init'), 10000);
     80
     81        add_filter( 'category_description', array(&$this, 'category_description_filter') );
     82        add_filter( 'get_the_archive_description', array(&$this, 'category_description_filter') );
     83    }
     84
     85    public function category_description_filter($description, $categoryId) {
     86
     87        ob_start();
     88
     89        include pathinfo($this->_plugin_file_path, PATHINFO_DIRNAME)."/views/ecp_category_description.php";
     90
     91        $description = ob_get_clean();
     92
     93        return $description;
    8094    }
    8195
  • enhanced-category-pages/trunk/readme.txt

    r1179826 r1272199  
    55Requires at least: 3.0.1
    66Tested up to: 4.2.2
    7 Stable tag: 1.0.2
     7Stable tag: 2.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1313== Description ==
    1414
     15**NEW** Version 2.0.0 brings great new feature: with some magic, if your theme displays category/term description, then it would be **automatically** enhanced.
     16Are you ready for more? You can customize the template by creating a `content-ecp.php` file in your theme of choice.
     17
     18
    1519Enhanced Category Pages allows you to create custom category and term pages by managing them using a special custom post type.
    1620
    1721**Features**
    1822
    19 * **NEW** Traverse categories using setup_ec_data that allows now category id as parameter
     23* **NEW** Easy to use for everyone: users, designers, developers
     24* **NEW** automatically show enhanced category/term content
     25* **NEW** customize enhanced category/term content by creating a `content-ecp.php` file in your theme of choice
     26* Traverse categories using setup_ec_data that allows now category id as parameter
    2027* Enhance any taxonomy: edit **any taxonomy** term as a custom post
    21 * edit category as a custom post - *Enhanced Category*
    22 * automatically generates *Enhanced Category* post type for each category
    23 * transparent synchronization of *Enhanced Category* and it's corresponding category
    24 * add any features available to WordPress custom posts
    25 * easy *Enhanced Category* display on category template using `<?php $GLOBALS['enhanced_category']->setup_ec_data(); ?>` (see install section)
    26 * internationalization ready
     28* Edit category as a custom post - *Enhanced Category*
     29* Automatically generates *Enhanced Category* post type for each category
     30* Transparent synchronization of *Enhanced Category* and it's corresponding category
     31* Add any features available to WordPress custom posts
     32* Easy *Enhanced Category* display on category template using `<?php $GLOBALS['enhanced_category']->setup_ec_data(); ?>` (see install section)
     33* Internationalization ready
    2734
    2835**Future Features**
     
    37443. Activate the plugin through the "Plugins" menu in WordPress.
    38454. Use "Enhanced Edit" link to edit the page of the respective category
     465. Category/term description display is automatically enhanced with your content.
     476. Optional: create `content-ecp.php` in your theme folder to customize the display.
    3948
    40 **Usage options**
     49**Advanced usage options**
    4150
    42 1. Display category/term page. Edit **category/taxonomy template** to show the content of the "Enhanced Category":
    43    
    44        
    45    
    46         //in category.php or taxonomy.php
    47         <?php
    48             global $enhanced_category;
    49             //get enhanced category post and set it up as global current post
    50             $enhanced_category->setup_ec_data();
    51         ?>
    52         <!-- enhanced category content -->
    53         <?php the_post_thumbnail("medium"); ?>
    54    
    55         <?php get_template_part( 'content', 'page' ); ?>
    56    
    57         <!-- custom fields -->
    58         <?php
    59             get_post_custom();
    60         ?>
    61    
    62         <?php
    63             // If comments are open or we have at least one comment, load up the comment template
    64             if ( comments_open() || get_comments_number() ) :
    65                 comments_template();
    66             endif;
    67         ?>
    68    
     511. Create `content-ecp.php` in your theme folder to customize the display of the enhanced content. The custom post associated with category/term is set up, so all display functions for posts are usable.
     52
     531. Display category/term page. Edit **category/taxonomy template** to show the content of the "Enhanced Category" (feel free to adjust to your needs):
     54   
     55   
     56        //in category.php or taxonomy.php or any other place your theme displays the category/term content
     57        <?php
     58            global $enhanced_category;
     59            //get enhanced category post and set it up as global current post
     60            $enhanced_category->setup_ec_data();
     61        ?>
     62        <!-- enhanced category content -->
     63        <?php the_post_thumbnail("medium"); ?>
     64   
     65        <?php get_template_part( 'content', 'page' ); ?>
     66   
     67        <!-- custom fields -->
     68        <?php
     69            get_post_custom();
     70        ?>
     71   
     72        <?php
     73            // If comments are open or we have at least one comment, load up the comment template
     74            if ( comments_open() || get_comments_number() ) :
     75                comments_template();
     76            endif;
     77        ?>
     78   
    69791. Display a list of categories:
    7080
    71    
    72         //$categories is presumed to be an already fetched array of categories/terms
    73         foreach($categories as $category) {
    74             $GLOBALS['enhanced_category']->setup_ec_data($category->term_id);
    75             the_post_thumbnail('thumbnail');
    76         }
    77    
     81   
     82        //$categories is presumed to be an already fetched array of categories/terms
     83        foreach($categories as $category) {
     84            $GLOBALS['enhanced_category']->setup_ec_data($category->term_id);
     85            the_post_thumbnail('thumbnail');
     86        }
     87   
    7888
    7989== Frequently Asked Questions ==
    8090
     91= How does magic happen? =
     92
     93*We use the `category_description` or `get_the_archive_description` filters in order to replace the plain content with the enhanced one.
     94
     95= How can I customize the output? =
     96
     97* `content-ecp.php` and `content-page.php` partial templates are looked for (in that order) and the first found is loaded.
     98
    8199= What custom post type is created? =
    82100
    83 *Enhanced Category* (safe name: enhancedcategory) custom post type is created and a post is generated automatically for each category.
     101*Enhanced Category* (safe name: enhancedcategory) custom post type is created and a post is generated automatically for each category/term.
    84102
    85103= What happens if I edit the category fields? =
     
    127145* setup_ec_data allows now category id as parameter
    128146
     147= 2.0.0 =
     148* automatically show the enhanced content using `category_description` or `get_the_archive_description` filters
     149* customize the display of content with `content-ecp.php` theme partial template
     150
    129151
    130152== Upgrade Notice ==
     
    141163= 1.0.2 =
    142164* traverse categories using setup_ec_data that allows now category id as parameter
     165
     166= 2.0.0 =
     167* This version adds magic: automatically show the enhanced content using `category_description` or `get_the_archive_description` filters.
     168
Note: See TracChangeset for help on using the changeset viewer.