Plugin Directory

Changeset 1906723


Ignore:
Timestamp:
07/10/2018 12:21:22 AM (8 years ago)
Author:
petroffm
Message:

Update for version 1.2.

Location:
collapsed-archives/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • collapsed-archives/trunk/collapsed-archives.php

    r1085312 r1906723  
    44Plugin URI: https://github.com/mpetroff/collapsed-archives-wp
    55Description: Adds a widget to display archive links using purely CSS-based collapsing.
    6 Version: 1.1
     6Version: 1.2
    77Author: Matthew Petroff
    8 Author URI: http://mpetroff.net/
     8Author URI: https://mpetroff.net/
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1919 *     @type bool       $show_post_count Whether to display the post count alongside the link. Default false.
    2020 *     @type bool       $use_triangles   Whether to use triangles to indicate expansion instead of +/-. Default false.
     21 *     @type bool       $never_expand    Whether to never expand for date (normally expands for current post). Default false.
    2122 *     @type string     $order           Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
    2223 *                                       Default 'DESC'.
     
    2526 */
    2627function collapsed_archives_get_collapsed_archives( $args = '' ) {
    27     global $wpdb, $wp_locale;
     28    global $wpdb, $wp_locale, $wp_query;
    2829
    2930    $defaults = array(
    3031        'show_post_count' => false,
    3132        'use_triangles' => false,
     33        'never_expand' => false,
    3234        'order' => 'DESC',
    3335    );
     
    7678                $output .= '<li>';
    7779                $output .= '<input type="checkbox" id="' . $year_id . '"';
    78                 if ( ( $result->year == get_the_date('Y') && !is_page() ) || ( is_page() && $result->year == date('Y') ) ) {
     80                if ( !$r['never_expand'] && ( ( $result->year == get_the_date('Y', $wp_query->post->ID) && !is_page() ) || ( is_page() && $result->year == date('Y') ) ) ) {
    7981                    $output .= ' checked';
    8082                }
     
    128130        $count = ! empty( $instance['count'] ) ? '1' : '0';
    129131        $use_triangles = ! empty( $instance['use_triangles'] ) ? '1' : '0';
     132        $never_expand = ! empty( $instance['never_expand'] ) ? '1' : '0';
    130133        $order = ! empty( $instance['asc_order'] ) ? 'ASC' : 'DESC';
    131134       
     
    134137            echo $args['before_title'] . $title . $args['after_title'];
    135138        }
    136         echo collapsed_archives_get_collapsed_archives( array( 'show_post_count' => $count, 'use_triangles' => $use_triangles, 'order' => $order ) );
     139        echo collapsed_archives_get_collapsed_archives( array( 'show_post_count' => $count, 'use_triangles' => $use_triangles, 'never_expand' => $never_expand, 'order' => $order ) );
    137140        echo $args['after_widget'];
    138141    }
    139142
    140143    public function form( $instance ) {
    141         $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'use_triangles' => 0, 'asc_order' => 0 ) );
     144        $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'use_triangles' => 0, 'never_expand' => 0, 'asc_order' => 0 ) );
    142145        $title = strip_tags($instance['title']);
    143146        $count = $instance['count'] ? 'checked="checked"' : '';
    144147        $use_triangles = $instance['use_triangles'] ? 'checked="checked"' : '';
     148        $never_expand = $instance['never_expand'] ? 'checked="checked"' : '';
    145149        $asc_order = $instance['asc_order'] ? 'checked="checked"' : '';
    146150        ?>
     
    153157        <input class="checkbox" type="checkbox" <?php echo $use_triangles; ?> id="<?php echo $this->get_field_id('use_triangles'); ?>" name="<?php echo $this->get_field_name('use_triangles'); ?>" /> <label for="<?php echo $this->get_field_id('use_triangles'); ?>"><?php _e('Use triangles to indicate expansion instead of +/-.'); ?></label>
    154158        <br/>
     159        <input class="checkbox" type="checkbox" <?php echo $never_expand; ?> id="<?php echo $this->get_field_id('never_expand'); ?>" name="<?php echo $this->get_field_name('never_expand'); ?>" /> <label for="<?php echo $this->get_field_id('never_expand'); ?>"><?php _e('Don\'t expand list for current post / year.'); ?></label>
     160        <br/>
    155161        <input class="checkbox" type="checkbox" <?php echo $asc_order; ?> id="<?php echo $this->get_field_id('asc_order'); ?>" name="<?php echo $this->get_field_name('asc_order'); ?>" /> <label for="<?php echo $this->get_field_id('asc_order'); ?>"><?php _e('Display archives in chronological order instead of reverse chronological order.'); ?></label>
    156162        </p>
     
    160166    public function update( $new_instance, $old_instance ) {
    161167        $instance = $old_instance;
    162         $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'use_triangles' => 0, 'asc_order' => 0 ) );
     168        $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'use_triangles' => 0, 'never_expand' => 0, 'asc_order' => 0 ) );
    163169        $instance['title'] = strip_tags($new_instance['title']);
    164170        $instance['count'] = $new_instance['count'] ? 1 : 0;
    165171        $instance['use_triangles'] = $new_instance['use_triangles'] ? 1 : 0;
     172        $instance['never_expand'] = $new_instance['never_expand'] ? 1 : 0;
    166173        $instance['asc_order'] = $new_instance['asc_order'] ? 1 : 0;
    167174       
  • collapsed-archives/trunk/readme.txt

    r1277080 r1906723  
    33Tags: archives, collapsed, collapsing, CSS
    44Requires at least: 2.8
    5 Tested up to: 4.3
    6 Stable tag: 1.1
     5Tested up to: 4.9.7
     6Stable tag: 1.2
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1818* Post counts can optionally be displayed next to the archive links
    1919* Choice of either +/- or arrows to indicate expansion
     20* Option to never automatically expand list for current post / year
    2021* Choice between displaying archive links in reverse chronological order or chronological order
     22
     23= 1.2 (2018-07-09) =
     24* Added option for never automatically expanding list for current post / year
     25* Fixed issue with wrong year being expanded
    2126
    2227= 1.1 (2015-02-09) =
     
    5459== Changelog ==
    5560
     61= 1.2 (2018-07-09) =
     62* Added option for never automatically expanding list for current post / year
     63* Fixed issue with wrong year being expanded
     64
    5665= 1.1 (2015-02-09) =
    5766* Improved theme support
Note: See TracChangeset for help on using the changeset viewer.