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.1 |
Comparing to | |
See all releases |
Code changes from version 4.1.0 to 4.1.1
- cat-posts.css +41 -35
- cat-posts.php +356 -324
- readme.txt +13 -5
cat-posts.css
CHANGED
@@ -1,35 +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
|
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:
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Default CSS Styles for the Category Posts Widget plugin
|
3 |
+
Version: 4.1.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 |
+
}
|
cat-posts.php
CHANGED
@@ -1,324 +1,356 @@
|
|
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 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
$instance["
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
$
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
$
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
"
|
85 |
-
"&
|
86 |
-
"&
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
if( isset ( $instance["
|
99 |
-
echo
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
<?php
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
<?php endif;
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
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 |
-
|
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 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
<
|
254 |
-
<
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
<?php
|
277 |
-
|
278 |
-
|
279 |
-
</
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.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 |
+
$control_ops = array( 'show_title' => true );
|
54 |
+
parent::__construct('category-posts', __('Category Posts'), $widget_ops, $control_ops);
|
55 |
+
}
|
56 |
+
|
57 |
+
// Displays category posts widget on blog.
|
58 |
+
function widget($args, $instance) {
|
59 |
+
global $post;
|
60 |
+
$post_old = $post; // Save the post object.
|
61 |
+
|
62 |
+
extract( $args );
|
63 |
+
|
64 |
+
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
65 |
+
|
66 |
+
// If not title, use the name of the category.
|
67 |
+
if( !$instance["title"] ) {
|
68 |
+
$category_info = get_category($instance["cat"]);
|
69 |
+
$instance["title"] = $category_info->name;
|
70 |
+
}
|
71 |
+
|
72 |
+
$valid_sort_orders = array('date', 'title', 'comment_count', 'rand');
|
73 |
+
if ( in_array($instance['sort_by'], $valid_sort_orders) ) {
|
74 |
+
$sort_by = $instance['sort_by'];
|
75 |
+
$sort_order = (bool) isset( $instance['asc_sort_order'] ) ? 'ASC' : 'DESC';
|
76 |
+
} else {
|
77 |
+
// by default, display latest first
|
78 |
+
$sort_by = 'date';
|
79 |
+
$sort_order = 'DESC';
|
80 |
+
}
|
81 |
+
|
82 |
+
// Get array of post info.
|
83 |
+
$cat_posts = new WP_Query(
|
84 |
+
"showposts=" . $instance["num"] .
|
85 |
+
"&cat=" . $instance["cat"] .
|
86 |
+
"&orderby=" . $sort_by .
|
87 |
+
"&order=" . $sort_order
|
88 |
+
);
|
89 |
+
|
90 |
+
// Excerpt length filter
|
91 |
+
$new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";");
|
92 |
+
if ( $instance["excerpt_length"] > 0 )
|
93 |
+
add_filter('excerpt_length', $new_excerpt_length);
|
94 |
+
|
95 |
+
echo $before_widget;
|
96 |
+
|
97 |
+
// Widget title
|
98 |
+
if( isset ( $instance["show_title"] ) && $instance["show_title"] ) {
|
99 |
+
echo $before_title;
|
100 |
+
if( isset ( $instance["title_link"] ) ) {
|
101 |
+
echo '<a href="' . get_category_link($instance["cat"]) . '">' . $instance["title"] . '</a>';
|
102 |
+
} else {
|
103 |
+
echo $instance["title"];
|
104 |
+
}
|
105 |
+
echo $after_title;
|
106 |
+
}
|
107 |
+
|
108 |
+
// Post list
|
109 |
+
echo "<ul>\n";
|
110 |
+
|
111 |
+
while ( $cat_posts->have_posts() )
|
112 |
+
{
|
113 |
+
$cat_posts->the_post(); ?>
|
114 |
+
|
115 |
+
<li <?php if( !isset( $instance['disable_css'] ) ) {
|
116 |
+
echo "class=\"cat-post-item";
|
117 |
+
if ( is_single(get_the_title() ) ) { echo " cat-post-current"; }
|
118 |
+
echo "\"";
|
119 |
+
} ?> >
|
120 |
+
|
121 |
+
<?php
|
122 |
+
if( isset( $instance["thumbTop"] ) ) :
|
123 |
+
if ( function_exists('the_post_thumbnail') &&
|
124 |
+
current_theme_supports("post-thumbnails") &&
|
125 |
+
isset( $instance["thumb"] ) &&
|
126 |
+
has_post_thumbnail() ) : ?>
|
127 |
+
<a <?php if( !isset( $instance['disable_css'] ) ) { echo "class=\"cat-post-thumbnail\""; } ?>
|
128 |
+
href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
|
129 |
+
<?php the_post_thumbnail( 'cat_post_thumb_size'.$this->id ); ?>
|
130 |
+
</a>
|
131 |
+
<?php endif;
|
132 |
+
endif; ?>
|
133 |
+
|
134 |
+
<a class="post-title <?php if( !isset( $instance['disable_css'] ) ) { echo " cat-post-title"; } ?>"
|
135 |
+
href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>
|
136 |
+
</a>
|
137 |
+
|
138 |
+
<?php if ( isset( $instance['date'] ) ) : ?>
|
139 |
+
<p class="post-date <?php if( !isset( $instance['disable_css'] ) ) { echo " cat-post-date"; } ?>">
|
140 |
+
<?php the_time("j M Y"); ?>
|
141 |
+
</p>
|
142 |
+
<?php endif;
|
143 |
+
|
144 |
+
if( !isset( $instance["thumbTop"] ) ) :
|
145 |
+
if ( function_exists('the_post_thumbnail') &&
|
146 |
+
current_theme_supports("post-thumbnails") &&
|
147 |
+
isset( $instance["thumb"] ) &&
|
148 |
+
has_post_thumbnail() ) : ?>
|
149 |
+
<a <?php if( !isset( $instance['disable_css'] ) ) { echo "class=\"cat-post-thumbnail\""; } ?>
|
150 |
+
href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
|
151 |
+
<?php the_post_thumbnail( 'cat_post_thumb_size'.$this->id ); ?>
|
152 |
+
</a>
|
153 |
+
<?php endif;
|
154 |
+
endif;
|
155 |
+
|
156 |
+
if ( isset( $instance['excerpt'] ) ) :
|
157 |
+
the_excerpt();
|
158 |
+
endif;
|
159 |
+
|
160 |
+
if ( isset( $instance['comment_num'] ) ) : ?>
|
161 |
+
<p class="comment-num <?php if( !isset( $instance['disable_css'] ) ) { echo "cat-post-comment-num"; } ?>">
|
162 |
+
(<?php comments_number(); ?>)
|
163 |
+
</p>
|
164 |
+
<?php endif; ?>
|
165 |
+
</li>
|
166 |
+
<?php
|
167 |
+
}
|
168 |
+
|
169 |
+
echo "</ul>\n";
|
170 |
+
|
171 |
+
echo $after_widget;
|
172 |
+
|
173 |
+
remove_filter('excerpt_length', $new_excerpt_length);
|
174 |
+
|
175 |
+
if (function_exists ('wp_reset_postdata')) //wp_reset_postdata only exists in WordPress >3.0.0
|
176 |
+
wp_reset_postdata();
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Update the options
|
181 |
+
*
|
182 |
+
* @param array $new_instance
|
183 |
+
* @param array $old_instance
|
184 |
+
* @return array
|
185 |
+
*/
|
186 |
+
function update($new_instance, $old_instance) {
|
187 |
+
|
188 |
+
// thumbnail size
|
189 |
+
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
190 |
+
if ( !$sizes ) {
|
191 |
+
$sizes = array();
|
192 |
+
}
|
193 |
+
$sizes[$this->id] = array($new_instance['thumb_w'], $new_instance['thumb_h']);
|
194 |
+
update_option('mkrdip_cat_post_thumb_sizes', $sizes);
|
195 |
+
|
196 |
+
// show title
|
197 |
+
$new_instance['show_title'] = $new_instance['show_title'];
|
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 |
+
'show_title' => __( true ),
|
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 |
+
) );
|
227 |
+
|
228 |
+
$title = $instance['title'];
|
229 |
+
$show_title = $instance['show_title'];
|
230 |
+
$cat = $instance['cat'];
|
231 |
+
$num = $instance['num'];
|
232 |
+
$sort_by = $instance['sort_by'];
|
233 |
+
$asc_sort_order = $instance['asc_sort_order'];
|
234 |
+
$title_link = $instance['title_link'];
|
235 |
+
$excerpt = $instance['excerpt'];
|
236 |
+
$excerpt_length = $instance['excerpt_length'];
|
237 |
+
$comment_num = $instance['comment_num'];
|
238 |
+
$date = $instance['date'];
|
239 |
+
$thumb = $instance['thumb'];
|
240 |
+
$thumbTop = $instance['thumbTop'];
|
241 |
+
$thumb_w = $instance['thumb_w'];
|
242 |
+
$thumb_h = $instance['thumb_h'];
|
243 |
+
$disable_css = $instance['disable_css'];
|
244 |
+
|
245 |
+
?>
|
246 |
+
<p>
|
247 |
+
<label for="<?php echo $this->get_field_id("title"); ?>">
|
248 |
+
<?php _e( 'Title' ); ?>:
|
249 |
+
<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"]); ?>" />
|
250 |
+
</label>
|
251 |
+
</p>
|
252 |
+
<p>
|
253 |
+
<label for="<?php echo $this->get_field_id("show_title"); ?>">
|
254 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_title"); ?>" name="<?php echo $this->get_field_name("show_title"); ?>"<?php checked( (bool) $instance["show_title"], true ); ?> />
|
255 |
+
<?php _e( 'Show title' ); ?>
|
256 |
+
</label>
|
257 |
+
</p>
|
258 |
+
<p>
|
259 |
+
<label>
|
260 |
+
<?php _e( 'Category' ); ?>:
|
261 |
+
<?php wp_dropdown_categories( array( 'name' => $this->get_field_name("cat"), 'selected' => $instance["cat"] ) ); ?>
|
262 |
+
</label>
|
263 |
+
</p>
|
264 |
+
<p>
|
265 |
+
<label for="<?php echo $this->get_field_id("num"); ?>">
|
266 |
+
<?php _e('Number of posts to show'); ?>:
|
267 |
+
<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' />
|
268 |
+
</label>
|
269 |
+
</p>
|
270 |
+
<p>
|
271 |
+
<label for="<?php echo $this->get_field_id("sort_by"); ?>">
|
272 |
+
<?php _e('Sort by'); ?>:
|
273 |
+
<select id="<?php echo $this->get_field_id("sort_by"); ?>" name="<?php echo $this->get_field_name("sort_by"); ?>">
|
274 |
+
<option value="date"<?php selected( $instance["sort_by"], "date" ); ?>>Date</option>
|
275 |
+
<option value="title"<?php selected( $instance["sort_by"], "title" ); ?>>Title</option>
|
276 |
+
<option value="comment_count"<?php selected( $instance["sort_by"], "comment_count" ); ?>>Number of comments</option>
|
277 |
+
<option value="rand"<?php selected( $instance["sort_by"], "rand" ); ?>>Random</option>
|
278 |
+
</select>
|
279 |
+
</label>
|
280 |
+
</p>
|
281 |
+
<p>
|
282 |
+
<label for="<?php echo $this->get_field_id("asc_sort_order"); ?>">
|
283 |
+
<input type="checkbox" class="checkbox"
|
284 |
+
id="<?php echo $this->get_field_id("asc_sort_order"); ?>"
|
285 |
+
name="<?php echo $this->get_field_name("asc_sort_order"); ?>"
|
286 |
+
<?php checked( (bool) $instance["asc_sort_order"], true ); ?> />
|
287 |
+
<?php _e( 'Reverse sort order (ascending)' ); ?>
|
288 |
+
</label>
|
289 |
+
</p>
|
290 |
+
<p>
|
291 |
+
<label for="<?php echo $this->get_field_id("title_link"); ?>">
|
292 |
+
<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 ); ?> />
|
293 |
+
<?php _e( 'Make widget title link' ); ?>
|
294 |
+
</label>
|
295 |
+
</p>
|
296 |
+
<p>
|
297 |
+
<label for="<?php echo $this->get_field_id("excerpt"); ?>">
|
298 |
+
<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 ); ?> />
|
299 |
+
<?php _e( 'Show post excerpt' ); ?>
|
300 |
+
</label>
|
301 |
+
</p>
|
302 |
+
<p>
|
303 |
+
<label for="<?php echo $this->get_field_id("excerpt_length"); ?>">
|
304 |
+
<?php _e( 'Excerpt length (in words):' ); ?>
|
305 |
+
</label>
|
306 |
+
<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" />
|
307 |
+
</p>
|
308 |
+
<p>
|
309 |
+
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
|
310 |
+
<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 ); ?> />
|
311 |
+
<?php _e( 'Show number of comments' ); ?>
|
312 |
+
</label>
|
313 |
+
</p>
|
314 |
+
<p>
|
315 |
+
<label for="<?php echo $this->get_field_id("date"); ?>">
|
316 |
+
<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 ); ?> />
|
317 |
+
<?php _e( 'Show post date' ); ?>
|
318 |
+
</label>
|
319 |
+
</p>
|
320 |
+
<?php if ( function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") ) : ?>
|
321 |
+
<p>
|
322 |
+
<label for="<?php echo $this->get_field_id("thumb"); ?>">
|
323 |
+
<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 ); ?> />
|
324 |
+
<?php _e( 'Show post thumbnail' ); ?>
|
325 |
+
</label>
|
326 |
+
</p>
|
327 |
+
<p>
|
328 |
+
<label for="<?php echo $this->get_field_id("thumbTop"); ?>">
|
329 |
+
<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 ); ?> />
|
330 |
+
<?php _e( 'Thumbnail to top' ); ?>
|
331 |
+
</label>
|
332 |
+
</p>
|
333 |
+
<p>
|
334 |
+
<label>
|
335 |
+
<?php _e('Thumbnail dimensions (in pixels)'); ?>:<br />
|
336 |
+
<label for="<?php echo $this->get_field_id("thumb_w"); ?>">
|
337 |
+
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"]; ?>" />
|
338 |
+
</label>
|
339 |
+
|
340 |
+
<label for="<?php echo $this->get_field_id("thumb_h"); ?>">
|
341 |
+
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"]; ?>" />
|
342 |
+
</label>
|
343 |
+
</label>
|
344 |
+
</p>
|
345 |
+
<?php endif; ?>
|
346 |
+
<p>
|
347 |
+
<label for="<?php echo $this->get_field_id("disable_css"); ?>">
|
348 |
+
<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 ); ?> />
|
349 |
+
<?php _e( 'Disable widget CSS' ); ?>
|
350 |
+
</label>
|
351 |
+
</p>
|
352 |
+
<?php
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
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 |
|
@@ -18,12 +18,14 @@ Category Posts Widget is a light widget designed to do one thing and do it well:
|
|
18 |
|
19 |
* Option to change ordering of posts.
|
20 |
* Option to show post thumbnail & set dimension by width & height.
|
|
|
21 |
* Set how many posts to show.
|
22 |
* Set which category the posts should come form.
|
23 |
* Option to show the post excerpt and how long the excerpt should be.
|
24 |
* Option to show the post date.
|
25 |
* Option to show the comment count.
|
26 |
* Option to make the widget title link to the category page.
|
|
|
27 |
* Multiple widgets.
|
28 |
|
29 |
= Contribute =
|
@@ -34,11 +36,11 @@ While using this plugin if you find any bug or any conflict, please submit an is
|
|
34 |
|
35 |
= Automatic installation =
|
36 |
|
37 |
-
Automatic installation is the easiest option as WordPress handles the file transfers itself and you don
|
38 |
|
39 |
1. log in to your WordPress dashboard, navigate to the Plugins menu and click Add New.
|
40 |
2. In the search field type “Category Posts Widget” and click Search Plugins.
|
41 |
-
3. Once you
|
42 |
4. Then, go to plugins page of WordPress admin activate the plugin.
|
43 |
5. Now, goto the Widgets page of the Appearance section and configure the Category Posts widget.
|
44 |
|
@@ -63,6 +65,12 @@ Automatic installation is the easiest option as WordPress handles the file trans
|
|
63 |
|
64 |
== Changelog ==
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
4.1.0
|
67 |
|
68 |
* Added PHP5 Constructor
|
@@ -73,7 +81,7 @@ Automatic installation is the easiest option as WordPress handles the file trans
|
|
73 |
4.0
|
74 |
|
75 |
* Added CSS file for post styling
|
76 |
-
* Now
|
77 |
|
78 |
3.3
|
79 |
|
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.0
|
7 |
+
Stable tag: 4.1.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
18 |
|
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 show/hide the title
|
29 |
* Multiple widgets.
|
30 |
|
31 |
= Contribute =
|
36 |
|
37 |
= Automatic installation =
|
38 |
|
39 |
+
Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t need to leave your web browser. To do an automatic install of Category Posts Widget,
|
40 |
|
41 |
1. log in to your WordPress dashboard, navigate to the Plugins menu and click Add New.
|
42 |
2. In the search field type “Category Posts Widget” and click Search Plugins.
|
43 |
+
3. Once you’ve found plugin, you can install it by simply clicking “Install Now”.
|
44 |
4. Then, go to plugins page of WordPress admin activate the plugin.
|
45 |
5. Now, goto the Widgets page of the Appearance section and configure the Category Posts widget.
|
46 |
|
65 |
|
66 |
== Changelog ==
|
67 |
|
68 |
+
4.1.1
|
69 |
+
|
70 |
+
* Added option to put thumbnail on top
|
71 |
+
* Added option to show/hide the title
|
72 |
+
* Fixed no background bug.
|
73 |
+
|
74 |
4.1.0
|
75 |
|
76 |
* Added PHP5 Constructor
|
81 |
4.0
|
82 |
|
83 |
* Added CSS file for post styling
|
84 |
+
* Now compaitable with latest versions of WordPress
|
85 |
|
86 |
3.3
|
87 |
|