-
Erick Hitter authoredErick Hitter authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
date-based-taxonomy-archives.php 10.16 KiB
<?php
/*
Plugin Name: Date-based Taxonomy Archives
Plugin URI: http://www.ethitter.com/plugins/date-based-taxonomy-archives/
Description: Add support for date-based taxonomy archives. Render an unordered list of years with months, linked to corresponding date-based taxonomy archive, nested therein.
Author: Erick Hitter
Version: 0.2
Author URI: http://www.ethitter.com/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Date_Based_Taxonomy_Archives {
/**
* Class variables
*/
var $defaults = array(
'taxonomies' => false,
'show_post_count' => false,
'limit' => '',
'before' => '',
'after' => '',
'echo' => true
);
var $cache_key_incrementor = 'incrementor';
var $cache_group = 'date_based_taxonomy_archives';
var $filter_archive_links = false;
/**
* Register actions and filters
*
* @uses add_action, add_filter
* @return null
*/
function __construct() {
add_filter( 'date_based_taxonomy_archives_where', array( $this, 'filter_date_based_taxonomy_archives_where' ), 10, 2 );
add_filter( 'date_based_taxonomy_archives_join', array( $this, 'filter_date_based_taxonomy_archives_join' ), 10, 2 );
add_filter( 'get_archives_link', array( $this, 'filter_get_archives_link' ) );
add_action( 'generate_rewrite_rules', array( $this, 'action_generate_rewrite_rules' ) );
add_action( 'transition_post_status', array( $this, 'action_transition_post_status' ), 50, 2 );
}
/**
* Render unordered lists of monthly archive links grouped by year
*
* @param array $args
* @uses $wpdb, $wp_locale, apply_filters, wp_parse_args, absint, this::get_incrementor, wp_cache_get, wp_cache_set, get_month_link, get_archives_link
* @return string or false
*/
function get_archives( $args = array() ) {
global $wpdb, $wp_locale;
$args = apply_filters( 'date_based_taxonomy_archives_args', $args );
$args = wp_parse_args( $args, $this->defaults );