Version Description
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.
=
Download this release
Release Info
Developer | dpe415 |
Plugin | Flexible Posts Widget |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 2.0
- flexible-posts-widget.js +0 -8
- flexible-posts-widget.php +210 -80
- js/admin.js +69 -0
- readme.txt +28 -9
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
flexible-posts-widget.js
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* Flexible Posts Widget
|
3 |
-
* Admin Scripts
|
4 |
-
* Author: dpe415
|
5 |
-
* URI: http://wordpress.org/extend/plugins/flexible-posts-widget/
|
6 |
-
*/
|
7 |
-
|
8 |
-
// Nothing here yet...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flexible-posts-widget.php
CHANGED
@@ -4,13 +4,35 @@ 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:
|
8 |
Description: An advanced posts display widget with many options: post by taxonomy & term or post type, thumbnails, order & order by, customizable templates
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
// Block direct requests
|
12 |
-
if
|
13 |
die('-1');
|
|
|
|
|
|
|
|
|
14 |
|
15 |
// Load the widget on widgets_init
|
16 |
function dpe_load_flexible_posts_widget() {
|
@@ -18,43 +40,60 @@ function dpe_load_flexible_posts_widget() {
|
|
18 |
}
|
19 |
add_action('widgets_init', 'dpe_load_flexible_posts_widget');
|
20 |
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* Flexible Posts Widget Class
|
23 |
*/
|
|
|
24 |
class DPE_Flexible_Posts_Widget extends WP_Widget {
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
parent::WP_Widget(false, $name = 'Flexible Posts Widget');
|
30 |
-
//$this->register_sns();
|
31 |
-
/*
|
32 |
global $pagenow;
|
|
|
|
|
33 |
if (defined("WP_ADMIN") && WP_ADMIN) {
|
34 |
if ( 'widgets.php' == $pagenow ) {
|
35 |
-
wp_enqueue_script( 'dpe-
|
36 |
}
|
37 |
}
|
38 |
-
*/
|
39 |
-
}
|
40 |
|
41 |
-
|
42 |
-
$dir = plugins_url('/', __FILE__);
|
43 |
-
wp_register_script( 'dpe-flexible-posts-widget', $dir . 'flexible-posts-widget.js', array('jquery','thickbox'), false, true );
|
44 |
}
|
45 |
|
46 |
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
function widget($args, $instance) {
|
49 |
extract( $args );
|
50 |
extract( $instance );
|
51 |
$title = apply_filters( 'widget_title', empty( $title ) ? '' : $title );
|
52 |
|
53 |
if( empty($template) )
|
54 |
-
$template = 'widget';
|
55 |
|
56 |
// Setup our query
|
57 |
-
if(
|
58 |
$args = array(
|
59 |
'tax_query' => array(
|
60 |
array(
|
@@ -89,11 +128,21 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
|
|
89 |
|
90 |
}
|
91 |
|
92 |
-
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
function update($new_instance, $old_instance) {
|
94 |
global $posttypes;
|
95 |
$instance = $old_instance;
|
96 |
$instance['title'] = strip_tags( $new_instance['title'] );
|
|
|
97 |
$instance['posttype'] = $new_instance['posttype'];
|
98 |
$instance['taxonomy'] = $new_instance['taxonomy'];
|
99 |
$instance['term'] = strip_tags( $new_instance['term'] );
|
@@ -106,84 +155,105 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
|
|
106 |
return $instance;
|
107 |
}
|
108 |
|
109 |
-
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
function form($instance) {
|
111 |
|
|
|
112 |
$posttypes = get_post_types('', 'objects');
|
113 |
-
$taxonomies = get_taxonomies('', 'objects');
|
114 |
$orderbys = array( 'ID', 'title', 'date', 'rand', 'menu_order', );
|
115 |
$orders = array( 'ASC', 'DESC', );
|
116 |
$thumb_sizes = get_intermediate_image_sizes();
|
117 |
|
118 |
$instance = wp_parse_args( (array) $instance, array(
|
119 |
'title' => '',
|
|
|
120 |
'posttype' => 'post',
|
121 |
-
'taxonomy' => '',
|
122 |
'term' => '',
|
123 |
-
'number' => '',
|
124 |
'orderby' => 'date',
|
125 |
'order' => 'DESC',
|
126 |
'thumbnail' => false,
|
127 |
'thumbsize' => '',
|
128 |
-
'template' => 'widget',
|
129 |
) );
|
130 |
|
131 |
extract( $instance );
|
132 |
|
133 |
?>
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
</p>
|
138 |
-
<h4 style="
|
139 |
-
<p><strong>By taxonomy & term</strong></p>
|
140 |
-
<p>
|
141 |
-
<label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Select a taxonomy'); ?></label>
|
142 |
-
<select class="widefat" name="<?php echo $this->get_field_name('taxonomy'); ?>" id="<?php echo $this->get_field_id('taxonomy'); ?>">
|
143 |
-
<?php
|
144 |
-
foreach ($taxonomies as $option) {
|
145 |
-
echo '<option value="' . $option->name . '" id="' . $option->name . '"', $taxonomy == $option->name ? ' selected="selected"' : '', '>', $option->name, '</option>';
|
146 |
-
}
|
147 |
-
?>
|
148 |
-
</select>
|
149 |
-
</p>
|
150 |
<p>
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
<hr style="margin-bottom:12px; border:none; border-bottom:1px solid #dfdfdf" />
|
156 |
-
<p><strong>By post type:</strong></p>
|
157 |
-
<p>
|
158 |
-
<label for="<?php echo $this->get_field_id('posttype'); ?>"><?php _e('Post type'); ?></label>
|
159 |
-
<select class="widefat" name="<?php echo $this->get_field_name('posttype'); ?>" id="<?php echo $this->get_field_id('posttype'); ?>">
|
160 |
-
<?php
|
161 |
-
foreach ($posttypes as $option) {
|
162 |
-
echo '<option value="' . $option->name . '" id="' . $option->name . '"', $posttype == $option->name ? ' selected="selected"' : '', '>', $option->name, '</option>';
|
163 |
-
}
|
164 |
-
?>
|
165 |
-
</select>
|
166 |
-
<span style="padding-top:3px;" class="description">Ignored if a term is provided.</span>
|
167 |
</p>
|
168 |
-
|
169 |
-
<
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
<p>
|
174 |
-
<
|
175 |
-
<
|
176 |
</p>
|
177 |
-
<p>
|
178 |
-
<label for="<?php echo $this->get_field_id('thumbsize'); ?>"><?php _e('Select a thumbnail size to show'); ?></label>
|
179 |
-
<select class="widefat" name="<?php echo $this->get_field_name('thumbsize'); ?>" id="<?php echo $this->get_field_id('thumbsize'); ?>">
|
180 |
-
<?php
|
181 |
-
foreach ($thumb_sizes as $option) {
|
182 |
-
echo '<option value="' . $option . '" id="' . $option . '"', $thumbsize == $option ? ' selected="selected"' : '', '>', $option, '</option>';
|
183 |
-
}
|
184 |
-
?>
|
185 |
-
</select>
|
186 |
-
</p>
|
187 |
<p>
|
188 |
<label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e('Order post by:'); ?></label>
|
189 |
<select class="widefat" name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>">
|
@@ -199,17 +269,36 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
|
|
199 |
<select class="widefat" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>">
|
200 |
<?php
|
201 |
foreach ($orders as $option) {
|
202 |
-
echo '<option value="' . $option . '"
|
203 |
}
|
204 |
?>
|
205 |
</select>
|
206 |
-
<br
|
|
|
207 |
</p>
|
208 |
-
<
|
209 |
-
|
210 |
-
<input id="<?php echo $this->get_field_id('
|
211 |
-
|
212 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
<?php
|
214 |
}
|
215 |
|
@@ -226,21 +315,62 @@ class DPE_Flexible_Posts_Widget extends WP_Widget {
|
|
226 |
* @return template path
|
227 |
**/
|
228 |
|
229 |
-
function getTemplateHierarchy($template) {
|
|
|
230 |
// whether or not .php was added
|
231 |
-
$template_slug = rtrim($template, '.php');
|
232 |
$template = $template_slug . '.php';
|
233 |
|
234 |
-
if ( $theme_file = locate_template(array('flexible-posts-widget/'
|
235 |
$file = $theme_file;
|
236 |
} else {
|
237 |
$file = 'views/' . $template;
|
238 |
}
|
|
|
239 |
//return apply_filters( 'dpe_template_flexible-posts_'.$template, $file); // - Maybe we'll add this in the future
|
|
|
240 |
return $file;
|
|
|
241 |
}
|
242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
|
244 |
} // class DPE_Flexible_Posts_Widget
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
?>
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/flexible-posts-widget/
|
5 |
Author: dpe415
|
6 |
Author URI: http://dpedesign.com
|
7 |
+
Version: 2.0
|
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
|
17 |
+
published by the Free Software Foundation.
|
18 |
+
|
19 |
+
This program is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
23 |
+
|
24 |
+
You should have received a copy of the GNU General Public License
|
25 |
+
along with this program; if not, write to the Free Software
|
26 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
28 |
|
29 |
// Block direct requests
|
30 |
+
if( !defined('ABSPATH') )
|
31 |
die('-1');
|
32 |
+
|
33 |
+
if( !defined('DPE_FP_Version') )
|
34 |
+
define( 'DPE_FP_Version', '2.0' );
|
35 |
+
|
36 |
|
37 |
// Load the widget on widgets_init
|
38 |
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 |
+
/**
|
54 |
+
* Register widget with WordPress.
|
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 |
|
78 |
|
79 |
+
/**
|
80 |
+
* Front-end display of widget.
|
81 |
+
*
|
82 |
+
* @see WP_Widget::widget()
|
83 |
+
*
|
84 |
+
* @param array $args Widget arguments.
|
85 |
+
* @param array $instance Saved values from database.
|
86 |
+
*/
|
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(
|
128 |
|
129 |
}
|
130 |
|
131 |
+
/**
|
132 |
+
* Sanitize widget form values as they are saved.
|
133 |
+
*
|
134 |
+
* @see WP_Widget::update()
|
135 |
+
*
|
136 |
+
* @param array $new_instance Values just sent to be saved.
|
137 |
+
* @param array $old_instance Previously saved values from database.
|
138 |
+
*
|
139 |
+
* @return array Updated safe values to be saved.
|
140 |
+
*/
|
141 |
function update($new_instance, $old_instance) {
|
142 |
global $posttypes;
|
143 |
$instance = $old_instance;
|
144 |
$instance['title'] = strip_tags( $new_instance['title'] );
|
145 |
+
$instance['getemby'] = $new_instance['getemby'];
|
146 |
$instance['posttype'] = $new_instance['posttype'];
|
147 |
$instance['taxonomy'] = $new_instance['taxonomy'];
|
148 |
$instance['term'] = strip_tags( $new_instance['term'] );
|
155 |
return $instance;
|
156 |
}
|
157 |
|
158 |
+
/**
|
159 |
+
* Back-end widget form.
|
160 |
+
*
|
161 |
+
* @see WP_Widget::form()
|
162 |
+
*
|
163 |
+
* @param array $instance Previously saved values from database.
|
164 |
+
*/
|
165 |
function form($instance) {
|
166 |
|
167 |
+
$getembies = array( 'tnt', 'pt' );
|
168 |
$posttypes = get_post_types('', 'objects');
|
169 |
+
$taxonomies = get_taxonomies('', 'objects');
|
170 |
$orderbys = array( 'ID', 'title', 'date', 'rand', 'menu_order', );
|
171 |
$orders = array( 'ASC', 'DESC', );
|
172 |
$thumb_sizes = get_intermediate_image_sizes();
|
173 |
|
174 |
$instance = wp_parse_args( (array) $instance, array(
|
175 |
'title' => '',
|
176 |
+
'getemby' => 'tnt',
|
177 |
'posttype' => 'post',
|
178 |
+
'taxonomy' => 'category',
|
179 |
'term' => '',
|
180 |
+
'number' => '3',
|
181 |
'orderby' => 'date',
|
182 |
'order' => 'DESC',
|
183 |
'thumbnail' => false,
|
184 |
'thumbsize' => '',
|
185 |
+
'template' => 'widget.php',
|
186 |
) );
|
187 |
|
188 |
extract( $instance );
|
189 |
|
190 |
?>
|
191 |
+
<p>
|
192 |
+
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:'); ?></label>
|
193 |
+
<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; ?>" />
|
194 |
</p>
|
195 |
+
<h4 style="margin-bottom:.2em;"><label for="<?php echo $this->get_field_id('getemby'); ?>"><?php _e('Get posts by:'); ?></label></strong></h4>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
<p>
|
197 |
+
<select class="widefat dpe-fp-getemby" name="<?php echo $this->get_field_name('getemby'); ?>" id="<?php echo $this->get_field_id('getemby'); ?>">
|
198 |
+
<option value="tnt"<?php echo $getemby == 'tnt' ? ' selected="selected"' : ''?>>Taxonomy & Term</option>
|
199 |
+
<option value="pt"<?php echo $getemby == 'pt' ? ' selected="selected"' : ''?>>Post Type</option>
|
200 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
</p>
|
202 |
+
|
203 |
+
<div id="<?php echo $this->get_field_id('tnt-box'); ?>" class="getembies tnt" <?php echo $getemby == 'tnt' ? '' : 'style="display:none;"'?>>
|
204 |
+
<p>
|
205 |
+
<label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Select a taxonomy:'); ?></label>
|
206 |
+
<select class="widefat dpe-fp-taxonomy" name="<?php echo $this->get_field_name('taxonomy'); ?>" id="<?php echo $this->get_field_id('taxonomy'); ?>">
|
207 |
+
<?php
|
208 |
+
foreach ($taxonomies as $option) {
|
209 |
+
echo '<option value="' . $option->name . '"', $taxonomy == $option->name ? ' selected="selected"' : '', '>', $option->label, '</option>';
|
210 |
+
}
|
211 |
+
?>
|
212 |
+
</select>
|
213 |
+
</p>
|
214 |
+
<p>
|
215 |
+
<label for="<?php echo $this->get_field_id('term'); ?>"><?php _e('Select a term:'); ?></label>
|
216 |
+
<select class="widefat dpe-fp-term" name="<?php echo $this->get_field_name('term'); ?>" id="<?php echo $this->get_field_id('term'); ?>">
|
217 |
+
<option value="-1">Please select...</option>
|
218 |
+
<?php
|
219 |
+
if( $taxonomy ) {
|
220 |
+
$args = array (
|
221 |
+
'hide_empty' => 0,
|
222 |
+
);
|
223 |
+
|
224 |
+
$terms = get_terms( $taxonomy, $args );
|
225 |
+
|
226 |
+
if( !empty($terms) ) {
|
227 |
+
$output = '';
|
228 |
+
foreach ( $terms as $option )
|
229 |
+
$output .= '<option value="' . $option->slug . '"' . ( $term == $option->slug ? ' selected="selected"' : '' ) . '>' . $option->name . '</option>';
|
230 |
+
echo( $output );
|
231 |
+
}
|
232 |
+
}
|
233 |
+
?>
|
234 |
+
</select>
|
235 |
+
</p>
|
236 |
+
</div><!-- .tnt.getemby -->
|
237 |
+
|
238 |
+
<div id="<?php echo $this->get_field_id('pt-box'); ?>" class="getembies pt" <?php echo $getemby == 'pt' ? '' : 'style="display:none;"'?>>
|
239 |
+
<p>
|
240 |
+
<label for="<?php echo $this->get_field_id('posttype'); ?>"><?php _e('Select a post type:'); ?></label>
|
241 |
+
<select class="widefat" name="<?php echo $this->get_field_name('posttype'); ?>" id="<?php echo $this->get_field_id('posttype'); ?>">
|
242 |
+
<?php
|
243 |
+
foreach ($posttypes as $option) {
|
244 |
+
echo '<option value="' . $option->name . '"', $posttype == $option->name ? ' selected="selected"' : '', '>', $option->labels->name, '</option>';
|
245 |
+
}
|
246 |
+
?>
|
247 |
+
</select>
|
248 |
+
</p>
|
249 |
+
</div><!-- .pt.getemby -->
|
250 |
+
|
251 |
+
<hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
|
252 |
+
<h4 style="">Display options</h4>
|
253 |
<p>
|
254 |
+
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
|
255 |
+
<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;" />
|
256 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
<p>
|
258 |
<label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e('Order post by:'); ?></label>
|
259 |
<select class="widefat" name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>">
|
269 |
<select class="widefat" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>">
|
270 |
<?php
|
271 |
foreach ($orders as $option) {
|
272 |
+
echo '<option value="' . $option . '"', $order == $option ? ' selected="selected"' : '', '>', $option, '</option>';
|
273 |
}
|
274 |
?>
|
275 |
</select>
|
276 |
+
<br />
|
277 |
+
<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>
|
278 |
</p>
|
279 |
+
<hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
|
280 |
+
<p style="margin-top:1.33em;">
|
281 |
+
<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 ); ?>/>
|
282 |
+
<label style="font-weight:bold;" for="<?php echo $this->get_field_id('thumbnail'); ?>"><?php _e('Display thumbnails?'); ?></label>
|
283 |
</p>
|
284 |
+
<p <?php echo $thumbnail == '1' ? '' : 'style="display:none;"'?> class="thumb-size">
|
285 |
+
<label for="<?php echo $this->get_field_id('thumbsize'); ?>"><?php _e('Select a thumbnail size to show:'); ?></label>
|
286 |
+
<select class="widefat" name="<?php echo $this->get_field_name('thumbsize'); ?>" id="<?php echo $this->get_field_id('thumbsize'); ?>">
|
287 |
+
<?php
|
288 |
+
foreach ($thumb_sizes as $option) {
|
289 |
+
echo '<option value="' . $option . '" id="' . $option . '"', $thumbsize == $option ? ' selected="selected"' : '', '>', $option, '</option>';
|
290 |
+
}
|
291 |
+
?>
|
292 |
+
</select>
|
293 |
+
</p>
|
294 |
+
<hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
|
295 |
+
<p style="margin:1.33em 0;">
|
296 |
+
<label for="<?php echo $this->get_field_id('template'); ?>"><?php _e('Template filename:'); ?></label>
|
297 |
+
<input id="<?php echo $this->get_field_id('template'); ?>" name="<?php echo $this->get_field_name('template'); ?>" type="text" value="<?php echo $template; ?>" />
|
298 |
+
<br />
|
299 |
+
<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>
|
300 |
+
</p>
|
301 |
+
<hr style="margin-bottom:1.33em; border:none; border-bottom:1px solid #dfdfdf;" />
|
302 |
<?php
|
303 |
}
|
304 |
|
315 |
* @return template path
|
316 |
**/
|
317 |
|
318 |
+
function getTemplateHierarchy( $template ) {
|
319 |
+
|
320 |
// whether or not .php was added
|
321 |
+
$template_slug = rtrim( $template, '.php' );
|
322 |
$template = $template_slug . '.php';
|
323 |
|
324 |
+
if ( $theme_file = locate_template( array( 'flexible-posts-widget/' . $template ) ) ) {
|
325 |
$file = $theme_file;
|
326 |
} else {
|
327 |
$file = 'views/' . $template;
|
328 |
}
|
329 |
+
|
330 |
//return apply_filters( 'dpe_template_flexible-posts_'.$template, $file); // - Maybe we'll add this in the future
|
331 |
+
|
332 |
return $file;
|
333 |
+
|
334 |
}
|
335 |
+
|
336 |
+
// Register styles & scripts
|
337 |
+
function register_sns() {
|
338 |
+
$dir = plugins_url('/', __FILE__);
|
339 |
+
wp_register_script( 'dpe-fp-widget', $dir . 'js/admin.js', array('jquery'), DPE_FP_Version, true );
|
340 |
+
}
|
341 |
+
|
342 |
|
343 |
} // class DPE_Flexible_Posts_Widget
|
344 |
|
345 |
+
|
346 |
+
// return a list of terms for the chosen taxonomy used via AJAX
|
347 |
+
function dpe_fp_term_me() {
|
348 |
+
|
349 |
+
$taxonomy = esc_attr( $_POST['taxonomy'] );
|
350 |
+
$term = esc_attr( $_POST['term'] );
|
351 |
+
|
352 |
+
if( empty($taxonomy) )
|
353 |
+
echo false;
|
354 |
+
|
355 |
+
$args = array (
|
356 |
+
'hide_empty' => 0,
|
357 |
+
);
|
358 |
+
|
359 |
+
$terms = get_terms( $taxonomy, $args );
|
360 |
+
|
361 |
+
if( empty($terms) ) {
|
362 |
+
$output = '<option value="-1">No terms found...</option>';
|
363 |
+
} else {
|
364 |
+
$output = '<option value="-1">Please select...</option>';
|
365 |
+
foreach ( $terms as $option ) {
|
366 |
+
$output .= '<option value="' . $option->slug . '"' . ( $term == $option->slug ? ' selected="selected"' : '' ) . '>' . $option->name . '</option>';
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
echo( $output );
|
371 |
+
|
372 |
+
die();
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
?>
|
js/admin.js
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* Flexible Posts Widget
|
3 |
+
* Admin Scripts
|
4 |
+
* Author: dpe415
|
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() {
|
19 |
+
if( this.checked ) {
|
20 |
+
jQuery(this).parent().next().slideDown('fast');
|
21 |
+
} else {
|
22 |
+
jQuery(this).parent().next().slideUp('fast');
|
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 {
|
41 |
+
jQuery(this).parent().next().slideUp('fast');
|
42 |
+
}
|
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 |
+
});
|
readme.txt
CHANGED
@@ -4,13 +4,18 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: widget, widgets, posts, recent posts, thumbnails, custom post types, custom taxonomies
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.3.2
|
7 |
-
Stable tag:
|
|
|
|
|
8 |
|
9 |
An advanced posts display widget with many options. Display posts in your sidebars exactly the way you like!
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
The default WordPress Recent Posts widget is exceptionally basic. I found myself always in need of a
|
|
|
|
|
|
|
14 |
|
15 |
= Features & options =
|
16 |
|
@@ -20,22 +25,22 @@ The default WordPress Recent Posts widget is exceptionally basic. I found myself
|
|
20 |
* Option to display the post thumbnail (feature image).
|
21 |
* Select the post thumbnail size to display from available image sizes.
|
22 |
* Select the sort orderby: Date, ID, Title, Menu Order, Random and sort order: ASC or DESC.
|
23 |
-
* The widget's HTML output can be customized by user-defined templates
|
24 |
|
25 |
|
26 |
== Installation ==
|
27 |
|
28 |
1. Upload the `flexible-posts-widget` folder to the `/wp-content/plugins/` directory.
|
29 |
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
30 |
-
1. Go to 'Appearance' > 'Widgets' and place the widget into a sidebar to
|
31 |
|
32 |
= To use a customized HTML output template =
|
33 |
|
34 |
1. Create a folder called `flexible-posts-widget` in the root of your theme folder.
|
35 |
1. Copy `widget.php` from within this plugin's `views` folder into your theme's new `flexible-posts-widget` folder.
|
36 |
-
1. Optional: Rename your theme's `widget.php` template file to a name of your choice.
|
37 |
1. Go to 'Appearance' > 'Widgets' in WordPress to configure an instance of the widget.
|
38 |
-
1. In the 'Template Filename' field enter the name of the template file you added to your theme
|
39 |
|
40 |
|
41 |
== Frequently Asked Questions ==
|
@@ -46,12 +51,21 @@ To get answers to your questions, request help or submit a bug report, please vi
|
|
46 |
|
47 |
== Screenshots ==
|
48 |
|
49 |
-
1. Flexible Posts Widget admin screen.
|
|
|
50 |
1. Example Flexible Posts Widget showing the post thumbnail and title wrapped in a link to the post.
|
51 |
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
== Other Notes ==
|
54 |
|
|
|
|
|
|
|
55 |
= Default vs. Custom Templates =
|
56 |
|
57 |
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.
|
@@ -61,14 +75,19 @@ Edit the new file in your theme to your desired HTML layout. Please do not edit
|
|
61 |
= Future updates & features list =
|
62 |
|
63 |
* Create shortcode functionality
|
64 |
-
* Dynamically populate available terms based on a selected taxonomy.
|
65 |
-
* Make the "Get Posts By" section selectable and only show the chosen method: Taxonomy & Term or Post Type.
|
66 |
* Dynamically populate the "Template Filename" field based on the templates available.
|
|
|
67 |
* Add default styles for the widget display & an option to load or not load them (?)
|
68 |
|
69 |
|
70 |
== Changelog ==
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
= 1.0.5 =
|
73 |
* Bug fix - Removed post_status 'private' from wp_queries. We don't want to show private posts in our loops.
|
74 |
|
4 |
Tags: widget, widgets, posts, recent posts, thumbnails, custom post types, custom taxonomies
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.3.2
|
7 |
+
Stable tag: 2.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 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 |
|
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 ==
|
32 |
|
33 |
1. Upload the `flexible-posts-widget` folder to the `/wp-content/plugins/` directory.
|
34 |
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
35 |
+
1. Go to 'Appearance' > 'Widgets' and place the widget into a sidebar to configure it.
|
36 |
|
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`
|
44 |
|
45 |
|
46 |
== Frequently Asked Questions ==
|
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.
|
75 |
= Future updates & features list =
|
76 |
|
77 |
* Create shortcode functionality
|
|
|
|
|
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.0 =
|
86 |
+
* *Upgrade notice:* When upgrading from v1.x.x to v2.x, remember to double-check the settings for any existing widgets.
|
87 |
+
* Dynamically populate available terms based on selected taxonomy.
|
88 |
+
* Make the "Get Posts By" section selectable and only show the chosen method: Taxonomy & Term or Post Type.
|
89 |
+
* Miscellaneous admin improvements.
|
90 |
+
|
91 |
= 1.0.5 =
|
92 |
* Bug fix - Removed post_status 'private' from wp_queries. We don't want to show private posts in our loops.
|
93 |
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
ADDED
Binary file
|