Plugin Directory

Changeset 350101


Ignore:
Timestamp:
02/23/2011 10:56:17 PM (15 years ago)
Author:
rATRIJS
Message:

Added support for WordPress 3.1. Renamed function 'is_post_type_archive' to 'pta_is_post_type_archive'.

Location:
custom-post-type-archives/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • custom-post-type-archives/trunk/post-type-archives.php

    r307139 r350101  
    55Description: Enables archives (with feeds and paging) for custom post types
    66Author: Rolands Atvars
    7 Version: 1.4
     7Version: 1.5
    88Author URI: http://ratvars.com
    99*/
     
    199199    return $wp_rewrite;
    200200}
    201 add_filter('generate_rewrite_rules', 'pta_register_post_type_rewrite_rules');
     201add_filter('generate_rewrite_rules', 'pta_register_post_type_rewrite_rules', 100);
    202202
    203203/**
     
    213213 */
    214214function pta_register_post_type_redirects($template, $force_post_type = false) {
    215     if(!is_post_type_archive() and $force_post_type === false) return $template;
     215    if(!pta_is_post_type_archive() and $force_post_type === false) return $template;
    216216   
    217217    if(is_404()) // we are in a custom post type archive but there were no posts found for current request
     
    240240 */
    241241function pta_fix_post_type_context() {
    242     if(is_post_type_archive()) {
     242    if(pta_is_post_type_archive()) {
    243243        global $wp_query;
    244244       
     
    263263 */
    264264function pta_fix_wp_title($wp_title, $sep, $seplocation) {
    265     if(is_post_type_archive() and !is_404()) { // do stuff if we are in post type archive that has posts (is not 404)
     265    if(pta_is_post_type_archive() and !is_404()) { // do stuff if we are in post type archive that has posts (is not 404)
    266266        $query_post_type = get_query_var('post_type');
    267267        $title = pta_get_settings('title'); // let's get the title now
     
    308308 */
    309309function pta_fix_body_class($classes) {
    310     if(!is_post_type_archive()) return $classes;
     310    if(!pta_is_post_type_archive()) return $classes;
    311311   
    312312    $archive_classes = array(
     
    327327 */
    328328function pta_add_feed_link() {
    329     if(!is_post_type_archive()) return; // if we are not in post type archive - quit!
     329    if(!pta_is_post_type_archive()) return; // if we are not in post type archive - quit!
    330330   
    331331    // only add the feed link if theme supports auto feed links or user enabled it
     
    359359 * @return bool
    360360 */
    361 function is_post_type_archive($specific_post_type = false) {
     361function pta_is_post_type_archive($specific_post_type = false) {
    362362    static $is_post_type_index;
    363363   
     
    382382   
    383383    return $is_post_type_index;
     384}
     385
     386/**
     387 * Since WP v3.1 WordPress implements it's own is_post_type_archive function so I had to rename it to
     388 * pta_is_post_type_archive.
     389 * To make things backwards compatible (with pre-3.1 releases) we just implement is_post_type_archive function
     390 * and forward it to pta_ist_post_type_archive.
     391 */
     392if(!function_exists('is_post_type_archive')) {
     393    function is_post_type_archive($specific_post_type = false) {
     394        return pta_is_post_type_archive($specific_post_type);
     395    }
    384396}
    385397
  • custom-post-type-archives/trunk/readme.txt

    r307139 r350101  
    44Tags: custom post types, custom post type, post types, post type, archive, archives, rewrite, feeds, paging, post type url, custom post type url, custom post type archive url, post type archive url, custom post type index, post type index
    55Requires at least: 3.0
    6 Tested up to: 3.0.1
    7 Stable tag: 1.4
     6Tested up to: 3.1
     7Stable tag: 1.5
    88
    99Enables custom post type archives that will support both paging and feeds. All fully customizable.
    1010
    1111== Description ==
     12
     13**Since version 3.1 WordPress has it's own implementation of custom post type archives so you can create them without this plugin - visit this page for more info -> http://codex.wordpress.org/Post_Types. Nevertheless I do believe that this plugin is more flexible and you can still use it and it will still work as expected.**
    1214
    1315This plugin will enable custom post type archives (also yearly, monthly and daily) together with feeds, customizable titles and paging.
     
    3133Also a good thing for theme developers - you have four new functions to use:
    3234
    33 *   is_post_type_archive - this function will work similary as is_category or is_single and so on. It will return true if this page is a custom post type archive or false if it isn't. You can also specify an optional argument with post type name and then function will return boolean to say whether you're in post type archive for that post type or not. Simple and useful!
     35*   pta_is_post_type_archive - this function will work similary as is_category or is_single and so on. It will return true if this page is a custom post type archive or false if it isn't. You can also specify an optional argument with post type name and then function will return boolean to say whether you're in post type archive for that post type or not. Simple and useful!
    3436*   get_the_post_type_permalink - this function will return a link to custom post type archive for current post in the WordPress loop. Or you can specify a post type slug or post ID or post object as an argument if you are not in a loop. In this way you can always link to custom post type archives wherever you are.
    3537*   the_post_type_permalink - uses get_the_post_type_permalink to echo the link rather than return it.
     
    163165== Changelog ==
    164166
     167= 1.5 =
     168*   This version should now support WordPress 3.1.
     169*   Function 'is_post_type_archive' is renamed to 'pta_is_post_type_archive', because since v3.1 WordPress implements it's own 'is_post_type_archive' function and WordPress's function won't work correctly with this plugin so you should use 'pta_is_post_type_archive' if you use this plugin. 'is_post_type_archive' function implemented by this plugin will still be available if you have a WordPress install older than v3.1.
     170
    165171= 1.4 =
    166172*   Added support for yearly, monthly and daily archives. Now you can just put year and month and day at the end of the custom post type archive URLs to show only posts from those dates. It works the same way as in other places.
     
    201207== Upgrade Notice ==
    202208
     209= 1.5 =
     210Added support for WordPress 3.1. Renamed function 'is_post_type_archive' to 'pta_is_post_type_archive'. Use this function if you use WP 3.1 or newer.
     211
    203212= 1.4 =
    204213Added support for daily, monthly and yearly archives and added a function like 'wp_get_archives' only for custom post types. Also added body classes.
Note: See TracChangeset for help on using the changeset viewer.