WordPress.org

Plugin Directory

Changeset 782432


Ignore:
Timestamp:
10/04/13 07:18:40 (7 months ago)
Author:
greenshady
Message:

Updating plugin to version 0.2.0.

Location:
clean-my-archives
Files:
10 added
3 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • clean-my-archives/trunk/clean-my-archives.php

    r292010 r782432  
    22/** 
    33 * Plugin Name: Clean My Archives 
    4  * Plugin URI: http://devpress.com/plugins/clean-my-archives 
     4 * Plugin URI: http://themehybrid.com/plugins/clean-my-archives 
    55 * Description: A plugin that displays a full archive of posts by month and year with the <code>[clean-my-archives]</code> shortcode. 
    6  * Version: 0.1 
    7  * Author: DevPress 
    8  * Author URI: http://devpress.com 
     6 * Version: 0.2.0 
     7 * Author: Justin Tadlock 
     8 * Author URI: http://justintadlock.com 
    99 * 
    10  * Clean My Archives is a plugin developed to simplify the process of adding a list of archives to your site.  So  
    11  * many archives plugins make things overly complex or add a lot of junk to the page like unneeded JavaScript.  
    12  * This plugin was created to clean your archives page. 
     10 * Clean My Archives is a plugin developed to simplify the process of adding a list of archives to your  
     11 * site.  So many archives plugins make things overly complex or add a lot of junk to the page like unneeded  
     12 * JavaScript.  This plugin was created to clean your archives page. 
    1313 * 
    14  * @copyright 2008 - 2010 
    15  * @version 0.1 
    16  * @author Justin Tadlock 
    17  * @link http://devpress.com/plugins/clean-my-archives 
    18  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
     14 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU  
     15 * General Public License as published by the Free Software Foundation; either version 2 of the License,  
     16 * or (at your option) any later version. 
    1917 * 
    20  * This program is distributed in the hope that it will be useful, 
    21  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
     18 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  
     19 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
    2320 * 
    24  * @package CleanMyArchives 
     21 * You should have received a copy of the GNU General Public License along with this program; if not, write  
     22 * to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 
     23 * 
     24 * @package   CleanMyArchives 
     25 * @version   0.2.0 
     26 * @since     0.1.0 
     27 * @author    Justin Tadlock <justin@justintadlock.com> 
     28 * @copyright Copyright (c) 2008 - 2013, Justin Tadlock 
     29 * @link      http://themehybrid.com/plugins/clean-my-archives 
     30 * @license   http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
    2531 */ 
    2632 
     
    3137 * Sets up the plugin and calls its default actions. 
    3238 * 
    33  * @since 0.1 
     39 * @since  0.1.0 
     40 * @access public 
     41 * @return void 
    3442 */ 
    3543function clean_my_archives_setup() { 
     
    4957 * Registers shortcodes for the plugin. 
    5058 * 
    51  * @since 0.1 
     59 * @since  0.1.0 
     60 * @access public 
     61 * @return void 
    5262 */ 
    5363function clean_my_archives_shortcodes() { 
     
    6070 * Returns a formated archive of all posts for the blog. 
    6171 * 
    62  * @since 0.1 
    63  * @param array $attr The shortcode attributes. 
    64  * @return string $clean Formatted archives. 
     72 * @since  0.1.0 
     73 * @access public 
     74 * @param  array   $attr   The shortcode attributes. 
     75 * @return string  $clean  Formatted archives. 
    6576 */ 
    6677function clean_my_archives( $attr = array() ) { 
    6778 
    6879    /* Set up some default variables that need to be empty. */ 
    69     $clean = ''; 
    70     $current_year = ''; 
     80    $clean         = ''; 
     81    $current_year  = ''; 
    7182    $current_month = ''; 
    72     $cache = array(); 
     83    $current_day   = ''; 
     84    $cache         = array(); 
    7385 
    7486    /* Default arguments. */ 
    7587    $defaults = array( 
    76         'limit' => -1, 
    77         'year' => '', 
    78         'month' => '', 
     88        'limit'     => -1, 
     89        'year'      => '', 
     90        'month'     => '', 
     91        'post_type' => 'post' 
    7992    ); 
     93 
    8094    $attr = shortcode_atts( $defaults, $attr ); 
    8195 
    8296    /* Set up some arguments to pass to WP_Query. */ 
    8397    $args = array( 
    84         'posts_per_page' => $attr['limit'], 
    85         'year' => $attr['year'], 
    86         'monthnum' => $attr['month'], 
    87         'post_type' => array( 'post' ), 
    88         'caller_get_posts' => true, // Disable sticky posts. 
     98        'posts_per_page'      => $attr['limit'], 
     99        'year'                => $attr['year'], 
     100        'monthnum'            => $attr['month'], 
     101        'post_type'           => is_array( $attr['post_type'] ) ? $attr['post_type'] : explode( ',', $attr['post_type'] ), 
     102        'ignore_sticky_posts' => true, 
    89103    ); 
    90104 
     
    96110 
    97111    /* If there is a cached archive, return it instead of doing all the work we've already done. */ 
    98     if ( is_array( $cache ) && !empty( $cache[$key] ) ) 
    99         return $cache[$key]; 
     112    if ( is_array( $cache ) && !empty( $cache[ $key ] ) ) 
     113        return $cache[ $key ]; 
    100114 
    101115    /* Query posts from the database. */ 
     
    112126 
    113127            /* Get the post's year and month. We need this to compare it with the previous post date. */ 
    114             $year = get_the_time( 'Y' ); 
    115             $month = get_the_time( 'm' ); 
     128            $year   = get_the_time( 'Y' ); 
     129            $month  = get_the_time( 'm' ); 
     130            $daynum = get_the_time( 'd' ); 
    116131 
    117132            /* If the current date doesn't match this post's date, we need extra formatting. */ 
     
    123138 
    124139                /* Set the current year and month to this post's year and month. */ 
    125                 $current_year = $year; 
     140                $current_year  = $year; 
    126141                $current_month = $month; 
     142                $current_day   = ''; 
    127143 
    128144                /* Add a heading with the month and year and link it to the monthly archive. */ 
    129                 $clean .= '<h2><a href="' . get_month_link( $current_year, $current_month ) . '">' . get_the_time( __( 'F Y', 'clean-my-archives' ) ) . '</a></h2>'; 
     145                $clean .= '<h2 class="month-year"><a href="' . get_month_link( $current_year, $current_month ) . '">' . get_the_time( __( 'F Y', 'clean-my-archives' ) ) . '</a></h2>'; 
    130146 
    131147                /* Open a new unordered list. */ 
     
    134150 
    135151            /* Get the post's day. */ 
    136             $day = get_the_time( __( 'd:', 'clean-my-archives' ) ); 
     152            $day = sprintf( '<span class="day">%s</span>', get_the_time( __( 'd:', 'clean-my-archives' ) ) ); 
    137153 
    138154            /* Get the post's number of comments. */ 
    139             $comments = sprintf( _x( '(%s)', 'Comments number beside post title.', 'clean-my-archives' ), get_comments_number() ); 
     155            $comments_num = sprintf( _x( '(%d)', 'Comments number', 'clean-my-archives' ), get_comments_number() ); 
     156            $comments     = sprintf( '<span class="comments-number">%s</span>',  $comments_num ); 
     157 
     158            /* Check if there's a duplicate day so we can add a class. */ 
     159            $duplicate_day = !empty( $current_day ) && $daynum === $current_day ? ' class="day-duplicate"' : ''; 
     160            $current_day   = $daynum; 
    140161 
    141162            /* Add the post list item to the formatted archives. */ 
    142             $clean .= the_title( '<li>' . $day . ' <a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a> ' . $comments . '</li>', false ); 
     163            $clean .= the_title( '<li' . $duplicate_day . '>' . $day . ' <a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a> ' . $comments . '</li>', false ); 
    143164        } 
    144165 
     
    148169 
    149170    /* Reset the query to the page's original query. */ 
    150     wp_reset_query(); 
     171    wp_reset_postdata(); 
    151172 
    152173    /* Make sure $cache is an array. */ 
     
    155176 
    156177    /* Set the cache for the plugin, so caching plugins can make this super fast. */ 
    157     $cache[$key] = $clean; 
     178    $cache[ $key ] = $clean; 
    158179    wp_cache_set( 'clean_my_archives', $cache ); 
    159180 
    160181    /* Return the formatted archives. */ 
    161     return $clean; 
     182    return !empty( $clean ) ? "<div class='clean-my-archives'>{$clean}</div>" : ''; 
    162183} 
    163184 
     
    165186 * Deletes the archive cache for users that are using a persistent-caching plugin. 
    166187 * 
    167  * @since 0.2 
     188 * @since  0.1.0 
     189 * @access public 
     190 * @return void 
    168191 */ 
    169192function clean_my_archives_delete_cache() { 
  • clean-my-archives/trunk/languages/clean-my-archives.pot

    r292010 r782432  
    11msgid "" 
    22msgstr "" 
    3 "Project-Id-Version: Query Posts Widget Plugin\n" 
     3"Project-Id-Version: Clean My Archives Plugin\n" 
    44"Report-Msgid-Bugs-To: \n" 
    5 "POT-Creation-Date: 2010-09-21 05:25-0600\n" 
     5"POT-Creation-Date: 2013-10-04 02:03-0600\n" 
    66"PO-Revision-Date: \n" 
    7 "Last-Translator: Justin Tadlock <justin@justintadlock.com>\n" 
     7"Last-Translator: \n" 
    88"Language-Team:  <justin@justintadlock.com>\n" 
     9"Language: en_US\n" 
    910"MIME-Version: 1.0\n" 
    1011"Content-Type: text/plain; charset=UTF-8\n" 
    1112"Content-Transfer-Encoding: 8bit\n" 
    12 "X-Poedit-Language: English\n" 
    13 "X-Poedit-Country: UNITED STATES\n" 
    14 "X-Poedit-KeywordsList: _e;__;esc_attr__;esc_attr_e;esc_html__;esc_html_e;_x;_ex\n" 
     13"X-Poedit-KeywordsList: _e;__;esc_attr__;esc_attr_e;esc_html__;esc_html_e;_x;" 
     14"_x:1,2c;_n:1,2;_n\n" 
    1515"X-Poedit-Basepath: ../\n" 
     16"X-Generator: Poedit 1.5.7\n" 
    1617"X-Poedit-SearchPath-0: .\n" 
    1718 
    18 #: clean-my-archives.php:129 
     19#: clean-my-archives.php:145 
    1920msgid "F Y" 
    2021msgstr "" 
    2122 
    22 #: clean-my-archives.php:136 
     23#: clean-my-archives.php:152 
    2324msgid "d:" 
    2425msgstr "" 
    2526 
    26 #: clean-my-archives.php:139 
     27#: clean-my-archives.php:155 
    2728#, php-format 
    28 msgid "(%s)" 
     29msgid "(%d)" 
    2930msgstr "" 
    30  
  • clean-my-archives/trunk/readme.txt

    r292022 r782432  
    11=== Clean My Archives === 
    2 Contributors: greenshady, ptahdunbar, developdaly, devpress 
    3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3687060 
     2 
     3Contributors: greenshady 
     4Donate link: http://themehybrid.com/donate 
    45Tags: archives, shortcode 
    5 Requires at least: 3.0 
    6 Tested up to: 3.0.1 
    7 Stable tag: 0.1 
     6Requires at least: 3.1 
     7Tested up to: 3.7 
     8Stable tag: 0.2.0 
     9License: GPLv2 or later 
     10License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    811 
    912An easy-to-use shortcode for displaying post archives on your site. 
     
    1114== Description == 
    1215 
    13 The Clean My Archives plugin was developed because so many archives plugins were overly complicated.  We wanted something extremely simple to use that simply got the job done.  Rather than make things complex, we created a simple `[clean-my-archives]` shortcode that you can place in any page (any shortcode-ready area) and list your post archives by month and year. 
     16The Clean My Archives plugin was developed because so many archives plugins were overly complicated.  I wanted something extremely simple to use that simply got the job done on my own [site's archives](http://justintadlock.com/archives). 
    1417 
    15 This plugin also integrates with WordPress caching plugins.  So, long lists of archives can be cached for later use and loaded quickly. 
     18Therefore, I created a simple `[clean-my-archives]` shortcode that you can place on any page (or any shortcode-ready area) and list your post archives by month and year. 
     19 
     20This plugin also integrates with WordPress caching plugins.  So, long lists of archives can be cached for later use and loaded quickly.  If you have many years of blog posts, I highly recommend some sort of persistent caching or paginating your archives (see FAQ). 
     21 
     22### Professional Support 
     23 
     24If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](http://themehybrid.com/support), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 40,000+ users (and growing). 
     25 
     26### Plugin Development 
     27 
     28If you're a theme author, plugin author, or just a code hobbyist, you can follow the development of this plugin on it's [GitHub repository](https://github.com/justintadlock/clean-my-archives).  
     29 
     30### Donations 
     31 
     32Yes, I do accept donations.  If you want to buy me a beer or whatever, you can do so from my [donations page](http://themehybrid.com/donate).  I appreciate all donations, no matter the size.  Further development of this plugin is not contingent on donations, but they are always a nice incentive. 
    1633 
    1734== Installation == 
    1835 
    19 1. Upload `clean-my-archives` to the `/wp-content/plugins/` directory. 
    20 1. Activate the plugin through the 'Plugins' menu in WordPress. 
    21  
    22 More detailed instructions are included in the plugin's `readme.html` file. 
     361. Uzip the `clean-my-archives.zip` folder. 
     372. Upload the `clean-my-archives` folder to your `/wp-content/plugins` directory. 
     383. In your WordPress dashboard, head over to the *Plugins* section. 
     394. Activate *Clean My Archives*. 
    2340 
    2441== Frequently Asked Questions == 
    2542 
    26 = Why was this plugin created? = 
     43### Why was this plugin created? 
    2744 
    28 To provide a simple archives solution for end users. 
     45First and foremost, I wanted a simple archives solution for, what's now, over 10 years of blog posts.  You can check out [my archives](http://justintadlock.com/archives) to see how the plugin performs. 
    2946 
    30 = How do I use it? = 
     47The second reason was to share my solution with other users who want the same simplicity. 
    3148 
    32 Add the `[clean-my-archives]` shortcode to a shortcode-ready area, such as the page editor.  More detailed instructions and examples are in the plugins' `readme.html` file. 
     49### How do I use it? 
     50 
     51Add the `[clean-my-archives]` shortcode to a shortcode-ready area, such as the page editor. That's it.  You have nothing more to do. 
     52 
     53Of course, there are some other configuration options. Examples follow. 
     54 
     55#### Limit the number of posts with the `limit` parameter: 
     56 
     57    [clean-my-archives limit="100"] 
     58 
     59#### Use the `year` parameter to limit to a year: 
     60 
     61    [clean-my-archives year="2013"] 
     62 
     63#### Use the `month` parameter to limit by month: 
     64 
     65    [clean-my-archives month="12"] 
     66 
     67#### Load specific post types with the `post_type` parameter 
     68 
     69    [clean-my-archives post_type="post"] 
     70 
     71    [clean-my-archives post_type="post, page"] 
     72 
     73### Does it support pagination? 
     74 
     75Sort of.  Technically, it doesn't.  However, WordPress pages support pagination.  So, you could enter the following in your page editor to paginate by year. 
     76 
     77    [clean-my-archives year="2013"] 
     78 
     79    <!-- nextpage --> 
     80 
     81    [clean-my-archives year="2012"] 
     82 
     83    <!-- nextpage --> 
     84 
     85    [clean-my-archives year="2011"] 
     86 
     87== Screenshots == 
     88 
     89You can see a [live demo here](http://justintadlock.com). 
     90 
     911. Screenshot of the plugin in action my archives page. 
    3392 
    3493== Changelog == 
    3594 
    36 **Version 0.1** 
     95### Version 0.2.0 
     96 
     97* Use `wp_reset_postdata()`, not `wp_reset_query()`. 
     98* Smarter code formatting for day and comments number. 
     99* Add support for custom post types or a mix of any post type. 
     100* Code formatting and inline doc cleanup. 
     101* Use the newer `ignore_sticky_posts` instead of `caller_get_posts`. 
     102* Add `<span>` wrappers for styling the day and comments number. 
     103* Add `.day-duplicate` class to `<li>` if it's a repeating day. 
     104* Add `<div class="clean-my-archives">` wrapper for entire output. 
     105 
     106### Version 0.1.0 
    37107 
    38108* Plugin launch.  Everything's new! 
Note: See TracChangeset for help on using the changeset viewer.