Changeset 1906723
- Timestamp:
- 07/10/2018 12:21:22 AM (8 years ago)
- Location:
- collapsed-archives/trunk
- Files:
-
- 2 edited
-
collapsed-archives.php (modified) (8 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
collapsed-archives/trunk/collapsed-archives.php
r1085312 r1906723 4 4 Plugin URI: https://github.com/mpetroff/collapsed-archives-wp 5 5 Description: Adds a widget to display archive links using purely CSS-based collapsing. 6 Version: 1. 16 Version: 1.2 7 7 Author: Matthew Petroff 8 Author URI: http ://mpetroff.net/8 Author URI: https://mpetroff.net/ 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 19 19 * @type bool $show_post_count Whether to display the post count alongside the link. Default false. 20 20 * @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. 21 22 * @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'. 22 23 * Default 'DESC'. … … 25 26 */ 26 27 function collapsed_archives_get_collapsed_archives( $args = '' ) { 27 global $wpdb, $wp_locale ;28 global $wpdb, $wp_locale, $wp_query; 28 29 29 30 $defaults = array( 30 31 'show_post_count' => false, 31 32 'use_triangles' => false, 33 'never_expand' => false, 32 34 'order' => 'DESC', 33 35 ); … … 76 78 $output .= '<li>'; 77 79 $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') ) ) ) { 79 81 $output .= ' checked'; 80 82 } … … 128 130 $count = ! empty( $instance['count'] ) ? '1' : '0'; 129 131 $use_triangles = ! empty( $instance['use_triangles'] ) ? '1' : '0'; 132 $never_expand = ! empty( $instance['never_expand'] ) ? '1' : '0'; 130 133 $order = ! empty( $instance['asc_order'] ) ? 'ASC' : 'DESC'; 131 134 … … 134 137 echo $args['before_title'] . $title . $args['after_title']; 135 138 } 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 ) ); 137 140 echo $args['after_widget']; 138 141 } 139 142 140 143 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 ) ); 142 145 $title = strip_tags($instance['title']); 143 146 $count = $instance['count'] ? 'checked="checked"' : ''; 144 147 $use_triangles = $instance['use_triangles'] ? 'checked="checked"' : ''; 148 $never_expand = $instance['never_expand'] ? 'checked="checked"' : ''; 145 149 $asc_order = $instance['asc_order'] ? 'checked="checked"' : ''; 146 150 ?> … … 153 157 <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> 154 158 <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/> 155 161 <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> 156 162 </p> … … 160 166 public function update( $new_instance, $old_instance ) { 161 167 $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 ) ); 163 169 $instance['title'] = strip_tags($new_instance['title']); 164 170 $instance['count'] = $new_instance['count'] ? 1 : 0; 165 171 $instance['use_triangles'] = $new_instance['use_triangles'] ? 1 : 0; 172 $instance['never_expand'] = $new_instance['never_expand'] ? 1 : 0; 166 173 $instance['asc_order'] = $new_instance['asc_order'] ? 1 : 0; 167 174 -
collapsed-archives/trunk/readme.txt
r1277080 r1906723 3 3 Tags: archives, collapsed, collapsing, CSS 4 4 Requires at least: 2.8 5 Tested up to: 4. 36 Stable tag: 1. 15 Tested up to: 4.9.7 6 Stable tag: 1.2 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 18 18 * Post counts can optionally be displayed next to the archive links 19 19 * Choice of either +/- or arrows to indicate expansion 20 * Option to never automatically expand list for current post / year 20 21 * 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 21 26 22 27 = 1.1 (2015-02-09) = … … 54 59 == Changelog == 55 60 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 56 65 = 1.1 (2015-02-09) = 57 66 * Improved theme support
Note: See TracChangeset
for help on using the changeset viewer.