Ultimate Posts Widget - Version 2.0.2

Version Description

  • Reverts back to using widget_title filter
  • Fixes number of posts setting to allow unlimited amounts
  • Adds instance and widget ID variables to filters for more control
Download this release

Release Info

Developer bostondv
Plugin Icon wp plugin Ultimate Posts Widget
Version 2.0.2
Comparing to
See all releases

Code changes from version 2.0.1 to 2.0.2

Files changed (3) hide show
  1. package.json +1 -1
  2. readme.txt +6 -5
  3. ultimate-posts-widget.php +19 -17
package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "bostondv/ultimate-posts-widget",
3
- "version": "2.0.0",
4
  "contributors": [
5
  "Boston Dell-Vandenberg <boston@pomelodesign.com>"
6
  ],
1
  {
2
  "name": "bostondv/ultimate-posts-widget",
3
+ "version": "2.0.2",
4
  "contributors": [
5
  "Boston Dell-Vandenberg <boston@pomelodesign.com>"
6
  ],
readme.txt CHANGED
@@ -6,7 +6,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
6
  Tags: widget, recent posts, custom post types, sticky posts, featured image, post thumbnail, excerpts, category, custom fields, list pages, widget query, microformats, customizable widget, categories widget, tags widget, excerpt, widget templates, post author, post date, custom query, ultimate posts, comments, orderby, comment count
7
  Requires at least: 3.6
8
  Tested up to: 4.0
9
- Stable tag: 2.0.1
10
 
11
  The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
12
 
@@ -65,10 +65,6 @@ Did you enjoy this plugin? Please [donate to support ongoing development](http:/
65
 
66
  Allows changing whether to load the template CSS file(s).
67
 
68
- **upw_widget_title** *(string)*
69
-
70
- Allows changing the widget title.
71
-
72
  **upw_wp_query_args** *(array)*
73
 
74
  Allows changing the WP_Query arguments for the widget.
@@ -119,6 +115,11 @@ This plugin uses the [timthumb library](http://www.binarymoon.co.uk/projects/tim
119
 
120
  == Changelog ==
121
 
 
 
 
 
 
122
  = 2.0.1 =
123
  * Fixes issue loading multiple widgets on the same page and using the same template
124
  * Adds a default title to the widget for new instances
6
  Tags: widget, recent posts, custom post types, sticky posts, featured image, post thumbnail, excerpts, category, custom fields, list pages, widget query, microformats, customizable widget, categories widget, tags widget, excerpt, widget templates, post author, post date, custom query, ultimate posts, comments, orderby, comment count
7
  Requires at least: 3.6
8
  Tested up to: 4.0
9
+ Stable tag: 2.0.2
10
 
11
  The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
12
 
65
 
66
  Allows changing whether to load the template CSS file(s).
67
 
 
 
 
 
68
  **upw_wp_query_args** *(array)*
69
 
70
  Allows changing the WP_Query arguments for the widget.
115
 
116
  == Changelog ==
117
 
118
+ = 2.0.2 =
119
+ * Reverts back to using `widget_title` filter
120
+ * Fixes number of posts setting to allow unlimited amounts
121
+ * Adds instance and widget ID variables to filters for more control
122
+
123
  = 2.0.1 =
124
  * Fixes issue loading multiple widgets on the same page and using the same template
125
  * Adds a default title to the widget for new instances
ultimate-posts-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ultimate Posts Widget
4
  Plugin URI: http://wordpress.org/plugins/ultimate-posts-widget/
5
  Description: The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
6
- Version: 2.0.1
7
  Author: Boston Dell-Vandenberg
8
  Author URI: http://pomelodesign.com
9
  Text Domain: upw
@@ -95,13 +95,13 @@ if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
95
  ob_start();
96
  extract( $args );
97
 
98
- $title = apply_filters( 'upw_widget_title', $instance['title'] );
99
  $title_link = $instance['title_link'];
100
  $class = $instance['class'];
101
- $number = $instance['number'];
102
- $types = ($instance['types'] ? explode(',', $instance['types']) : '');
103
- $cats = ($instance['cats'] ? explode(',', $instance['cats']) : '');
104
- $tags = ($instance['tags'] ? explode(',', $instance['tags']) : '');
105
  $atcat = $instance['atcat'] ? true : false;
106
  $thumb_size = $instance['thumb_size'];
107
  $attag = $instance['attag'] ? true : false;
@@ -133,7 +133,7 @@ if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
133
  foreach (get_the_category() as $catt) {
134
  $cats .= $catt->term_id.' ';
135
  }
136
- $cats = str_replace(" ", ",", trim($cats));
137
  }
138
 
139
  // If $attag true and in tag
@@ -147,7 +147,7 @@ if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
147
  foreach (get_the_tags() as $tagg) {
148
  $tags .= $tagg->term_id.' ';
149
  }
150
- $tags = str_replace(" ", ",", trim($tags));
151
  }
152
 
153
  // Excerpt more filter
@@ -156,22 +156,24 @@ if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
156
 
157
  // Excerpt length filter
158
  $new_excerpt_length = create_function('$length', "return " . $excerpt_length . ";");
159
- if ( $instance["excerpt_length"] > 0 ) add_filter('excerpt_length', $new_excerpt_length);
160
- if( $class )
161
- {
162
  $before_widget = str_replace('class="', 'class="'. $class . ' ', $before_widget);
163
  }
 
164
  echo $before_widget;
 
165
  if ( $title ) {
166
  echo $before_title;
167
  if ( $title_link ) echo "<a href='$title_link'>";
168
  echo $title;
169
- if ( $title_link ) echo "</a>";
170
  echo $after_title;
171
  }
172
 
173
  $args = array(
174
- 'showposts' => $number,
175
  'order' => $order,
176
  'orderby' => $orderby,
177
  'category__in' => $cats,
@@ -187,12 +189,12 @@ if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
187
  $args[key($sticky_query)] = reset($sticky_query);
188
  }
189
 
190
- $args = apply_filters('upw_wp_query_args', $args);
191
 
192
  $upw_query = new WP_Query($args);
193
 
194
  if ($instance['template'] === 'custom') {
195
- $custom_template_path = apply_filters('upw_custom_template_path', '/upw/' . $instance['template_custom'] . '.php');
196
  if (locate_template($custom_template_path)) {
197
  include get_stylesheet_directory() . $custom_template_path;
198
  } else {
@@ -443,7 +445,7 @@ if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
443
 
444
  <p>
445
  <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts', 'upw' ); ?>:</label>
446
- <input class="widefat" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" value="<?php echo $number; ?>" min="1" max="20" />
447
  </p>
448
 
449
  <p>
@@ -478,7 +480,7 @@ if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
478
 
479
  <p<?php if (!$show_excerpt) echo ' style="display:none;"'; ?>>
480
  <label for="<?php echo $this->get_field_id('excerpt_length'); ?>"><?php _e( 'Excerpt length (in words)', 'upw' ); ?>:</label>
481
- <input class="widefat" type="number" id="<?php echo $this->get_field_id('excerpt_length'); ?>" name="<?php echo $this->get_field_name('excerpt_length'); ?>" value="<?php echo $excerpt_length; ?>" min="1" max="100" />
482
  </p>
483
 
484
  <p>
3
  Plugin Name: Ultimate Posts Widget
4
  Plugin URI: http://wordpress.org/plugins/ultimate-posts-widget/
5
  Description: The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
6
+ Version: 2.0.2
7
  Author: Boston Dell-Vandenberg
8
  Author URI: http://pomelodesign.com
9
  Text Domain: upw
95
  ob_start();
96
  extract( $args );
97
 
98
+ $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
99
  $title_link = $instance['title_link'];
100
  $class = $instance['class'];
101
+ $number = empty($instance['number']) ? -1 : $instance['number'];
102
+ $types = empty($instance['types']) ? '' : explode(',', $instance['types']);
103
+ $cats = empty($instance['cats']) ? '' : explode(',', $instance['cats']);
104
+ $tags = empty($instance['tags']) ? '' : explode(',', $instance['tags']);
105
  $atcat = $instance['atcat'] ? true : false;
106
  $thumb_size = $instance['thumb_size'];
107
  $attag = $instance['attag'] ? true : false;
133
  foreach (get_the_category() as $catt) {
134
  $cats .= $catt->term_id.' ';
135
  }
136
+ $cats = str_replace(' ', ',', trim($cats));
137
  }
138
 
139
  // If $attag true and in tag
147
  foreach (get_the_tags() as $tagg) {
148
  $tags .= $tagg->term_id.' ';
149
  }
150
+ $tags = str_replace(' ', ',', trim($tags));
151
  }
152
 
153
  // Excerpt more filter
156
 
157
  // Excerpt length filter
158
  $new_excerpt_length = create_function('$length', "return " . $excerpt_length . ";");
159
+ if ( $instance['excerpt_length'] > 0 ) add_filter('excerpt_length', $new_excerpt_length);
160
+
161
+ if( $class ) {
162
  $before_widget = str_replace('class="', 'class="'. $class . ' ', $before_widget);
163
  }
164
+
165
  echo $before_widget;
166
+
167
  if ( $title ) {
168
  echo $before_title;
169
  if ( $title_link ) echo "<a href='$title_link'>";
170
  echo $title;
171
+ if ( $title_link ) echo '</a>';
172
  echo $after_title;
173
  }
174
 
175
  $args = array(
176
+ 'posts_per_page' => $number,
177
  'order' => $order,
178
  'orderby' => $orderby,
179
  'category__in' => $cats,
189
  $args[key($sticky_query)] = reset($sticky_query);
190
  }
191
 
192
+ $args = apply_filters('upw_wp_query_args', $args, $instance, $this->id_base);
193
 
194
  $upw_query = new WP_Query($args);
195
 
196
  if ($instance['template'] === 'custom') {
197
+ $custom_template_path = apply_filters('upw_custom_template_path', '/upw/' . $instance['template_custom'] . '.php', $instance, $this->id_base);
198
  if (locate_template($custom_template_path)) {
199
  include get_stylesheet_directory() . $custom_template_path;
200
  } else {
445
 
446
  <p>
447
  <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts', 'upw' ); ?>:</label>
448
+ <input class="widefat" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" value="<?php echo $number; ?>" min="-1" />
449
  </p>
450
 
451
  <p>
480
 
481
  <p<?php if (!$show_excerpt) echo ' style="display:none;"'; ?>>
482
  <label for="<?php echo $this->get_field_id('excerpt_length'); ?>"><?php _e( 'Excerpt length (in words)', 'upw' ); ?>:</label>
483
+ <input class="widefat" type="number" id="<?php echo $this->get_field_id('excerpt_length'); ?>" name="<?php echo $this->get_field_name('excerpt_length'); ?>" value="<?php echo $excerpt_length; ?>" min="-1" />
484
  </p>
485
 
486
  <p>