Flexible Posts Widget - Version 3.0

Version Description

  • Allow widgets to query by post type and/or taxonomy & term instead of just one or the other. (Props: @vernal)
  • Allow widgets to query by multiple post types and multiple terms within the same taxonomy. (Props: @vernal)
  • Changed the list of available post types and taxonomies from every possible option to just those that are public.
  • General UI enhancements for the widget admin.
  • Some minor code cleanup and security improvements.
Download this release

Release Info

Developer dpe415
Plugin Icon wp plugin Flexible Posts Widget
Version 3.0
Comparing to
See all releases

Code changes from version 2.1.1 to 3.0

css/admin.css ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Flexible Posts Widget
3
+ * Admin Styles
4
+ * Author: dpe415
5
+ * URI: http://wordpress.org/extend/plugins/flexible-posts-widget/
6
+ */
7
+
8
+ .cf:before,
9
+ .cf:after {content:" "; display:table;}
10
+ .cf:after {clear:both;}
11
+ .cf {*zoom:1;}
12
+
13
+ .dpe-fp-widget h4 {margin-bottom:0.5em;}
14
+ .dpe-fp-widget select {background-color:#fff;}
15
+
16
+ .dpe-fp-widget .ui-tabs-active {background:#fff; border-color: #DFDFDF #DFDFDF #FFFFFF;}
17
+ .dpe-fp-widget .ui-tabs-active a {color:#333333;}
18
+
19
+ .dpe-fp-widget .warning {color:#d21703;}
20
+ .dpe-fp-widget .section {margin-bottom:1.33em; border-bottom:1px solid #dfdfdf;}
21
+ .dpe-fp-widget .section.getemby {padding-bottom:1.333em;}
22
+
23
+ .dpe-fp-widget .tabs-panel.tt {padding:1.333em 1em;}
24
+ .dpe-fp-widget .tabs-panel .terms {max-height:110px; overflow:auto; border:1px solid #DFDFDF;}
25
+ .dpe-fp-widget .tabs-panel .terms ul {margin-left:1em;}
26
+ .dpe-fp-widget .tabs-panel .terms p {margin:1em;}
27
+
28
+ .dpe-fp-widget .display p {margin-bottom:0.5em;}
29
+ .dpe-fp-widget .display p:last-child {margin-bottom:1em;}
30
+ .dpe-fp-widget .display label {float:left; padding-top:0.4em;}
31
+ .dpe-fp-widget .display input {float:right; width:60px; text-align:right;}
32
+ .dpe-fp-widget .display select {float:right; width:120px;}
33
+
34
+ .dpe-fp-widget .thumbnails label {padding-top:0.4em;}
flexible-posts-widget.php CHANGED
@@ -4,13 +4,13 @@ Plugin Name: Flexible Posts Widget
4
  Plugin URI: http://wordpress.org/extend/plugins/flexible-posts-widget/
5
  Author: dpe415
6
  Author URI: http://dpedesign.com
7
- Version: 2.1.1
8
- Description: An advanced posts display widget with many options: post by taxonomy & term or post type, thumbnails, order & order by, customizable templates
9
  License: GPL2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
 
13
- /* Copyright 2012 David Paul Ellenwood (email : david@dpedesign.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License, version 2, as
@@ -31,7 +31,7 @@ if( !defined('ABSPATH') )
31
  die('-1');
32
 
33
  if( !defined('DPE_FP_Version') )
34
- define( 'DPE_FP_Version', '2.1.1' );
35
 
36
 
37
  // Load the widget on widgets_init
@@ -40,14 +40,10 @@ function dpe_load_flexible_posts_widget() {
40
  }
41
  add_action('widgets_init', 'dpe_load_flexible_posts_widget');
42
 
43
-
44
- // Setup our get terms/AJAX callback
45
- add_action( 'wp_ajax_dpe_fp_get_terms', 'dpe_fp_term_me' );
46
 
47
  /**
48
  * Flexible Posts Widget Class
49
  */
50
-
51
  class DPE_Flexible_Posts_Widget extends WP_Widget {
52
 
53
  /**
@@ -55,23 +51,43 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
55
  */
56
  public function __construct() {
57
 
 
 
58
  parent::__construct(
59
  'dpe_fp_widget', // Base ID
60
  'Flexible Posts Widget', // Name
61
  array( 'description' => __( 'Display posts as widget items', 'text_domain' ), ) // Args
62
  );
63
 
64
- $this->register_sns(); // Register styles & scripts
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- global $pagenow;
 
67
 
68
  // Enqueue admin scripts
69
- if (defined("WP_ADMIN") && WP_ADMIN) {
70
  if ( 'widgets.php' == $pagenow ) {
71
  wp_enqueue_script( 'dpe-fp-widget' );
 
72
  }
73
  }
74
-
75
 
76
  }
77
 
@@ -87,35 +103,30 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
87
  function widget($args, $instance) {
88
  extract( $args );
89
  extract( $instance );
 
90
  $title = apply_filters( 'widget_title', empty( $title ) ? '' : $title );
91
 
92
- if( empty($template) )
93
  $template = 'widget.php';
94
 
95
- // Setup our query
96
- if( 'tnt' == $getemby ) {
97
- $args = array(
98
- 'tax_query' => array(
99
- array(
100
- 'taxonomy' => $taxonomy,
101
- 'field' => 'slug',
102
- 'terms' => $term,
103
- )
104
- ),
105
- 'post_status' => array('publish', 'inherit'),
106
- 'posts_per_page' => $number,
107
- 'offset' => $offset,
108
- 'orderby' => $orderby,
109
- 'order' => $order,
110
- );
111
- } else {
112
- $args = array(
113
- 'post_status' => array('publish', 'inherit'),
114
- 'post_type' => $posttype,
115
- 'posts_per_page' => $number,
116
- 'offset' => $offset,
117
- 'orderby' => $orderby,
118
- 'order' => $order,
119
  );
120
  }
121
 
@@ -140,22 +151,58 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
140
  *
141
  * @return array Updated safe values to be saved.
142
  */
143
- function update($new_instance, $old_instance) {
144
- global $posttypes;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  $instance = $old_instance;
146
  $instance['title'] = strip_tags( $new_instance['title'] );
147
- $instance['getemby'] = $new_instance['getemby'];
148
- $instance['posttype'] = $new_instance['posttype'];
149
- $instance['taxonomy'] = $new_instance['taxonomy'];
150
- $instance['term'] = strip_tags( $new_instance['term'] );
151
- $instance['number'] = strip_tags( $new_instance['number'] );
152
- $instance['offset'] = strip_tags( $new_instance['offset'] );
153
- $instance['orderby'] = $new_instance['orderby'];
154
- $instance['order'] = $new_instance['order'];
155
- $instance['thumbsize'] = $new_instance['thumbsize'];
156
- $instance['thumbnail'] = $new_instance['thumbnail'];
157
  $instance['template'] = strip_tags( $new_instance['template'] );
 
 
158
  return $instance;
 
159
  }
160
 
161
  /**
@@ -165,21 +212,13 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
165
  *
166
  * @param array $instance Previously saved values from database.
167
  */
168
- function form($instance) {
169
-
170
- $getembies = array( 'tnt', 'pt' );
171
- $posttypes = get_post_types('', 'objects');
172
- $taxonomies = get_taxonomies('', 'objects');
173
- $orderbys = array( 'ID', 'title', 'date', 'rand', 'menu_order', );
174
- $orders = array( 'ASC', 'DESC', );
175
- $thumb_sizes = get_intermediate_image_sizes();
176
-
177
  $instance = wp_parse_args( (array) $instance, array(
178
  'title' => '',
179
- 'getemby' => 'tnt',
180
- 'posttype' => 'post',
181
- 'taxonomy' => 'category',
182
- 'term' => '',
183
  'number' => '3',
184
  'offset' => '0',
185
  'orderby' => 'date',
@@ -187,127 +226,13 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
187
  'thumbnail' => false,
188
  'thumbsize' => '',
189
  'template' => 'widget.php',
 
190
  ) );
191
 
192
  extract( $instance );
193
 
194
- ?>
195
- <p>
196
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:'); ?></label>
197
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
198
- </p>
199
- <h4 style="margin-bottom:.2em;"><label for="<?php echo $this->get_field_id('getemby'); ?>"><?php _e('Get posts by:'); ?></label></strong></h4>
200
- <p>
201
- <select class="widefat dpe-fp-getemby" name="<?php echo $this->get_field_name('getemby'); ?>" id="<?php echo $this->get_field_id('getemby'); ?>">
202
- <option value="tnt"<?php echo $getemby == 'tnt' ? ' selected="selected"' : ''?>>Taxonomy &amp; Term</option>
203
- <option value="pt"<?php echo $getemby == 'pt' ? ' selected="selected"' : ''?>>Post Type</option>
204
- </select>
205
- </p>
206
-
207
- <div id="<?php echo $this->get_field_id('tnt-box'); ?>" class="getembies tnt" <?php echo $getemby == 'tnt' ? '' : 'style="display:none;"'?>>
208
- <p>
209
- <label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Select a taxonomy:'); ?></label>
210
- <select style="background-color:#fff;" class="widefat dpe-fp-taxonomy" name="<?php echo $this->get_field_name('taxonomy'); ?>" id="<?php echo $this->get_field_id('taxonomy'); ?>">
211
- <?php
212
- foreach ($taxonomies as $option) {
213
- echo '<option value="' . $option->name . '"', $taxonomy == $option->name ? ' selected="selected"' : '', '>', $option->label, '</option>';
214
- }
215
- ?>
216
- </select>
217
- </p>
218
- <p>
219
- <label for="<?php echo $this->get_field_id('term'); ?>"><?php _e('Select a term:'); ?></label>
220
- <select class="widefat dpe-fp-term" name="<?php echo $this->get_field_name('term'); ?>" id="<?php echo $this->get_field_id('term'); ?>">
221
- <option value="-1">Please select...</option>
222
- <?php
223
- if( $taxonomy ) {
224
- $args = array (
225
- 'hide_empty' => 0,
226
- );
227
-
228
- $terms = get_terms( $taxonomy, $args );
229
-
230
- if( !empty($terms) ) {
231
- $output = '';
232
- foreach ( $terms as $option )
233
- $output .= '<option value="' . $option->slug . '"' . ( $term == $option->slug ? ' selected="selected"' : '' ) . '>' . $option->name . '</option>';
234
- echo( $output );
235
- }
236
- }
237
- ?>
238
- </select>
239
- </p>
240
- </div><!-- .tnt.getemby -->
241
-
242
- <div id="<?php echo $this->get_field_id('pt-box'); ?>" class="getembies pt" <?php echo $getemby == 'pt' ? '' : 'style="display:none;"'?>>
243
- <p>
244
- <label for="<?php echo $this->get_field_id('posttype'); ?>"><?php _e('Select a post type:'); ?></label>
245
- <select class="widefat" name="<?php echo $this->get_field_name('posttype'); ?>" id="<?php echo $this->get_field_id('posttype'); ?>">
246
- <?php
247
- foreach ($posttypes as $option) {
248
- echo '<option value="' . $option->name . '"', $posttype == $option->name ? ' selected="selected"' : '', '>', $option->labels->name, '</option>';
249
- }
250
- ?>
251
- </select>
252
- </p>
253
- </div><!-- .pt.getemby -->
254
-
255
- <hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
256
- <h4 style="">Display options</h4>
257
- <p>
258
- <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
259
- <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" style="width:40px; margin-left:.2em; text-align:right;" />
260
- </p>
261
- <p>
262
- <label for="<?php echo $this->get_field_id('offset'); ?>"><?php _e('Number of posts to skip:'); ?></label>
263
- <input id="<?php echo $this->get_field_id('offset'); ?>" name="<?php echo $this->get_field_name('offset'); ?>" type="text" value="<?php echo $offset; ?>" style="width:40px; margin-left:.2em; text-align:right;" />
264
- </p>
265
- <p>
266
- <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e('Order post by:'); ?></label>
267
- <select class="widefat" name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>">
268
- <?php
269
- foreach ($orderbys as $option) {
270
- echo '<option value="' . $option . '" id="' . $option . '"', $orderby == $option ? ' selected="selected"' : '', '>', $option, '</option>';
271
- }
272
- ?>
273
- </select>
274
- </p>
275
- <p>
276
- <label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order:'); ?></label>
277
- <select class="widefat" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>">
278
- <?php
279
- foreach ($orders as $option) {
280
- echo '<option value="' . $option . '"', $order == $option ? ' selected="selected"' : '', '>', $option, '</option>';
281
- }
282
- ?>
283
- </select>
284
- <br />
285
- <span style="padding-top:3px;" class="description"><?php _e('ASC = 1,2,3 or A,B,C<br />DESC = 3,2,1 or C,B,A'); ?></span>
286
- </p>
287
- <hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
288
- <p style="margin-top:1.33em;">
289
- <input class="dpe-fp-thumbnail" id="<?php echo $this->get_field_id('thumbnail'); ?>" name="<?php echo $this->get_field_name('thumbnail'); ?>" type="checkbox" value="1" <?php checked( '1', $thumbnail ); ?>/>
290
- <label style="font-weight:bold;" for="<?php echo $this->get_field_id('thumbnail'); ?>"><?php _e('Display thumbnails?'); ?></label>
291
- </p>
292
- <p <?php echo $thumbnail == '1' ? '' : 'style="display:none;"'?> class="thumb-size">
293
- <label for="<?php echo $this->get_field_id('thumbsize'); ?>"><?php _e('Select a thumbnail size to show:'); ?></label>
294
- <select class="widefat" name="<?php echo $this->get_field_name('thumbsize'); ?>" id="<?php echo $this->get_field_id('thumbsize'); ?>">
295
- <?php
296
- foreach ($thumb_sizes as $option) {
297
- echo '<option value="' . $option . '" id="' . $option . '"', $thumbsize == $option ? ' selected="selected"' : '', '>', $option, '</option>';
298
- }
299
- ?>
300
- </select>
301
- </p>
302
- <hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
303
- <p style="margin:1.33em 0;">
304
- <label for="<?php echo $this->get_field_id('template'); ?>"><?php _e('Template filename:'); ?></label>
305
- <input id="<?php echo $this->get_field_id('template'); ?>" name="<?php echo $this->get_field_name('template'); ?>" type="text" value="<?php echo $template; ?>" />
306
- <br />
307
- <span style="padding-top:3px;" class="description"><a target="_blank" href="http://wordpress.org/extend/plugins/flexible-posts-widget/other_notes/">See documentation</a> for details.</span>
308
- </p>
309
- <hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
310
- <?php
311
  }
312
 
313
  /**
@@ -322,8 +247,7 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
322
  * @param string $template template file to search for
323
  * @return template path
324
  **/
325
-
326
- function getTemplateHierarchy( $template ) {
327
 
328
  // whether or not .php was added
329
  $template_slug = rtrim( $template, '.php' );
@@ -341,44 +265,77 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
341
 
342
  }
343
 
344
- // Register styles & scripts
345
- function register_sns() {
346
- $dir = plugins_url('/', __FILE__);
347
- wp_register_script( 'dpe-fp-widget', $dir . 'js/admin.js', array('jquery'), DPE_FP_Version, true );
 
 
348
  }
349
 
 
 
 
 
 
 
 
 
 
 
 
350
 
351
- } // class DPE_Flexible_Posts_Widget
352
-
353
 
354
- // return a list of terms for the chosen taxonomy used via AJAX
355
- function dpe_fp_term_me() {
356
-
357
- $taxonomy = esc_attr( $_POST['taxonomy'] );
358
- $term = esc_attr( $_POST['term'] );
359
-
360
- if( empty($taxonomy) )
361
- echo false;
362
-
363
- $args = array (
364
- 'hide_empty' => 0,
365
- );
366
-
367
- $terms = get_terms( $taxonomy, $args );
368
-
369
- if( empty($terms) ) {
370
- $output = '<option value="-1">No terms found...</option>';
371
- } else {
372
- $output = '<option value="-1">Please select...</option>';
373
- foreach ( $terms as $option ) {
374
- $output .= '<option value="' . $option->slug . '"' . ( $term == $option->slug ? ' selected="selected"' : '' ) . '>' . $option->name . '</option>';
375
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  }
377
 
378
- echo( $output );
379
-
380
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
 
382
- }
 
383
 
384
  ?>
4
  Plugin URI: http://wordpress.org/extend/plugins/flexible-posts-widget/
5
  Author: dpe415
6
  Author URI: http://dpedesign.com
7
+ Version: 3.0
8
+ Description: An advanced posts display widget with many options: get posts by post type, taxonomy & term; sorting & ordering; feature images; custom templates and more.
9
  License: GPL2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
 
13
+ /* Copyright 2013 David Paul Ellenwood (email : david@dpedesign.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License, version 2, as
31
  die('-1');
32
 
33
  if( !defined('DPE_FP_Version') )
34
+ define( 'DPE_FP_Version', '3.0' );
35
 
36
 
37
  // Load the widget on widgets_init
40
  }
41
  add_action('widgets_init', 'dpe_load_flexible_posts_widget');
42
 
 
 
 
43
 
44
  /**
45
  * Flexible Posts Widget Class
46
  */
 
47
  class DPE_Flexible_Posts_Widget extends WP_Widget {
48
 
49
  /**
51
  */
52
  public function __construct() {
53
 
54
+ global $pagenow;
55
+
56
  parent::__construct(
57
  'dpe_fp_widget', // Base ID
58
  'Flexible Posts Widget', // Name
59
  array( 'description' => __( 'Display posts as widget items', 'text_domain' ), ) // Args
60
  );
61
 
62
+ $this->directory = plugins_url( '/', __FILE__ );
63
+ $this->posttypes = get_post_types( array('public' => true ), 'objects' );
64
+ $this->taxonomies = get_taxonomies( array('public' => true ), 'objects' );
65
+ $this->thumbsizes = get_intermediate_image_sizes();
66
+ $this->orderbys = array(
67
+ 'date' => 'Publish Date',
68
+ 'title' => 'Title',
69
+ 'menu_order' => 'Menu Order',
70
+ 'ID' => 'Post ID',
71
+ 'author' => 'Author',
72
+ 'name' => 'Post Slug',
73
+ 'comment_count' => 'Comment Count',
74
+ 'rand' => 'Random',
75
+ );
76
+ $this->orders = array(
77
+ 'ASC' => 'Ascending',
78
+ 'DESC' => 'Descending',
79
+ );
80
 
81
+ $this->register_hooks(); // Register actions & filters
82
+ $this->register_sns( $this->directory ); // Register styles & scripts
83
 
84
  // Enqueue admin scripts
85
+ if ( defined("WP_ADMIN") && WP_ADMIN ) {
86
  if ( 'widgets.php' == $pagenow ) {
87
  wp_enqueue_script( 'dpe-fp-widget' );
88
+ wp_enqueue_style( 'dpe-fp-widget' );
89
  }
90
  }
 
91
 
92
  }
93
 
103
  function widget($args, $instance) {
104
  extract( $args );
105
  extract( $instance );
106
+
107
  $title = apply_filters( 'widget_title', empty( $title ) ? '' : $title );
108
 
109
+ if ( empty($template) )
110
  $template = 'widget.php';
111
 
112
+ // Setup the query
113
+ $args = array(
114
+ 'post_type' => $posttype,
115
+ 'post_status' => array('publish', 'inherit'),
116
+ 'posts_per_page' => $number,
117
+ 'offset' => $offset,
118
+ 'orderby' => $orderby,
119
+ 'order' => $order,
120
+ );
121
+
122
+ // Setup the tax & term query based on the user's selection
123
+ if ( $taxonomy != 'none' ) {
124
+ $args['tax_query'] = array(
125
+ array(
126
+ 'taxonomy' => $taxonomy,
127
+ 'field' => 'slug',
128
+ 'terms' => $term,
129
+ )
 
 
 
 
 
 
130
  );
131
  }
132
 
151
  *
152
  * @return array Updated safe values to be saved.
153
  */
154
+ function update( $new_instance, $old_instance ) {
155
+
156
+ // Get our defaults to test against
157
+ $pt_names = get_post_types( array('public' => true ), 'names' );
158
+ $tax_names = get_taxonomies( array('public' => true ), 'names' );
159
+ $tax_names[] = 'none';
160
+
161
+ // Validate posttype submissions
162
+ $posttypes = array();
163
+ foreach( $new_instance['posttype'] as $pt ) {
164
+ if( in_array( $pt, $pt_names ) )
165
+ $posttypes[] = $pt;
166
+ }
167
+ if( empty($posttypes) )
168
+ $posttypes[] = 'post';
169
+
170
+ // Validate taxonomy & term submissions
171
+ if( in_array( $new_instance['taxonomy'], $tax_names ) ) {
172
+ $taxonomy = $new_instance['taxonomy'];
173
+ $terms = array();
174
+ if( 'none' != $taxonomy ) {
175
+ $term_objects = get_terms( $taxonomy, array( 'hide_empty' => false ) );
176
+ $term_names = array();
177
+ foreach ( $term_objects as $object ) {
178
+ $term_names[] = $object->slug;
179
+ }
180
+ foreach( $new_instance['term'] as $term ) {
181
+ if( in_array( $term, $term_names ) )
182
+ $terms[] = $term;
183
+ }
184
+ }
185
+ } else {
186
+ $taxonomy = 'none';
187
+ $terms = array();
188
+ }
189
+
190
  $instance = $old_instance;
191
  $instance['title'] = strip_tags( $new_instance['title'] );
192
+ $instance['posttype'] = $posttypes;
193
+ $instance['taxonomy'] = $taxonomy;
194
+ $instance['term'] = $terms;
195
+ $instance['number'] = (int)$new_instance['number'];
196
+ $instance['offset'] = (int)$new_instance['offset'];
197
+ $instance['orderby'] = ( array_key_exists( $new_instance['orderby'], $this->orderbys ) ? $new_instance['orderby'] : 'date' );
198
+ $instance['order'] = ( array_key_exists( $new_instance['order'], $this->orders ) ? $new_instance['order'] : 'DESC' );
199
+ $instance['thumbnail'] = (bool)$new_instance['thumbnail'];
200
+ $instance['thumbsize'] = (in_array ( $new_instance['thumbsize'], $this->thumbsizes ) ? $new_instance['thumbsize'] : '' );
 
201
  $instance['template'] = strip_tags( $new_instance['template'] );
202
+ $instance['cur_tab'] = (int)( $new_instance['cur_tab'] );
203
+
204
  return $instance;
205
+
206
  }
207
 
208
  /**
212
  *
213
  * @param array $instance Previously saved values from database.
214
  */
215
+ function form( $instance ) {
216
+
 
 
 
 
 
 
 
217
  $instance = wp_parse_args( (array) $instance, array(
218
  'title' => '',
219
+ 'posttype' => array('post'),
220
+ 'taxonomy' => 'none',
221
+ 'term' => array(),
 
222
  'number' => '3',
223
  'offset' => '0',
224
  'orderby' => 'date',
226
  'thumbnail' => false,
227
  'thumbsize' => '',
228
  'template' => 'widget.php',
229
+ 'cur_tab' => '0',
230
  ) );
231
 
232
  extract( $instance );
233
 
234
+ include( $this->getTemplateHierarchy( 'admin' ) );
235
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  }
237
 
238
  /**
247
  * @param string $template template file to search for
248
  * @return template path
249
  **/
250
+ public function getTemplateHierarchy( $template ) {
 
251
 
252
  // whether or not .php was added
253
  $template_slug = rtrim( $template, '.php' );
265
 
266
  }
267
 
268
+ /**
269
+ * Register styles & scripts
270
+ */
271
+ public function register_sns( $dir ) {
272
+ wp_register_script( 'dpe-fp-widget', $dir . 'js/admin.js', array('jquery', 'jquery-ui-tabs' ), DPE_FP_Version, true );
273
+ wp_register_style( 'dpe-fp-widget', $dir . 'css/admin.css', array(), DPE_FP_Version );
274
  }
275
 
276
+ /**
277
+ * Setup our get terms/AJAX callback
278
+ */
279
+ public function register_hooks() {
280
+ add_action( 'wp_ajax_dpe_fp_get_terms', array( &$this, 'terms_checklist' ) );
281
+ }
282
+
283
+ /**
284
+ * return a list of terms for the chosen taxonomy used via AJAX
285
+ */
286
+ public function terms_checklist( $term ) {
287
 
288
+ $taxonomy = esc_attr( $_POST['taxonomy'] );
 
289
 
290
+ if ( !isset( $term ) )
291
+ $term = esc_attr( $_POST['term'] );
292
+
293
+ if ( empty($taxonomy) || 'none' == $taxonomy ) {
294
+ echo false;
295
+ die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  }
297
+
298
+ $args = array (
299
+ 'hide_empty' => 0,
300
+ );
301
+
302
+ $terms = get_terms( $taxonomy, $args );
303
+
304
+ if( empty($terms) ) {
305
+ $output = '<p>No terms found.</p>';
306
+ } else {
307
+ $output = '<ul class="categorychecklist termschecklist form-no-clear">';
308
+ foreach ( $terms as $option ) {
309
+ $output .= "\n<li>" . '<label class="selectit"><input value="' . esc_attr( $option->slug ) . '" type="checkbox" name="' . $this->get_field_name('term') . '[]"' . checked( in_array( $option->slug, (array)$term ), true, false ) . ' /> ' . esc_html( $option->name ) . "</label></li>\n";
310
+ }
311
+ $output .= "</ul>\n";
312
+ }
313
+
314
+ echo ( $output );
315
+
316
+ die();
317
+
318
  }
319
 
320
+ /**
321
+ *
322
+ */
323
+ public function posttype_checklist( $posttype ) {
324
+
325
+ //Get pubic post type objects
326
+ $posttypes = get_post_types( array('public' => true ), 'objects' );
327
+
328
+ $output = '<ul class="categorychecklist posttypechecklist form-no-clear">';
329
+ foreach ( $posttypes as $type ) {
330
+ $output .= "\n<li>" . '<label class="selectit"><input value="' . esc_attr( $type->name ) . '" type="checkbox" name="' . $this->get_field_name('posttype') . '[]"' . checked( in_array( $type->name, $posttype ), true, false ) . ' /> ' . esc_html( $type->labels->name ) . "</label></li>\n";
331
+ }
332
+ $output .= "</ul>\n";
333
+
334
+ echo ( $output );
335
+
336
+ }
337
 
338
+
339
+ } // class DPE_Flexible_Posts_Widget
340
 
341
  ?>
js/admin.js CHANGED
@@ -5,14 +5,7 @@
5
  * URI: http://wordpress.org/extend/plugins/flexible-posts-widget/
6
  */
7
 
8
- jQuery(document).ready(function($) {
9
-
10
- // Setup the get posts by select box
11
- jQuery('select.dpe-fp-getemby').each( function() {
12
- var thisone = 'div.' + jQuery(this).val();
13
- jQuery(this).parent().nextAll('.getembies').hide();
14
- jQuery(this).parent().nextAll(thisone).show();
15
- });
16
 
17
  // Setup the show/hide thumbnails box
18
  jQuery('input.dpe-fp-thumbnail').each( function() {
@@ -23,18 +16,36 @@ jQuery(document).ready(function($) {
23
  }
24
  });
25
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  });
27
 
28
-
29
- // Add event triggers to the get posts by box
30
- jQuery(document).on("change", 'select.dpe-fp-getemby', function(event) {
31
- var thisone = 'div.' + jQuery(this).val();
32
- jQuery(this).parent().nextAll('.getembies').hide();
33
- jQuery(this).parent().nextAll(thisone).slideDown('fast');
 
 
 
 
 
 
34
  });
35
 
36
  // Add event triggers to the show/hide thumbnails box
37
- jQuery(document).on("change", 'input.dpe-fp-thumbnail', function(event) {
38
  if( this.checked ) {
39
  jQuery(this).parent().next().slideDown('fast');
40
  } else {
@@ -43,27 +54,38 @@ jQuery(document).on("change", 'input.dpe-fp-thumbnail', function(event) {
43
  });
44
 
45
  // Setup the get_terms callback
46
- jQuery(document).on("change", 'select.dpe-fp-taxonomy', function(event) {
47
-
48
- var terms_select = jQuery(this).parent().next('p').find('select');
49
- var terms_first_opt = terms_select.children(":first");
50
 
51
- terms_first_opt.text('Getting terms...');
52
- terms_select.attr('disabled', true);
53
-
54
- var data = {
55
- action: 'dpe_fp_get_terms',
56
- taxonomy: jQuery(this).val(),
57
- term: terms_select.val(),
58
- };
59
-
60
- jQuery.post(ajaxurl, data, function(response) {
61
- terms_select.html(response);
62
- terms_select.attr('disabled', false);
63
- }).error( function() {
64
- terms_first_opt.text('No terms found...');
65
- });
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
 
 
 
 
68
 
69
  });
5
  * URI: http://wordpress.org/extend/plugins/flexible-posts-widget/
6
  */
7
 
8
+ jQuery(function($) {
 
 
 
 
 
 
 
9
 
10
  // Setup the show/hide thumbnails box
11
  jQuery('input.dpe-fp-thumbnail').each( function() {
16
  }
17
  });
18
 
19
+ // Enable the Get Em By tabs
20
+ jQuery('.getembytabs').tabs({
21
+ // Set the active tab to a widget option
22
+ activate: function( event, ui ) {
23
+ jQuery(this).find('.cur_tab').val( jQuery( this ).tabs( "option", "active" ) );
24
+ },
25
+ // retrieve the saved active tab and set it for the UI
26
+ create: function( event, ui ) {
27
+ jQuery( this ).tabs( "option", "active", jQuery(this).find('.cur_tab').val() );
28
+ }
29
+ });
30
+
31
  });
32
 
33
+ // Add the tabs functionality AJAX returns
34
+ jQuery(document).ajaxComplete(function() {
35
+ jQuery('.getembytabs').tabs({
36
+ // Set the active tab to a widget option
37
+ activate: function( event, ui ) {
38
+ jQuery(this).find('.cur_tab').val( jQuery(this).tabs( "option", "active" ) );
39
+ },
40
+ // retrieve the saved active tab and set it for the UIß
41
+ create: function( event, ui ) {
42
+ jQuery(this).tabs( "option", "active", jQuery(this).find('.cur_tab').val() );
43
+ }
44
+ });
45
  });
46
 
47
  // Add event triggers to the show/hide thumbnails box
48
+ jQuery('#widgets-right').on("change", 'input.dpe-fp-thumbnail', function(event) {
49
  if( this.checked ) {
50
  jQuery(this).parent().next().slideDown('fast');
51
  } else {
54
  });
55
 
56
  // Setup the get_terms callback
57
+ jQuery('#widgets-right').on("change", 'select.dpe-fp-taxonomy', function(event) {
 
 
 
58
 
59
+ var terms_div = jQuery(this).parent().nextAll('div.terms');
60
+ var terms_label = jQuery(this).parent().next('label');
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
+ // If we're not ignoring Taxonomy & Term...
63
+ if( jQuery(this).val() != 'none' ) {
64
+
65
+ terms_label.html('Getting terms...').show();
66
+
67
+ var selected_terms = [];
68
+ terms_div.find("input:checked").each(function () {
69
+ selected_terms.push( jQuery(this).val() );
70
+ });
71
+
72
+ var data = {
73
+ action: 'dpe_fp_get_terms',
74
+ taxonomy: jQuery(this).val(),
75
+ term: selected_terms,
76
+ };
77
+
78
+ jQuery.post(ajaxurl, data, function(response) {
79
+ terms_div.html(response);
80
+ terms_label.html('Select terms:').show();
81
+ terms_div.slideDown();
82
+ }).error( function() {
83
+ terms_label.html('No terms found.').show();
84
+ });
85
 
86
+ } else {
87
+ terms_div.slideUp().html('');
88
+ terms_label.hide();
89
+ }
90
 
91
  });
readme.txt CHANGED
@@ -1,31 +1,32 @@
1
  === Flexible Posts Widget ===
2
  Contributors: dpe415
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DJKSKHJWYAWDU
4
- Tags: widget, widgets, posts, recent posts, thumbnails, custom post types, custom taxonomies
5
  Requires at least: 3.2
6
- Tested up to: 3.4
7
- Stable tag: 2.1.1
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- An advanced posts display widget with many options. Display posts in your sidebars exactly the way you like!
12
 
13
  == Description ==
14
 
15
- The default WordPress Recent Posts widget is exceptionally basic. I found myself always in need of a way to display a selection of posts from any taxonomy or post type in a theme sidebar; hence, Flexible Posts Widget. Flexible Posts Widget extends the default widget with many per-instance options.
16
 
17
- = Upgrading from v1 to v2 =
18
- When upgrading from version 1.0.x to version 2, please remember to double-check the settings for any existing widgets. Not all settings combinations will be saved after the upgrade.
 
19
 
20
  = Features & options =
21
 
22
  * Customizable widget title
23
- * Get posts using either a selectable taxonomy & term *OR* by selecting any post type.
24
- * Control the number of posts displayed.
25
- * Option to display the post thumbnail (feature image).
26
- * Select the post thumbnail size to display from available image sizes.
27
- * Select the sort orderby: Date, ID, Title, Menu Order, Random and sort order: ASC or DESC.
28
- * The widget's HTML output can be customized by user-defined templates added to the current theme folder.
29
 
30
 
31
  == Installation ==
@@ -37,7 +38,7 @@ When upgrading from version 1.0.x to version 2, please remember to double-check
37
  = To use a customized HTML output template =
38
 
39
  1. Create a folder called `flexible-posts-widget` in the root of your theme folder.
40
- 1. Copy `widget.php` from within this plugin's `views` folder into your theme's new `flexible-posts-widget` folder.
41
  1. Optional: Rename your theme's `widget.php` template file to a name of your choice (to use different templates for each widget instance).
42
  1. Go to 'Appearance' > 'Widgets' in WordPress to configure an instance of the widget.
43
  1. In the 'Template Filename' field enter the name of the template file you added to your theme. Example: `my-themes-widget.php`
@@ -45,45 +46,60 @@ When upgrading from version 1.0.x to version 2, please remember to double-check
45
 
46
  == Frequently Asked Questions ==
47
 
 
 
 
 
 
 
48
  = Questions, Support & Bug Reports =
49
  To get answers to your questions, request help or submit a bug report, please visit the forum: http://wordpress.org/tags/flexible-posts-widget/
50
 
51
 
52
  == Screenshots ==
53
 
54
- 1. Flexible Posts Widget admin screen showing get posts by taxonomy and term with thumbnails.
55
- 1. Flexible Posts Widget admin screen showing get posts by post type without thumbnails.
56
- 1. Example Flexible Posts Widget showing the post thumbnail and title wrapped in a link to the post.
 
 
 
57
 
58
  == Upgrade Notice ==
59
 
60
- = 2.0 =
61
- When upgrading from version 1.0.x to version 2.x, please remember to double-check the settings for any existing widgets. Not all settings combinations will be saved after the upgrade.
62
 
63
 
64
  == Other Notes ==
65
 
66
- = Upgrading from v1 to v2 =
67
- When upgrading from version 1.0.x to version 2.x, please remember to double-check the settings for any existing widgets. Not all settings combinations will be saved after the upgrade.
68
 
69
  = Default vs. Custom Templates =
70
 
71
- Flexible Posts Widget comes with a default template for the widget output. If you would like to alter the widget display code, create a new folder called `flexible-posts-widget` in your template directory and copy over the "views/widget.php" file.
72
 
73
  Edit the new file in your theme to your desired HTML layout. Please do not edit the one in the plugin folder as that will cause conflicts when you update the plugin to the latest release.
74
 
75
- = Future updates & features list =
76
 
77
- * Allow for multiple post type or term selections.
78
  * Dynamically populate the "Template Filename" field based on the templates available.
79
  * Adjust widget output template for Media-type posts.
80
- * Add default styles for the widget display & an option to load or not load them. (?)
 
81
 
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
 
85
  = 2.1.1 =
86
- * Fixed a source order bug in the widget.php template file. (Props: Carsten Bach).
87
 
88
  = 2.1 =
89
  * Added offset parameter to display options.
@@ -109,4 +125,4 @@ Edit the new file in your theme to your desired HTML layout. Please do not edit
109
  * Readme.txt updates
110
 
111
  = 1.0 =
112
- * First public release
1
  === Flexible Posts Widget ===
2
  Contributors: dpe415
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DJKSKHJWYAWDU
4
+ Tags: widget, widgets, posts, categories, tags, recent posts, thumbnails, custom post types, custom taxonomies, feature image
5
  Requires at least: 3.2
6
+ Tested up to: 3.5
7
+ Stable tag: 3.0
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ An advanced posts display widget with many options. Display posts in your sidebars any way you'd like!
12
 
13
  == Description ==
14
 
15
+ The default Recent Posts widget is exceptionally basic. I always find myself in need of a way to easily display a selection of posts from any combination post type or taxonomy. Hence, Flexible Post Widget.
16
 
17
+ Flexible Posts Widget (FPW) is more than just a simple alternative to the default Recent Posts widget. With many per-instance options it is highly customizable and allows advanced users to display the resulting posts virtually anyway imaginable.
18
+
19
+ Version 3.0 is a major enhancement as widgets can now get posts by *BOTH* post type and/or taxonomy & term as well as select *multiple* post types and terms. Previous versions of the plugin only allowed post type OR taxonomy & term queries, not both.
20
 
21
  = Features & options =
22
 
23
  * Customizable widget title
24
+ * Get posts via post type(s) and/or taxonomy & term(s).
25
+ * Control the number of posts displayed and the number of posts to offset.
26
+ * Option to display the post feature image.
27
+ * Select the post feature image size to display from existing image sizes: thumbnail, medium, large, post-thumbnail or any size defined by the current theme.
28
+ * Order posts by: date, ID, title, menu order, random; and sort posts: ascending or descending.
29
+ * Each widget's output can be customized by user-defined templates added to the current theme folder.
30
 
31
 
32
  == Installation ==
38
  = To use a customized HTML output template =
39
 
40
  1. Create a folder called `flexible-posts-widget` in the root of your theme folder.
41
+ 1. Copy `widget.php` from within the plugin's `views` folder into your theme's new `flexible-posts-widget` folder.
42
  1. Optional: Rename your theme's `widget.php` template file to a name of your choice (to use different templates for each widget instance).
43
  1. Go to 'Appearance' > 'Widgets' in WordPress to configure an instance of the widget.
44
  1. In the 'Template Filename' field enter the name of the template file you added to your theme. Example: `my-themes-widget.php`
46
 
47
  == Frequently Asked Questions ==
48
 
49
+ = How can I style the images, titles or other widget output a certain way? =
50
+ FPW intentionally does NOT add any styling of it's own. To adjust the font size, color, alignment, image size, etc. of any output from this widget, you'll need to edit your theme's styles.
51
+
52
+ = Does this plugin/widget insert any styles or scripts into my site? =
53
+ FPW does NOT add styles or scripts to your public theme. The plugin is intentionally designed work within your existing theme. FPW does add one stylesheet and one JavaScript to Widgets page in wp-admin to help with the widget administration.
54
+
55
  = Questions, Support & Bug Reports =
56
  To get answers to your questions, request help or submit a bug report, please visit the forum: http://wordpress.org/tags/flexible-posts-widget/
57
 
58
 
59
  == Screenshots ==
60
 
61
+ 1. Configuring a Flexible Posts Widget in wp-admin with the Post Type tab displayed.
62
+ 1. Configuring a Flexible Posts Widget in wp-admin with the Taxonomy & Term tab displayed.
63
+ 1. An example of posts displayed using WordPress's TwentyTwelve theme and the default Feature Image (post-thumbnail) size. This demonstrates how the plugin looks out-of-the-box with no user-customized styling or output in a default theme.
64
+ 1. In the Wild: FPW displaying a selection of featured beers (Post Type: Brew) over at http://canalparkbrewery.com. This example uses slightly customized output and some theme-specific styles.
65
+ 1. In the wild: FPW displaying a selection media attachments, with custom thumbnails. This example uses highly customized HTML output and very theme-specific styles.
66
+ 1. In the wild: FPW displaying several posts over at http://chnl7700.mnsu.edu. Also highly customized output and theme styles.
67
 
68
  == Upgrade Notice ==
69
 
70
+ When upgrading from one major version to another (version 1.x to version 2.x to version 3.x, etc), please remember to verify your settings for any existing widgets. Not all settings combinations will be saved after a major release upgrade.
 
71
 
72
 
73
  == Other Notes ==
74
 
75
+ = Upgrading from one major version to another =
76
+ When upgrading between major releases (version 1.x to version 2.x to version 3.x, etc), please remember to verify your settings for any existing widgets. Not all settings combinations will be saved after a major release upgrade.
77
 
78
  = Default vs. Custom Templates =
79
 
80
+ FPW comes with a default template for the widget output. If you would like to alter the widget display code, create a new folder called `flexible-posts-widget` in your template directory and copy over the "views/widget.php" file.
81
 
82
  Edit the new file in your theme to your desired HTML layout. Please do not edit the one in the plugin folder as that will cause conflicts when you update the plugin to the latest release.
83
 
84
+ = Future updates & feature requests list =
85
 
 
86
  * Dynamically populate the "Template Filename" field based on the templates available.
87
  * Adjust widget output template for Media-type posts.
88
+ * Add shortcode functionality.
89
+ * Allow shortcode output to dynamically load more posts (AJAX-ified).
90
 
91
 
92
  == Changelog ==
93
 
94
+ = 3.0 =
95
+ * Allow widgets to query by post type and/or taxonomy & term instead of just one or the other. (Props: @vernal)
96
+ * Allow widgets to query by multiple post types and multiple terms within the same taxonomy. (Props: @vernal)
97
+ * Changed the list of available post types and taxonomies from every possible option to just those that are public.
98
+ * General UI enhancements for the widget admin.
99
+ * Some minor code cleanup and security improvements.
100
+
101
  = 2.1.1 =
102
+ * Fixed a source order bug in the widget.php template file. (Props: @carstenbach).
103
 
104
  = 2.1 =
105
  * Added offset parameter to display options.
125
  * Readme.txt updates
126
 
127
  = 1.0 =
128
+ * First public release
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
screenshot-6.png ADDED
Binary file
views/admin.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Flexible Posts Widget: Widget Admin Form
4
+ */
5
+
6
+ // Block direct requests
7
+ if ( !defined('ABSPATH') )
8
+ die('-1');
9
+
10
+ ?>
11
+ <div class="dpe-fp-widget">
12
+
13
+ <div class="section title">
14
+ <p>
15
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget title:'); ?></label>
16
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
17
+ </p>
18
+ </div>
19
+
20
+ <div class="section getemby">
21
+ <h4><?php _e('Get posts by'); ?></h4>
22
+ <div class="inside">
23
+
24
+ <div id="<?php echo $this->get_field_id('getemby'); ?>" class="categorydiv getembytabs">
25
+
26
+ <input id="<?php echo $this->get_field_id('cur_tab'); ?>" class="cur_tab" name="<?php echo $this->get_field_name('cur_tab'); ?>" type="hidden" value="<?php echo $cur_tab; ?>" />
27
+
28
+ <ul id="<?php echo $this->get_field_id('getemby-tabs'); ?>" class="category-tabs">
29
+ <li><a href="#<?php echo $this->get_field_id('getemby-pt'); ?>">Post Type</a></li>
30
+ <li><a href="#<?php echo $this->get_field_id('getemby-tt'); ?>">Taxonomy &amp; Term</a></li>
31
+ </ul>
32
+
33
+ <div id="<?php echo $this->get_field_id('getemby-pt'); ?>" class="tabs-panel pt">
34
+ <?php $this->posttype_checklist( $posttype ); ?>
35
+ </div><!-- .pt.getemby -->
36
+
37
+ <div id="<?php echo $this->get_field_id('getemby-tt'); ?>" class="tabs-panel tt" style="display:none;">
38
+ <p>
39
+ <label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Select a taxonomy:'); ?></label>
40
+ <select class="widefat dpe-fp-taxonomy" name="<?php echo $this->get_field_name('taxonomy'); ?>" id="<?php echo $this->get_field_id('taxonomy'); ?>">
41
+ <option value="none" <?php echo 'none' == $taxonomy ? ' selected="selected"' : ''; ?>>Ignore Taxonomy &amp; Term</option>
42
+ <?php
43
+ foreach ($this->taxonomies as $option) {
44
+ echo '<option value="' . $option->name . '"', $taxonomy == $option->name ? ' selected="selected"' : '', '>', $option->label, '</option>';
45
+ }
46
+ ?>
47
+ </select>
48
+ </p>
49
+ <label <?php echo 'none' == $taxonomy ? ' style="display:none;"' : ''; ?>><?php _e('Select terms:'); ?></label>
50
+ <div class="terms" <?php echo 'none' == $taxonomy ? ' style="display:none;"' : ''; ?>>
51
+ <?php
52
+ if ( !empty($taxonomy) && 'none' != $taxonomy ) {
53
+
54
+ $args = array (
55
+ 'hide_empty' => 0,
56
+ );
57
+
58
+ $terms = get_terms( $taxonomy, $args );
59
+
60
+ if( !empty( $terms ) ) {
61
+ $output .= '<ul class="categorychecklist termschecklist form-no-clear">';
62
+ foreach ( $terms as $option ) {
63
+ $output .= "\n<li>" . '<label class="selectit"><input value="' . esc_attr( $option->slug ) . '" type="checkbox" name="' . $this->get_field_name('term') . '[]"' . checked( in_array( $option->slug, (array)$term ), true, false ) . ' /> ' . esc_html( $option->name ) . "</label></li>\n";
64
+ }
65
+ $output .= "</ul>\n";
66
+ } else {
67
+ $output = '<p>No terms found.</p>';
68
+ }
69
+
70
+ echo ( $output );
71
+ }
72
+ ?>
73
+ </div>
74
+ </div><!-- .tt.getemby -->
75
+
76
+ </div><!-- #<?php echo $this->get_field_id('getemby'); ?> -->
77
+
78
+ </div><!-- .inside -->
79
+
80
+ </div>
81
+
82
+ <div class="section display">
83
+ <h4>Display options</h4>
84
+ <p class="cf">
85
+ <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
86
+ <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" />
87
+ </p>
88
+ <p class="cf">
89
+ <label for="<?php echo $this->get_field_id('offset'); ?>"><?php _e('Number of posts to skip:'); ?></label>
90
+ <input id="<?php echo $this->get_field_id('offset'); ?>" name="<?php echo $this->get_field_name('offset'); ?>" type="text" value="<?php echo $offset; ?>" />
91
+ </p>
92
+ <p class="cf">
93
+ <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e('Order posts by:'); ?></label>
94
+ <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>">
95
+ <?php
96
+ foreach ( $this->orderbys as $key => $value ) {
97
+ echo '<option value="' . $key . '" id="' . $this->get_field_id( $key ) . '"', $orderby == $key ? ' selected="selected"' : '', '>', $value, '</option>';
98
+ }
99
+ ?>
100
+ </select>
101
+ </p>
102
+ <p class="cf">
103
+ <label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order:'); ?></label>
104
+ <select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>">
105
+ <?php
106
+ foreach ( $this->orders as $key => $value ) {
107
+ echo '<option value="' . $key . '" id="' . $this->get_field_id( $key ) . '"', $order == $key ? ' selected="selected"' : '', '>', $value, '</option>';
108
+ }
109
+ ?>
110
+ </select>
111
+ </p>
112
+ </div>
113
+
114
+ <div class="section thumbnails">
115
+ <p style="margin-top:1.33em;">
116
+ <input class="dpe-fp-thumbnail" id="<?php echo $this->get_field_id('thumbnail'); ?>" name="<?php echo $this->get_field_name('thumbnail'); ?>" type="checkbox" value="1" <?php checked( '1', $thumbnail ); ?>/>
117
+ <label style="font-weight:bold;" for="<?php echo $this->get_field_id('thumbnail'); ?>"><?php _e('Display thumbnails?'); ?></label>
118
+ </p>
119
+ <p <?php echo $thumbnail ? '' : 'style="display:none;"'?> class="thumb-size">
120
+ <label for="<?php echo $this->get_field_id('thumbsize'); ?>"><?php _e('Select a thumbnail size to show:'); ?></label>
121
+ <select class="widefat" name="<?php echo $this->get_field_name('thumbsize'); ?>" id="<?php echo $this->get_field_id('thumbsize'); ?>">
122
+ <?php
123
+ foreach ($this->thumbsizes as $option) {
124
+ echo '<option value="' . $option . '" id="' . $this->get_field_id( $option ) . '"', $thumbsize == $option ? ' selected="selected"' : '', '>', $option, '</option>';
125
+ }
126
+ ?>
127
+ </select>
128
+ </p>
129
+ </div>
130
+
131
+ <div class="section template">
132
+ <p style="margin:1.33em 0;">
133
+ <label for="<?php echo $this->get_field_id('template'); ?>"><?php _e('Template filename:'); ?></label>
134
+ <input id="<?php echo $this->get_field_id('template'); ?>" name="<?php echo $this->get_field_name('template'); ?>" type="text" value="<?php echo $template; ?>" />
135
+ <br />
136
+ <span style="padding-top:3px;" class="description"><a target="_blank" href="http://wordpress.org/extend/plugins/flexible-posts-widget/other_notes/">See documentation</a> for details.</span>
137
+ </p>
138
+ </div>
139
+
140
+ </div><!-- .dpe-fp-widget -->
views/widget.php CHANGED
@@ -13,10 +13,9 @@ if ( !empty($title) )
13
  echo $before_title . $title . $after_title;
14
 
15
  if( $flexible_posts->have_posts() ):
16
-
17
  ?>
18
  <ul class="dpe-flexible-posts">
19
- <?php while ( $flexible_posts->have_posts() ) : $flexible_posts->the_post(); ?>
20
  <li id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
21
  <a href="<?php echo the_permalink(); ?>">
22
  <?php
13
  echo $before_title . $title . $after_title;
14
 
15
  if( $flexible_posts->have_posts() ):
 
16
  ?>
17
  <ul class="dpe-flexible-posts">
18
+ <?php while( $flexible_posts->have_posts() ) : $flexible_posts->the_post(); ?>
19
  <li id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
20
  <a href="<?php echo the_permalink(); ?>">
21
  <?php