Version Description
- Please consider to re-configure the widget as the latest version has numerous changes from previous.
- Version 4.0 uses CSS file for styling the widget in front end.
- Version 3.0 or later version uses WordPress 2.9's built in post thumbnail functionality.
Download this release
Release Info
Developer | Kometschuh |
Plugin | Category Posts Widget |
Version | 4.1.3 |
Comparing to | |
See all releases |
Code changes from version 4.1.2 to 4.1.3
- cat-posts.css +41 -41
- cat-posts.php +364 -352
- readme.txt +21 -11
cat-posts.css
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
/*
|
2 |
-
Default CSS Styles for the Category Posts Widget plugin
|
3 |
-
Version: 4.1.
|
4 |
-
*/
|
5 |
-
.cat-post-current,
|
6 |
-
.cat-post-date,
|
7 |
-
.cat-post-comment-num {
|
8 |
-
font-size: 12px;
|
9 |
-
line-height: 18px;
|
10 |
-
}
|
11 |
-
.cat-post-title {
|
12 |
-
font-size: 15px;
|
13 |
-
}
|
14 |
-
.cat-post-current a {
|
15 |
-
font-weight: bold;
|
16 |
-
text-transform: uppercase;
|
17 |
-
}
|
18 |
-
.cat-post-date {
|
19 |
-
font-style: italic;
|
20 |
-
margin-bottom: 0;
|
21 |
-
}
|
22 |
-
.cat-post-thumbnail img {
|
23 |
-
float: left;
|
24 |
-
margin: 5px 10px 5px 0;
|
25 |
-
}
|
26 |
-
.cat-post-item {
|
27 |
-
border-bottom: 1px solid #ccc;
|
28 |
-
list-style: none;
|
29 |
-
list-style-type: none;
|
30 |
-
margin: 3px 0;
|
31 |
-
padding: 3px 0;
|
32 |
-
}
|
33 |
-
.cat-post-item:before,
|
34 |
-
.cat-post-item:after {
|
35 |
-
content: "";
|
36 |
-
display: table;
|
37 |
-
clear: both;
|
38 |
-
}
|
39 |
-
.cat-post-item:last-child {
|
40 |
-
border-bottom: none;
|
41 |
-
}
|
1 |
+
/*
|
2 |
+
Default CSS Styles for the Category Posts Widget plugin
|
3 |
+
Version: 4.1.3
|
4 |
+
*/
|
5 |
+
.cat-post-current,
|
6 |
+
.cat-post-date,
|
7 |
+
.cat-post-comment-num {
|
8 |
+
font-size: 12px;
|
9 |
+
line-height: 18px;
|
10 |
+
}
|
11 |
+
.cat-post-title {
|
12 |
+
font-size: 15px;
|
13 |
+
}
|
14 |
+
.cat-post-current a {
|
15 |
+
font-weight: bold;
|
16 |
+
text-transform: uppercase;
|
17 |
+
}
|
18 |
+
.cat-post-date {
|
19 |
+
font-style: italic;
|
20 |
+
margin-bottom: 0;
|
21 |
+
}
|
22 |
+
.cat-post-thumbnail img {
|
23 |
+
float: left;
|
24 |
+
margin: 5px 10px 5px 0;
|
25 |
+
}
|
26 |
+
.cat-post-item {
|
27 |
+
border-bottom: 1px solid #ccc;
|
28 |
+
list-style: none;
|
29 |
+
list-style-type: none;
|
30 |
+
margin: 3px 0;
|
31 |
+
padding: 3px 0;
|
32 |
+
}
|
33 |
+
.cat-post-item:before,
|
34 |
+
.cat-post-item:after {
|
35 |
+
content: "";
|
36 |
+
display: table;
|
37 |
+
clear: both;
|
38 |
+
}
|
39 |
+
.cat-post-item:last-child {
|
40 |
+
border-bottom: none;
|
41 |
+
}
|
cat-posts.php
CHANGED
@@ -1,352 +1,364 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Category Posts Widget
|
4 |
-
Plugin URI: http://mkrdip.me/category-posts-widget
|
5 |
-
Description: Adds a widget that shows the most recent posts from a single category.
|
6 |
-
Author: Mrinal Kanti Roy
|
7 |
-
Version: 4.1.
|
8 |
-
Author URI: http://mkrdip.me
|
9 |
-
*/
|
10 |
-
|
11 |
-
// Don't call the file directly
|
12 |
-
if ( !defined( 'ABSPATH' ) ) exit;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Register our styles
|
16 |
-
*
|
17 |
-
* @return void
|
18 |
-
*/
|
19 |
-
add_action( 'wp_enqueue_scripts', 'category_posts_widget_styles' );
|
20 |
-
|
21 |
-
function category_posts_widget_styles() {
|
22 |
-
wp_register_style( 'category-posts', plugins_url( 'category-posts/cat-posts.css' ) );
|
23 |
-
wp_enqueue_style( 'category-posts' );
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Register thumbnail sizes.
|
28 |
-
*
|
29 |
-
* @return void
|
30 |
-
*/
|
31 |
-
function category_posts_add_image_size(){
|
32 |
-
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
33 |
-
|
34 |
-
if ( $sizes ){
|
35 |
-
foreach ( $sizes as $id=>$size ) {
|
36 |
-
add_image_size( 'cat_post_thumb_size' . $id, $size[0], $size[1], true );
|
37 |
-
}
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
add_action( 'init', 'category_posts_add_image_size' );
|
42 |
-
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Category Posts Widget Class
|
46 |
-
*
|
47 |
-
* Shows the single category posts with some configurable options
|
48 |
-
*/
|
49 |
-
class CategoryPosts extends WP_Widget {
|
50 |
-
|
51 |
-
function __construct() {
|
52 |
-
$widget_ops = array('classname' => 'cat-post-widget', 'description' => __('List single category posts'));
|
53 |
-
parent::__construct('category-posts', __('Category Posts'), $widget_ops);
|
54 |
-
}
|
55 |
-
|
56 |
-
// Displays category posts widget on blog.
|
57 |
-
function widget($args, $instance) {
|
58 |
-
global $post;
|
59 |
-
$post_old = $post; // Save the post object.
|
60 |
-
|
61 |
-
extract( $args );
|
62 |
-
|
63 |
-
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
64 |
-
|
65 |
-
// If not title, use the name of the category.
|
66 |
-
if( !$instance["title"] ) {
|
67 |
-
$category_info = get_category($instance["cat"]);
|
68 |
-
$instance["title"] = $category_info->name;
|
69 |
-
}
|
70 |
-
|
71 |
-
$valid_sort_orders = array('date', 'title', 'comment_count', 'rand');
|
72 |
-
if ( in_array($instance['sort_by'], $valid_sort_orders) ) {
|
73 |
-
$sort_by = $instance['sort_by'];
|
74 |
-
$sort_order = (bool) isset( $instance['asc_sort_order'] ) ? 'ASC' : 'DESC';
|
75 |
-
} else {
|
76 |
-
// by default, display latest first
|
77 |
-
$sort_by = 'date';
|
78 |
-
$sort_order = 'DESC';
|
79 |
-
}
|
80 |
-
|
81 |
-
// Get array of post info.
|
82 |
-
$cat_posts = new WP_Query(
|
83 |
-
"showposts=" . $instance["num"] .
|
84 |
-
"&cat=" . $instance["cat"] .
|
85 |
-
"&orderby=" . $sort_by .
|
86 |
-
"&order=" . $sort_order
|
87 |
-
);
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
if( isset ( $instance["
|
100 |
-
echo
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
$cat_posts->
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
<?php
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
<?php
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
*
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
$sizes
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
'
|
211 |
-
'
|
212 |
-
'
|
213 |
-
'
|
214 |
-
'
|
215 |
-
'
|
216 |
-
'
|
217 |
-
'
|
218 |
-
'
|
219 |
-
'
|
220 |
-
'
|
221 |
-
'
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
$
|
230 |
-
$
|
231 |
-
$
|
232 |
-
$
|
233 |
-
$
|
234 |
-
$
|
235 |
-
$
|
236 |
-
$
|
237 |
-
$
|
238 |
-
$
|
239 |
-
$
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
<p>
|
249 |
-
<label for="<?php echo $this->get_field_id("
|
250 |
-
|
251 |
-
<?php
|
252 |
-
</label>
|
253 |
-
</p>
|
254 |
-
<p>
|
255 |
-
<label>
|
256 |
-
<?php
|
257 |
-
<?php
|
258 |
-
</label>
|
259 |
-
</p>
|
260 |
-
<p>
|
261 |
-
<label for="<?php echo $this->get_field_id("
|
262 |
-
<?php
|
263 |
-
|
264 |
-
</label>
|
265 |
-
</p>
|
266 |
-
<p>
|
267 |
-
<label
|
268 |
-
<?php _e('
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
<?php
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
</label>
|
297 |
-
</p>
|
298 |
-
<p>
|
299 |
-
<label for="<?php echo $this->get_field_id("
|
300 |
-
<?php
|
301 |
-
|
302 |
-
|
303 |
-
</p>
|
304 |
-
<p>
|
305 |
-
<label for="<?php echo $this->get_field_id("
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
</p>
|
310 |
-
<p>
|
311 |
-
<label for="<?php echo $this->get_field_id("
|
312 |
-
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("
|
313 |
-
<?php _e( 'Show
|
314 |
-
</label>
|
315 |
-
</p>
|
316 |
-
|
317 |
-
<
|
318 |
-
<
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
<p>
|
324 |
-
<label for="<?php echo $this->get_field_id("
|
325 |
-
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("
|
326 |
-
<?php _e( '
|
327 |
-
</label>
|
328 |
-
</p>
|
329 |
-
<p>
|
330 |
-
<label>
|
331 |
-
<?php
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
</
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Category Posts Widget
|
4 |
+
Plugin URI: http://mkrdip.me/category-posts-widget
|
5 |
+
Description: Adds a widget that shows the most recent posts from a single category.
|
6 |
+
Author: Mrinal Kanti Roy
|
7 |
+
Version: 4.1.3
|
8 |
+
Author URI: http://mkrdip.me
|
9 |
+
*/
|
10 |
+
|
11 |
+
// Don't call the file directly
|
12 |
+
if ( !defined( 'ABSPATH' ) ) exit;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Register our styles
|
16 |
+
*
|
17 |
+
* @return void
|
18 |
+
*/
|
19 |
+
add_action( 'wp_enqueue_scripts', 'category_posts_widget_styles' );
|
20 |
+
|
21 |
+
function category_posts_widget_styles() {
|
22 |
+
wp_register_style( 'category-posts', plugins_url( 'category-posts/cat-posts.css' ) );
|
23 |
+
wp_enqueue_style( 'category-posts' );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Register thumbnail sizes.
|
28 |
+
*
|
29 |
+
* @return void
|
30 |
+
*/
|
31 |
+
function category_posts_add_image_size(){
|
32 |
+
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
33 |
+
|
34 |
+
if ( $sizes ){
|
35 |
+
foreach ( $sizes as $id=>$size ) {
|
36 |
+
add_image_size( 'cat_post_thumb_size' . $id, $size[0], $size[1], true );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
add_action( 'init', 'category_posts_add_image_size' );
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Category Posts Widget Class
|
46 |
+
*
|
47 |
+
* Shows the single category posts with some configurable options
|
48 |
+
*/
|
49 |
+
class CategoryPosts extends WP_Widget {
|
50 |
+
|
51 |
+
function __construct() {
|
52 |
+
$widget_ops = array('classname' => 'cat-post-widget', 'description' => __('List single category posts'));
|
53 |
+
parent::__construct('category-posts', __('Category Posts'), $widget_ops);
|
54 |
+
}
|
55 |
+
|
56 |
+
// Displays category posts widget on blog.
|
57 |
+
function widget($args, $instance) {
|
58 |
+
global $post;
|
59 |
+
$post_old = $post; // Save the post object.
|
60 |
+
|
61 |
+
extract( $args );
|
62 |
+
|
63 |
+
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
64 |
+
|
65 |
+
// If not title, use the name of the category.
|
66 |
+
if( !$instance["title"] ) {
|
67 |
+
$category_info = get_category($instance["cat"]);
|
68 |
+
$instance["title"] = $category_info->name;
|
69 |
+
}
|
70 |
+
|
71 |
+
$valid_sort_orders = array('date', 'title', 'comment_count', 'rand');
|
72 |
+
if ( in_array($instance['sort_by'], $valid_sort_orders) ) {
|
73 |
+
$sort_by = $instance['sort_by'];
|
74 |
+
$sort_order = (bool) isset( $instance['asc_sort_order'] ) ? 'ASC' : 'DESC';
|
75 |
+
} else {
|
76 |
+
// by default, display latest first
|
77 |
+
$sort_by = 'date';
|
78 |
+
$sort_order = 'DESC';
|
79 |
+
}
|
80 |
+
|
81 |
+
// Get array of post info.
|
82 |
+
$cat_posts = new WP_Query(
|
83 |
+
"showposts=" . $instance["num"] .
|
84 |
+
"&cat=" . $instance["cat"] .
|
85 |
+
"&orderby=" . $sort_by .
|
86 |
+
"&order=" . $sort_order
|
87 |
+
);
|
88 |
+
|
89 |
+
if ( !isset ( $instance["hide_if_empty"] ) || $cat_posts->have_posts() ) {
|
90 |
+
|
91 |
+
// Excerpt length filter
|
92 |
+
$new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";");
|
93 |
+
if ( $instance["excerpt_length"] > 0 )
|
94 |
+
add_filter('excerpt_length', $new_excerpt_length);
|
95 |
+
|
96 |
+
echo $before_widget;
|
97 |
+
|
98 |
+
// Widget title
|
99 |
+
if( !isset ( $instance["hide_title"] ) ) {
|
100 |
+
echo $before_title;
|
101 |
+
if( isset ( $instance["title_link"] ) ) {
|
102 |
+
echo '<a href="' . get_category_link($instance["cat"]) . '">' . $instance["title"] . '</a>';
|
103 |
+
} else {
|
104 |
+
echo $instance["title"];
|
105 |
+
}
|
106 |
+
echo $after_title;
|
107 |
+
}
|
108 |
+
|
109 |
+
// Post list
|
110 |
+
echo "<ul>\n";
|
111 |
+
|
112 |
+
while ( $cat_posts->have_posts() )
|
113 |
+
{
|
114 |
+
$cat_posts->the_post(); ?>
|
115 |
+
|
116 |
+
<li <?php if( !isset( $instance['disable_css'] ) ) {
|
117 |
+
echo "class=\"cat-post-item";
|
118 |
+
if ( is_single(get_the_title() ) ) { echo " cat-post-current"; }
|
119 |
+
echo "\"";
|
120 |
+
} ?> >
|
121 |
+
|
122 |
+
<?php
|
123 |
+
if( isset( $instance["thumbTop"] ) ) :
|
124 |
+
if ( function_exists('the_post_thumbnail') &&
|
125 |
+
current_theme_supports("post-thumbnails") &&
|
126 |
+
isset( $instance["thumb"] ) &&
|
127 |
+
has_post_thumbnail() ) : ?>
|
128 |
+
<a <?php if( !isset( $instance['disable_css'] ) ) { echo "class=\"cat-post-thumbnail\""; } ?>
|
129 |
+
href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
|
130 |
+
<?php the_post_thumbnail( 'cat_post_thumb_size'.$this->id ); ?>
|
131 |
+
</a>
|
132 |
+
<?php endif;
|
133 |
+
endif; ?>
|
134 |
+
|
135 |
+
<a class="post-title <?php if( !isset( $instance['disable_css'] ) ) { echo " cat-post-title"; } ?>"
|
136 |
+
href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>
|
137 |
+
</a>
|
138 |
+
|
139 |
+
<?php if ( isset( $instance['date'] ) ) : ?>
|
140 |
+
<p class="post-date <?php if( !isset( $instance['disable_css'] ) ) { echo " cat-post-date"; } ?>">
|
141 |
+
<?php the_time("j M Y"); ?>
|
142 |
+
</p>
|
143 |
+
<?php endif;
|
144 |
+
|
145 |
+
if( !isset( $instance["thumbTop"] ) ) :
|
146 |
+
if ( function_exists('the_post_thumbnail') &&
|
147 |
+
current_theme_supports("post-thumbnails") &&
|
148 |
+
isset( $instance["thumb"] ) &&
|
149 |
+
has_post_thumbnail() ) : ?>
|
150 |
+
<a <?php if( !isset( $instance['disable_css'] ) ) { echo "class=\"cat-post-thumbnail\""; } ?>
|
151 |
+
href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
|
152 |
+
<?php the_post_thumbnail( 'cat_post_thumb_size'.$this->id ); ?>
|
153 |
+
</a>
|
154 |
+
<?php endif;
|
155 |
+
endif;
|
156 |
+
|
157 |
+
if ( isset( $instance['excerpt'] ) ) :
|
158 |
+
the_excerpt();
|
159 |
+
endif;
|
160 |
+
|
161 |
+
if ( isset( $instance['comment_num'] ) ) : ?>
|
162 |
+
<p class="comment-num <?php if( !isset( $instance['disable_css'] ) ) { echo "cat-post-comment-num"; } ?>">
|
163 |
+
(<?php comments_number(); ?>)
|
164 |
+
</p>
|
165 |
+
<?php endif; ?>
|
166 |
+
</li>
|
167 |
+
<?php
|
168 |
+
}
|
169 |
+
|
170 |
+
echo "</ul>\n";
|
171 |
+
|
172 |
+
echo $after_widget;
|
173 |
+
|
174 |
+
remove_filter('excerpt_length', $new_excerpt_length);
|
175 |
+
|
176 |
+
if (function_exists ('wp_reset_postdata')) //wp_reset_postdata only exists in WordPress >3.0.0
|
177 |
+
wp_reset_postdata();
|
178 |
+
|
179 |
+
} // END if !isset ( $instance["hide_if_empty"] ) || $cat_posts->have_posts()
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Update the options
|
184 |
+
*
|
185 |
+
* @param array $new_instance
|
186 |
+
* @param array $old_instance
|
187 |
+
* @return array
|
188 |
+
*/
|
189 |
+
function update($new_instance, $old_instance) {
|
190 |
+
|
191 |
+
// thumbnail size
|
192 |
+
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
193 |
+
if ( !$sizes ) {
|
194 |
+
$sizes = array();
|
195 |
+
}
|
196 |
+
$sizes[$this->id] = array($new_instance['thumb_w'], $new_instance['thumb_h']);
|
197 |
+
update_option('mkrdip_cat_post_thumb_sizes', $sizes);
|
198 |
+
|
199 |
+
return $new_instance;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* The widget configuration form back end.
|
204 |
+
*
|
205 |
+
* @param array $instance
|
206 |
+
* @return void
|
207 |
+
*/
|
208 |
+
function form($instance) {
|
209 |
+
$instance = wp_parse_args( ( array ) $instance, array(
|
210 |
+
'title' => __( '' ),
|
211 |
+
'hide_title' => __( '' ),
|
212 |
+
'cat' => __( '' ),
|
213 |
+
'num' => __( '' ),
|
214 |
+
'sort_by' => __( '' ),
|
215 |
+
'asc_sort_order' => __( '' ),
|
216 |
+
'title_link' => __( '' ),
|
217 |
+
'excerpt' => __( '' ),
|
218 |
+
'excerpt_length' => __( '' ),
|
219 |
+
'comment_num' => __( '' ),
|
220 |
+
'date' => __( '' ),
|
221 |
+
'thumb' => __( '' ),
|
222 |
+
'thumbTop' => __( '' ),
|
223 |
+
'thumb_w' => __( '' ),
|
224 |
+
'thumb_h' => __( '' ),
|
225 |
+
'disable_css' => __( '' ),
|
226 |
+
'hide_if_empty' => __( '' )
|
227 |
+
) );
|
228 |
+
|
229 |
+
$title = $instance['title'];
|
230 |
+
$hide_title = $instance['hide_title'];
|
231 |
+
$cat = $instance['cat'];
|
232 |
+
$num = $instance['num'];
|
233 |
+
$sort_by = $instance['sort_by'];
|
234 |
+
$asc_sort_order = $instance['asc_sort_order'];
|
235 |
+
$title_link = $instance['title_link'];
|
236 |
+
$excerpt = $instance['excerpt'];
|
237 |
+
$excerpt_length = $instance['excerpt_length'];
|
238 |
+
$comment_num = $instance['comment_num'];
|
239 |
+
$date = $instance['date'];
|
240 |
+
$thumb = $instance['thumb'];
|
241 |
+
$thumbTop = $instance['thumbTop'];
|
242 |
+
$thumb_w = $instance['thumb_w'];
|
243 |
+
$thumb_h = $instance['thumb_h'];
|
244 |
+
$disable_css = $instance['disable_css'];
|
245 |
+
$hide_if_empty = $instance['hide_if_empty'];
|
246 |
+
|
247 |
+
?>
|
248 |
+
<p>
|
249 |
+
<label for="<?php echo $this->get_field_id("title"); ?>">
|
250 |
+
<?php _e( 'Title' ); ?>:
|
251 |
+
<input class="widefat" id="<?php echo $this->get_field_id("title"); ?>" name="<?php echo $this->get_field_name("title"); ?>" type="text" value="<?php echo esc_attr($instance["title"]); ?>" />
|
252 |
+
</label>
|
253 |
+
</p>
|
254 |
+
<p>
|
255 |
+
<label for="<?php echo $this->get_field_id("hide_title"); ?>">
|
256 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("hide_title"); ?>" name="<?php echo $this->get_field_name("hide_title"); ?>"<?php checked( (bool) $instance["hide_title"], true ); ?> />
|
257 |
+
<?php _e( 'Hide title' ); ?>
|
258 |
+
</label>
|
259 |
+
</p>
|
260 |
+
<p>
|
261 |
+
<label for="<?php echo $this->get_field_id("title_link"); ?>">
|
262 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("title_link"); ?>" name="<?php echo $this->get_field_name("title_link"); ?>"<?php checked( (bool) $instance["title_link"], true ); ?> />
|
263 |
+
<?php _e( 'Make widget title link' ); ?>
|
264 |
+
</label>
|
265 |
+
</p>
|
266 |
+
<p>
|
267 |
+
<label>
|
268 |
+
<?php _e( 'Category' ); ?>:
|
269 |
+
<?php wp_dropdown_categories( array( 'name' => $this->get_field_name("cat"), 'selected' => $instance["cat"] ) ); ?>
|
270 |
+
</label>
|
271 |
+
</p>
|
272 |
+
<p>
|
273 |
+
<label for="<?php echo $this->get_field_id("num"); ?>">
|
274 |
+
<?php _e('Number of posts to show'); ?>:
|
275 |
+
<input style="text-align: center;" id="<?php echo $this->get_field_id("num"); ?>" name="<?php echo $this->get_field_name("num"); ?>" type="text" value="<?php echo absint($instance["num"]); ?>" size='3' />
|
276 |
+
</label>
|
277 |
+
</p>
|
278 |
+
<p>
|
279 |
+
<label for="<?php echo $this->get_field_id("sort_by"); ?>">
|
280 |
+
<?php _e('Sort by'); ?>:
|
281 |
+
<select id="<?php echo $this->get_field_id("sort_by"); ?>" name="<?php echo $this->get_field_name("sort_by"); ?>">
|
282 |
+
<option value="date"<?php selected( $instance["sort_by"], "date" ); ?>>Date</option>
|
283 |
+
<option value="title"<?php selected( $instance["sort_by"], "title" ); ?>>Title</option>
|
284 |
+
<option value="comment_count"<?php selected( $instance["sort_by"], "comment_count" ); ?>>Number of comments</option>
|
285 |
+
<option value="rand"<?php selected( $instance["sort_by"], "rand" ); ?>>Random</option>
|
286 |
+
</select>
|
287 |
+
</label>
|
288 |
+
</p>
|
289 |
+
<p>
|
290 |
+
<label for="<?php echo $this->get_field_id("asc_sort_order"); ?>">
|
291 |
+
<input type="checkbox" class="checkbox"
|
292 |
+
id="<?php echo $this->get_field_id("asc_sort_order"); ?>"
|
293 |
+
name="<?php echo $this->get_field_name("asc_sort_order"); ?>"
|
294 |
+
<?php checked( (bool) $instance["asc_sort_order"], true ); ?> />
|
295 |
+
<?php _e( 'Reverse sort order (ascending)' ); ?>
|
296 |
+
</label>
|
297 |
+
</p>
|
298 |
+
<p>
|
299 |
+
<label for="<?php echo $this->get_field_id("excerpt"); ?>">
|
300 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("excerpt"); ?>" name="<?php echo $this->get_field_name("excerpt"); ?>"<?php checked( (bool) $instance["excerpt"], true ); ?> />
|
301 |
+
<?php _e( 'Show post excerpt' ); ?>
|
302 |
+
</label>
|
303 |
+
</p>
|
304 |
+
<p>
|
305 |
+
<label for="<?php echo $this->get_field_id("excerpt_length"); ?>">
|
306 |
+
<?php _e( 'Excerpt length (in words):' ); ?>
|
307 |
+
</label>
|
308 |
+
<input style="text-align: center;" type="text" id="<?php echo $this->get_field_id("excerpt_length"); ?>" name="<?php echo $this->get_field_name("excerpt_length"); ?>" value="<?php echo $instance["excerpt_length"]; ?>" size="3" />
|
309 |
+
</p>
|
310 |
+
<p>
|
311 |
+
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
|
312 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num"); ?>" name="<?php echo $this->get_field_name("comment_num"); ?>"<?php checked( (bool) $instance["comment_num"], true ); ?> />
|
313 |
+
<?php _e( 'Show number of comments' ); ?>
|
314 |
+
</label>
|
315 |
+
</p>
|
316 |
+
<p>
|
317 |
+
<label for="<?php echo $this->get_field_id("date"); ?>">
|
318 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date"); ?>" name="<?php echo $this->get_field_name("date"); ?>"<?php checked( (bool) $instance["date"], true ); ?> />
|
319 |
+
<?php _e( 'Show post date' ); ?>
|
320 |
+
</label>
|
321 |
+
</p>
|
322 |
+
<?php if ( function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") ) : ?>
|
323 |
+
<p>
|
324 |
+
<label for="<?php echo $this->get_field_id("thumb"); ?>">
|
325 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("thumb"); ?>" name="<?php echo $this->get_field_name("thumb"); ?>"<?php checked( (bool) $instance["thumb"], true ); ?> />
|
326 |
+
<?php _e( 'Show post thumbnail' ); ?>
|
327 |
+
</label>
|
328 |
+
</p>
|
329 |
+
<p>
|
330 |
+
<label for="<?php echo $this->get_field_id("thumbTop"); ?>">
|
331 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("thumbTop"); ?>" name="<?php echo $this->get_field_name("thumbTop"); ?>"<?php checked( (bool) $instance["thumbTop"], true ); ?> />
|
332 |
+
<?php _e( 'Thumbnail to top' ); ?>
|
333 |
+
</label>
|
334 |
+
</p>
|
335 |
+
<p>
|
336 |
+
<label>
|
337 |
+
<?php _e('Thumbnail dimensions (in pixels)'); ?>:<br />
|
338 |
+
<label for="<?php echo $this->get_field_id("thumb_w"); ?>">
|
339 |
+
Width: <input class="widefat" style="width:30%;" type="text" id="<?php echo $this->get_field_id("thumb_w"); ?>" name="<?php echo $this->get_field_name("thumb_w"); ?>" value="<?php echo $instance["thumb_w"]; ?>" />
|
340 |
+
</label>
|
341 |
+
|
342 |
+
<label for="<?php echo $this->get_field_id("thumb_h"); ?>">
|
343 |
+
Height: <input class="widefat" style="width:30%;" type="text" id="<?php echo $this->get_field_id("thumb_h"); ?>" name="<?php echo $this->get_field_name("thumb_h"); ?>" value="<?php echo $instance["thumb_h"]; ?>" />
|
344 |
+
</label>
|
345 |
+
</label>
|
346 |
+
</p>
|
347 |
+
<?php endif; ?>
|
348 |
+
<p>
|
349 |
+
<label for="<?php echo $this->get_field_id("disable_css"); ?>">
|
350 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("disable_css"); ?>" name="<?php echo $this->get_field_name("disable_css"); ?>"<?php checked( (bool) $instance["disable_css"], true ); ?> />
|
351 |
+
<?php _e( 'Disable widget CSS' ); ?>
|
352 |
+
</label>
|
353 |
+
</p>
|
354 |
+
<p>
|
355 |
+
<label for="<?php echo $this->get_field_id("hide_if_empty"); ?>">
|
356 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("hide_if_empty"); ?>" name="<?php echo $this->get_field_name("hide_if_empty"); ?>"<?php checked( (bool) $instance["hide_if_empty"], true ); ?> />
|
357 |
+
<?php _e( 'Hide if empty' ); ?>
|
358 |
+
</label>
|
359 |
+
</p>
|
360 |
+
<?php
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
add_action( 'widgets_init', create_function('', 'return register_widget("CategoryPosts");') );
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: mkrdip, kometschuh
|
|
3 |
Donate link: http://mkrdip.me/donate
|
4 |
Tags: category, posts, widget, single category widget, posts widget, category recent posts
|
5 |
Requires at least: 2.8
|
6 |
-
Tested up to: 4.3.
|
7 |
-
Stable tag: 4.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -19,13 +19,15 @@ Category Posts Widget is a light widget designed to do one thing and do it well:
|
|
19 |
* Option to change ordering of posts.
|
20 |
* Option to show post thumbnail & set dimension by width & height.
|
21 |
* Option to put thumbnail on top
|
|
|
22 |
* Set how many posts to show.
|
23 |
* Set which category the posts should come form.
|
24 |
* Option to show the post excerpt and how long the excerpt should be.
|
25 |
* Option to show the post date.
|
26 |
* Option to show the comment count.
|
27 |
* Option to make the widget title link to the category page.
|
28 |
-
* Option to hide the title
|
|
|
29 |
* Multiple widgets.
|
30 |
|
31 |
= Contribute =
|
@@ -63,6 +65,10 @@ Automatic installation is the easiest option as WordPress handles the file trans
|
|
63 |
|
64 |
Please use the option: "Disable widget CSS".
|
65 |
|
|
|
|
|
|
|
|
|
66 |
== Screenshots ==
|
67 |
|
68 |
1. The widget configuration dialog.
|
@@ -70,27 +76,31 @@ Please use the option: "Disable widget CSS".
|
|
70 |
|
71 |
== Changelog ==
|
72 |
|
|
|
|
|
|
|
|
|
73 |
4.1.2
|
74 |
|
75 |
* Fixed hide title bug.
|
76 |
|
77 |
4.1.1
|
78 |
|
79 |
-
* Added option to put thumbnail on top
|
80 |
-
* Added option to hide the title
|
81 |
* Fixed no background bug.
|
82 |
|
83 |
4.1.0
|
84 |
|
85 |
-
* Added PHP5 Constructor
|
86 |
-
* Added Option to allow/disallow widget CSS
|
87 |
-
* Now, compatible with WordPress 4.3
|
88 |
* Meet new plugin author [kometschuh](https://profiles.wordpress.org/kometschuh)
|
89 |
|
90 |
4.0
|
91 |
|
92 |
-
* Added CSS file for post styling
|
93 |
-
* Now
|
94 |
|
95 |
3.3
|
96 |
|
@@ -114,7 +124,7 @@ Please use the option: "Disable widget CSS".
|
|
114 |
|
115 |
2.3
|
116 |
|
117 |
-
* Really tried to fix bug where wp_query global was getting over written by manually instantiating a WP_Query object
|
118 |
|
119 |
2.1
|
120 |
|
3 |
Donate link: http://mkrdip.me/donate
|
4 |
Tags: category, posts, widget, single category widget, posts widget, category recent posts
|
5 |
Requires at least: 2.8
|
6 |
+
Tested up to: 4.3.1
|
7 |
+
Stable tag: 4.1.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
19 |
* Option to change ordering of posts.
|
20 |
* Option to show post thumbnail & set dimension by width & height.
|
21 |
* Option to put thumbnail on top
|
22 |
+
* Option to disable widget CSS.
|
23 |
* Set how many posts to show.
|
24 |
* Set which category the posts should come form.
|
25 |
* Option to show the post excerpt and how long the excerpt should be.
|
26 |
* Option to show the post date.
|
27 |
* Option to show the comment count.
|
28 |
* Option to make the widget title link to the category page.
|
29 |
+
* Option to hide the title.
|
30 |
+
* Option to hide widget, if category have currently no posts.
|
31 |
* Multiple widgets.
|
32 |
|
33 |
= Contribute =
|
65 |
|
66 |
Please use the option: "Disable widget CSS".
|
67 |
|
68 |
+
= I want the title as a link pointing to the selected Categorie page? =
|
69 |
+
|
70 |
+
Enable the check box "Make widget title link".
|
71 |
+
|
72 |
== Screenshots ==
|
73 |
|
74 |
1. The widget configuration dialog.
|
76 |
|
77 |
== Changelog ==
|
78 |
|
79 |
+
4.1.3
|
80 |
+
|
81 |
+
* Added option to hide widget, if category have currently no posts.
|
82 |
+
|
83 |
4.1.2
|
84 |
|
85 |
* Fixed hide title bug.
|
86 |
|
87 |
4.1.1
|
88 |
|
89 |
+
* Added option to put thumbnail on top.
|
90 |
+
* Added option to show/hide the title.
|
91 |
* Fixed no background bug.
|
92 |
|
93 |
4.1.0
|
94 |
|
95 |
+
* Added PHP5 Constructor.
|
96 |
+
* Added Option to allow/disallow widget CSS.
|
97 |
+
* Now, compatible with WordPress 4.3.
|
98 |
* Meet new plugin author [kometschuh](https://profiles.wordpress.org/kometschuh)
|
99 |
|
100 |
4.0
|
101 |
|
102 |
+
* Added CSS file for post styling .
|
103 |
+
* Now compatible with latest versions of WordPress.
|
104 |
|
105 |
3.3
|
106 |
|
124 |
|
125 |
2.3
|
126 |
|
127 |
+
* Really tried to fix bug where wp_query global was getting over written by manually instantiating a WP_Query object.
|
128 |
|
129 |
2.1
|
130 |
|