Features by WooThemes - Version 1.4.1

Version Description

  • 2014-01-30
  • New - Filter to set feature links to open in a new window.
  • Fix - Widget image size option.
  • Tweak - Better WPML integration.
Download this release

Release Info

Developer jameskoster
Plugin Icon wp plugin Features by WooThemes
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.4.0 to 1.4.1

classes/class-woothemes-features.php CHANGED
@@ -418,7 +418,7 @@ class Woothemes_Features {
418
  $query_args['numberposts'] = $args['limit'];
419
  $query_args['orderby'] = $args['orderby'];
420
  $query_args['order'] = $args['order'];
421
- $query_args['suppress_filters'] = 0;
422
 
423
  if ( is_numeric( $args['id'] ) && ( intval( $args['id'] ) > 0 ) ) {
424
  $query_args['p'] = intval( $args['id'] );
418
  $query_args['numberposts'] = $args['limit'];
419
  $query_args['orderby'] = $args['orderby'];
420
  $query_args['order'] = $args['order'];
421
+ $query_args['suppress_filters'] = false;
422
 
423
  if ( is_numeric( $args['id'] ) && ( intval( $args['id'] ) > 0 ) ) {
424
  $query_args['p'] = intval( $args['id'] );
classes/class-woothemes-widget-features.php CHANGED
@@ -38,16 +38,23 @@ class Woothemes_Widget_Features extends WP_Widget {
38
  */
39
  public function __construct() {
40
  /* Widget variable settings. */
41
- $this->woothemes_widget_cssclass = 'widget_woothemes_features';
42
  $this->woothemes_widget_description = __( 'Recent features listed on your site.', 'woothemes-features' );
43
- $this->woothemes_widget_idbase = 'woothemes_features';
44
- $this->woothemes_widget_title = __( 'Features', 'woothemes-features' );
45
 
46
  /* Widget settings. */
47
- $widget_ops = array( 'classname' => $this->woothemes_widget_cssclass, 'description' => $this->woothemes_widget_description );
 
 
 
48
 
49
  /* Widget control settings. */
50
- $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woothemes_widget_idbase );
 
 
 
 
51
 
52
  /* Create the widget. */
53
  $this->WP_Widget( $this->woothemes_widget_idbase, $this->woothemes_widget_title, $widget_ops, $control_ops );
@@ -64,21 +71,21 @@ class Woothemes_Widget_Features extends WP_Widget {
64
  extract( $args, EXTR_SKIP );
65
 
66
  /* Our variables from the widget settings. */
67
- $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
68
 
69
  /* Before widget (defined by themes). */
70
  $args = array();
71
 
72
- $args['before'] = $before_widget;
73
 
74
  /* After widget (defined by themes). */
75
- $args['after'] = $after_widget;
76
 
77
  /* Display the widget title if one was input (before and after defined by themes). */
78
  if ( $title ) {
79
- $args['title'] = $title;
80
- $args['before_title'] = $before_title;
81
- $args['after_title'] = $after_title;
82
  }
83
 
84
  /* Widget content. */
@@ -86,19 +93,45 @@ class Woothemes_Widget_Features extends WP_Widget {
86
  do_action( $this->woothemes_widget_cssclass . '_top' );
87
 
88
  // Integer values.
89
- if ( isset( $instance['limit'] ) && ( 0 < count( $instance['limit'] ) ) ) { $args['limit'] = intval( $instance['limit'] ); }
90
- if ( isset( $instance['specific_id'] ) && ( 0 < count( $instance['specific_id'] ) ) ) { $args['id'] = intval( $instance['specific_id'] ); }
91
- if ( isset( $instance['size'] ) && ( 0 < count( $instance['size'] ) ) ) { $args['size'] = intval( $instance['size'] ); }
92
- if ( isset( $instance['per_row'] ) && ( 0 < count( $instance['per_row'] ) ) ) { $args['per_row'] = intval( $instance['per_row'] ); }
93
- if ( isset( $instance['category'] ) && is_numeric( $instance['category'] ) ) $args['category'] = intval( $instance['category'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  // Boolean values.
96
- if ( isset( $instance['link_title'] ) && ( 1 == $instance['link_title'] ) ) { $args['link_title'] = true; } else { $args['link_title'] = false; }
97
- if ( isset( $instance['custom_links_only'] ) && ( 1 == $instance['custom_links_only'] ) ) { $args['custom_links_only'] = true; } else { $args['custom_links_only'] = false; }
 
 
 
 
 
 
 
98
 
99
  // Select boxes.
100
- if ( isset( $instance['orderby'] ) && in_array( $instance['orderby'], array_keys( $this->get_orderby_options() ) ) ) { $args['orderby'] = $instance['orderby']; }
101
- if ( isset( $instance['order'] ) && in_array( $instance['order'], array_keys( $this->get_order_options() ) ) ) { $args['order'] = $instance['order']; }
 
 
 
 
 
102
 
103
  // Display the features.
104
  woothemes_features( $args );
@@ -118,22 +151,22 @@ class Woothemes_Widget_Features extends WP_Widget {
118
  $instance = $old_instance;
119
 
120
  /* Strip tags for title and name to remove HTML (important for text inputs). */
121
- $instance['title'] = strip_tags( $new_instance['title'] );
122
 
123
  /* Make sure the integer values are definitely integers. */
124
- $instance['limit'] = intval( $new_instance['limit'] );
125
- $instance['specific_id'] = intval( $new_instance['specific_id'] );
126
- $instance['size'] = intval( $new_instance['size'] );
127
- $instance['per_row'] = intval( $new_instance['per_row'] );
128
- $instance['category'] = intval( $new_instance['category'] );
129
 
130
  /* The checkbox is returning a Boolean (true/false), so we check for that. */
131
- $instance['link_title'] = (bool) esc_attr( $new_instance['link_title'] );
132
- $instance['custom_links_only'] = (bool) esc_attr( $new_instance['custom_links_only'] );
133
 
134
  /* The select box is returning a text value, so we escape it. */
135
- $instance['orderby'] = esc_attr( $new_instance['orderby'] );
136
- $instance['order'] = esc_attr( $new_instance['order'] );
137
 
138
  return $instance;
139
  } // End update()
@@ -150,15 +183,15 @@ class Woothemes_Widget_Features extends WP_Widget {
150
  /* Set up some default widget settings. */
151
  /* Make sure all keys are added here, even with empty string values. */
152
  $defaults = array(
153
- 'title' => '',
154
- 'limit' => 5,
155
- 'orderby' => 'menu_order',
156
- 'order' => 'DESC',
157
- 'specific_id' => '',
158
- 'size' => 50,
159
- 'per_row' => 3,
160
- 'category' => 0,
161
- 'link_title' => true,
162
  'custom_links_only' => false
163
  );
164
 
@@ -236,12 +269,12 @@ class Woothemes_Widget_Features extends WP_Widget {
236
  */
237
  protected function get_orderby_options () {
238
  return array(
239
- 'none' => __( 'No Order', 'woothemes-features' ),
240
- 'ID' => __( 'Entry ID', 'woothemes-features' ),
241
- 'title' => __( 'Title', 'woothemes-features' ),
242
- 'date' => __( 'Date Added', 'woothemes-features' ),
243
- 'menu_order' => __( 'Specified Order Setting', 'woothemes-features' ),
244
- 'rand' => __( 'Random Order', 'woothemes-features' )
245
  );
246
  } // End get_orderby_options()
247
 
@@ -252,12 +285,11 @@ class Woothemes_Widget_Features extends WP_Widget {
252
  */
253
  protected function get_order_options () {
254
  return array(
255
- 'ASC' => __( 'Ascending', 'woothemes-features' ),
256
- 'DESC' => __( 'Descending', 'woothemes-features' )
257
  );
258
  } // End get_order_options()
259
  } // End Class
260
 
261
  /* Register the widget. */
262
- add_action( 'widgets_init', create_function( '', 'return register_widget("WooThemes_Widget_Features");' ), 1 );
263
- ?>
38
  */
39
  public function __construct() {
40
  /* Widget variable settings. */
41
+ $this->woothemes_widget_cssclass = 'widget_woothemes_features';
42
  $this->woothemes_widget_description = __( 'Recent features listed on your site.', 'woothemes-features' );
43
+ $this->woothemes_widget_idbase = 'woothemes_features';
44
+ $this->woothemes_widget_title = __( 'Features', 'woothemes-features' );
45
 
46
  /* Widget settings. */
47
+ $widget_ops = array(
48
+ 'classname' => $this->woothemes_widget_cssclass,
49
+ 'description' => $this->woothemes_widget_description
50
+ );
51
 
52
  /* Widget control settings. */
53
+ $control_ops = array(
54
+ 'width' => 250,
55
+ 'height' => 350,
56
+ 'id_base' => $this->woothemes_widget_idbase
57
+ );
58
 
59
  /* Create the widget. */
60
  $this->WP_Widget( $this->woothemes_widget_idbase, $this->woothemes_widget_title, $widget_ops, $control_ops );
71
  extract( $args, EXTR_SKIP );
72
 
73
  /* Our variables from the widget settings. */
74
+ $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
75
 
76
  /* Before widget (defined by themes). */
77
  $args = array();
78
 
79
+ $args['before'] = $before_widget;
80
 
81
  /* After widget (defined by themes). */
82
+ $args['after'] = $after_widget;
83
 
84
  /* Display the widget title if one was input (before and after defined by themes). */
85
  if ( $title ) {
86
+ $args['title'] = $title;
87
+ $args['before_title'] = $before_title;
88
+ $args['after_title'] = $after_title;
89
  }
90
 
91
  /* Widget content. */
93
  do_action( $this->woothemes_widget_cssclass . '_top' );
94
 
95
  // Integer values.
96
+ if ( isset( $instance['limit'] ) && ( 0 < count( $instance['limit'] ) ) ) {
97
+ $args['limit'] = intval( $instance['limit'] );
98
+ }
99
+
100
+ if ( isset( $instance['specific_id'] ) && ( 0 < count( $instance['specific_id'] ) ) ) {
101
+ $args['id'] = intval( $instance['specific_id'] );
102
+ }
103
+
104
+ if ( isset( $instance['size'] ) && ( 0 < count( $instance['size'] ) ) ) {
105
+ $args['size'] = intval( $instance['size'] );
106
+ }
107
+
108
+ if ( isset( $instance['per_row'] ) && ( 0 < count( $instance['per_row'] ) ) ) {
109
+ $args['per_row'] = intval( $instance['per_row'] );
110
+ }
111
+
112
+ if ( isset( $instance['category'] ) && is_numeric( $instance['category'] ) ) {
113
+ $args['category'] = intval( $instance['category'] );
114
+ }
115
 
116
  // Boolean values.
117
+ if ( isset( $instance['link_title'] ) && ( 1 == $instance['link_title'] ) ) {
118
+ $args['link_title'] = true; } else { $args['link_title'] = false;
119
+ }
120
+
121
+ if ( isset( $instance['custom_links_only'] ) && ( 1 == $instance['custom_links_only'] ) ) {
122
+ $args['custom_links_only'] = true;
123
+ } else {
124
+ $args['custom_links_only'] = false;
125
+ }
126
 
127
  // Select boxes.
128
+ if ( isset( $instance['orderby'] ) && in_array( $instance['orderby'], array_keys( $this->get_orderby_options() ) ) ) {
129
+ $args['orderby'] = $instance['orderby'];
130
+ }
131
+
132
+ if ( isset( $instance['order'] ) && in_array( $instance['order'], array_keys( $this->get_order_options() ) ) ) {
133
+ $args['order'] = $instance['order'];
134
+ }
135
 
136
  // Display the features.
137
  woothemes_features( $args );
151
  $instance = $old_instance;
152
 
153
  /* Strip tags for title and name to remove HTML (important for text inputs). */
154
+ $instance['title'] = strip_tags( $new_instance['title'] );
155
 
156
  /* Make sure the integer values are definitely integers. */
157
+ $instance['limit'] = intval( $new_instance['limit'] );
158
+ $instance['specific_id'] = intval( $new_instance['specific_id'] );
159
+ $instance['size'] = intval( $new_instance['size'] );
160
+ $instance['per_row'] = intval( $new_instance['per_row'] );
161
+ $instance['category'] = intval( $new_instance['category'] );
162
 
163
  /* The checkbox is returning a Boolean (true/false), so we check for that. */
164
+ $instance['link_title'] = (bool) esc_attr( $new_instance['link_title'] );
165
+ $instance['custom_links_only'] = (bool) esc_attr( $new_instance['custom_links_only'] );
166
 
167
  /* The select box is returning a text value, so we escape it. */
168
+ $instance['orderby'] = esc_attr( $new_instance['orderby'] );
169
+ $instance['order'] = esc_attr( $new_instance['order'] );
170
 
171
  return $instance;
172
  } // End update()
183
  /* Set up some default widget settings. */
184
  /* Make sure all keys are added here, even with empty string values. */
185
  $defaults = array(
186
+ 'title' => '',
187
+ 'limit' => 5,
188
+ 'orderby' => 'menu_order',
189
+ 'order' => 'DESC',
190
+ 'specific_id' => '',
191
+ 'size' => 50,
192
+ 'per_row' => 3,
193
+ 'category' => 0,
194
+ 'link_title' => true,
195
  'custom_links_only' => false
196
  );
197
 
269
  */
270
  protected function get_orderby_options () {
271
  return array(
272
+ 'none' => __( 'No Order', 'woothemes-features' ),
273
+ 'ID' => __( 'Entry ID', 'woothemes-features' ),
274
+ 'title' => __( 'Title', 'woothemes-features' ),
275
+ 'date' => __( 'Date Added', 'woothemes-features' ),
276
+ 'menu_order' => __( 'Specified Order Setting', 'woothemes-features' ),
277
+ 'rand' => __( 'Random Order', 'woothemes-features' )
278
  );
279
  } // End get_orderby_options()
280
 
285
  */
286
  protected function get_order_options () {
287
  return array(
288
+ 'ASC' => __( 'Ascending', 'woothemes-features' ),
289
+ 'DESC' => __( 'Descending', 'woothemes-features' )
290
  );
291
  } // End get_order_options()
292
  } // End Class
293
 
294
  /* Register the widget. */
295
+ add_action( 'widgets_init', create_function( '', 'return register_widget("WooThemes_Widget_Features");' ), 1 );
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://woothemes.com/
4
  Tags: features, widget, shortcode, template-tag, services
5
  Requires at least: 3.4.2
6
  Tested up to: 3.8.0
7
- Stable tag: 1.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -97,6 +97,12 @@ Installing "Features by WooThemes" can be done either by searching for "Features
97
 
98
  We encourage everyone to contribute their ideas, thoughts and code snippets. This can be done by forking the [repository over at GitHub](http://github.com/woothemes/features/).
99
 
 
 
 
 
 
 
100
  == Screenshots ==
101
 
102
  1. The features management screen within the WordPress admin.
@@ -136,6 +142,12 @@ We encourage everyone to contribute their ideas, thoughts and code snippets. Thi
136
 
137
  == Changelog ==
138
 
 
 
 
 
 
 
139
  = 1.4.0 =
140
  * 2014-01-17
141
  * UI tweaks for WordPress 3.8.
4
  Tags: features, widget, shortcode, template-tag, services
5
  Requires at least: 3.4.2
6
  Tested up to: 3.8.0
7
+ Stable tag: 1.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
97
 
98
  We encourage everyone to contribute their ideas, thoughts and code snippets. This can be done by forking the [repository over at GitHub](http://github.com/woothemes/features/).
99
 
100
+ = Can I make feature links open in a new window / tab? =
101
+
102
+ You sure can, just use the following snippet:
103
+
104
+ `add_filter( 'woothemes_features_disable_external_links', '__return_false' );`
105
+
106
  == Screenshots ==
107
 
108
  1. The features management screen within the WordPress admin.
142
 
143
  == Changelog ==
144
 
145
+ = 1.4.1 =
146
+ * 2014-01-30
147
+ * New - Filter to set feature links to open in a new window.
148
+ * Fix - Widget image size option.
149
+ * Tweak - Better WPML integration.
150
+
151
  = 1.4.0 =
152
  * 2014-01-17
153
  * UI tweaks for WordPress 3.8.
woothemes-features-template.php CHANGED
@@ -37,7 +37,7 @@ function woothemes_features ( $args = '' ) {
37
  'order' => 'DESC',
38
  'id' => 0,
39
  'echo' => true,
40
- 'size' => 50,
41
  'per_row' => 3,
42
  'link_title' => true,
43
  'custom_links_only' => true,
@@ -89,14 +89,21 @@ function woothemes_features ( $args = '' ) {
89
  $class .= ' first';
90
  }
91
 
92
- $image_size = apply_filters( 'woothemes_features_image_size', 'thumbnail', $post );
93
 
94
  $image = get_the_post_thumbnail( $post->ID, $image_size );
95
 
96
  $title = get_the_title();
 
 
 
 
 
 
 
97
  if ( true == $args['link_title'] && '' != $post->url ) {
98
- $image = '<a href="' . esc_url( $post->url ) . '" title="' . esc_attr( $title ) . '">' . $image . '</a>';
99
- $title = '<a href="' . esc_url( $post->url ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
100
  }
101
 
102
  // Optionally display the image, if it is available.
@@ -158,16 +165,16 @@ function woothemes_features_shortcode ( $atts, $content = null ) {
158
  $args = (array)$atts;
159
 
160
  $defaults = array(
161
- 'limit' => 5,
162
- 'orderby' => 'menu_order',
163
- 'order' => 'DESC',
164
- 'id' => 0,
165
- 'echo' => true,
166
- 'size' => 50,
167
- 'per_row' => 3,
168
- 'link_title' => true,
169
  'custom_links_only' => false,
170
- 'category' => 0
171
  );
172
 
173
  $args = shortcode_atts( $defaults, $atts );
37
  'order' => 'DESC',
38
  'id' => 0,
39
  'echo' => true,
40
+ 'size' => 150,
41
  'per_row' => 3,
42
  'link_title' => true,
43
  'custom_links_only' => true,
89
  $class .= ' first';
90
  }
91
 
92
+ $image_size = apply_filters( 'woothemes_features_image_size', array($args['size'], $args['size']), $post );
93
 
94
  $image = get_the_post_thumbnail( $post->ID, $image_size );
95
 
96
  $title = get_the_title();
97
+
98
+ if ( apply_filters( 'woothemes_features_disable_external_links', true ) ) {
99
+ $external = '';
100
+ } else {
101
+ $external = 'target="_blank"';
102
+ }
103
+
104
  if ( true == $args['link_title'] && '' != $post->url ) {
105
+ $image = '<a href="' . esc_url( $post->url ) . '" title="' . esc_attr( $title ) . '" ' . $external . '>' . $image . '</a>';
106
+ $title = '<a href="' . esc_url( $post->url ) . '" title="' . esc_attr( $title ) . '" ' . $external . '>' . $title . '</a>';
107
  }
108
 
109
  // Optionally display the image, if it is available.
165
  $args = (array)$atts;
166
 
167
  $defaults = array(
168
+ 'limit' => 5,
169
+ 'orderby' => 'menu_order',
170
+ 'order' => 'DESC',
171
+ 'id' => 0,
172
+ 'echo' => true,
173
+ 'size' => 150,
174
+ 'per_row' => 3,
175
+ 'link_title' => true,
176
  'custom_links_only' => false,
177
+ 'category' => 0
178
  );
179
 
180
  $args = shortcode_atts( $defaults, $atts );
woothemes-features.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://woothemes.com/
5
  * Description: Hi, I'm your feature showcase plugin for WordPress. Show off what features your company, product or service offers, using our shortcode, widget or template tag.
6
  * Author: WooThemes
7
- * Version: 1.4.0
8
  * Author URI: http://woothemes.com/
9
  *
10
  * @package WordPress
@@ -19,4 +19,4 @@ require_once( 'woothemes-features-template.php' );
19
  require_once( 'classes/class-woothemes-widget-features.php' );
20
  global $woothemes_features;
21
  $woothemes_features = new Woothemes_Features( __FILE__ );
22
- $woothemes_features->version = '1.4.0';
4
  * Plugin URI: http://woothemes.com/
5
  * Description: Hi, I'm your feature showcase plugin for WordPress. Show off what features your company, product or service offers, using our shortcode, widget or template tag.
6
  * Author: WooThemes
7
+ * Version: 1.4.1
8
  * Author URI: http://woothemes.com/
9
  *
10
  * @package WordPress
19
  require_once( 'classes/class-woothemes-widget-features.php' );
20
  global $woothemes_features;
21
  $woothemes_features = new Woothemes_Features( __FILE__ );
22
+ $woothemes_features->version = '1.4.1';