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 | mkrdip |
Plugin | Category Posts Widget |
Version | 4.1.0 |
Comparing to | |
See all releases |
Code changes from version 4.0 to 4.1.0
- cat-posts.css +35 -46
- cat-posts.php +324 -316
- readme.txt +109 -102
- screenshot-1.png +0 -0
cat-posts.css
CHANGED
@@ -1,46 +1,35 @@
|
|
1 |
-
/*
|
2 |
-
Default CSS Styles for the Category Posts Widget plugin
|
3 |
-
Version: 4.0
|
4 |
-
*/
|
5 |
-
.cat-post-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
list-style: none;
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
border-bottom: none;
|
37 |
-
}
|
38 |
-
.cat-post-widget .more-link {
|
39 |
-
display: inline;
|
40 |
-
}
|
41 |
-
.cat-post-widget .post-entry {
|
42 |
-
padding: 0 0 5px 0;
|
43 |
-
overflow: hidden;
|
44 |
-
}
|
45 |
-
.cat-post-widget .comment-num {
|
46 |
-
}
|
1 |
+
/*
|
2 |
+
Default CSS Styles for the Category Posts Widget plugin
|
3 |
+
Version: 4.1.0
|
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 0 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:last-child {
|
34 |
+
border-bottom: none;
|
35 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat-posts.php
CHANGED
@@ -1,316 +1,324 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Category Posts Widget
|
4 |
-
Plugin URI:
|
5 |
-
Description: Adds a widget that shows the most recent posts from a single category.
|
6 |
-
Author: Mrinal Kanti Roy
|
7 |
-
Version: 4.0
|
8 |
-
Author URI: http://
|
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
|
52 |
-
$widget_ops = array('classname' => 'cat-post-widget', 'description' => __('List single category posts'));
|
53 |
-
|
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 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
// Get array of post info.
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
// Excerpt length filter
|
90 |
-
$new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";");
|
91 |
-
if ( $instance["excerpt_length"] > 0 )
|
92 |
-
add_filter('excerpt_length', $new_excerpt_length);
|
93 |
-
|
94 |
-
echo $before_widget;
|
95 |
-
|
96 |
-
// Widget title
|
97 |
-
echo $before_title;
|
98 |
-
if( isset( $instance["title_link"] ) )
|
99 |
-
echo '<a href="' . get_category_link($instance["cat"]) . '">' . $instance["title"] . '</a>';
|
100 |
-
else
|
101 |
-
echo $instance["title"];
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
<?php
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
<?php endif; ?>
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
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 |
-
<?php
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
</label>
|
252 |
-
</p>
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
<?php
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
<p>
|
269 |
-
<label for="<?php echo $this->get_field_id("
|
270 |
-
<?php
|
271 |
-
|
272 |
-
|
273 |
-
</p>
|
274 |
-
|
275 |
-
|
276 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.0
|
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 |
+
// Excerpt length filter
|
90 |
+
$new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";");
|
91 |
+
if ( $instance["excerpt_length"] > 0 )
|
92 |
+
add_filter('excerpt_length', $new_excerpt_length);
|
93 |
+
|
94 |
+
echo $before_widget;
|
95 |
+
|
96 |
+
// Widget title
|
97 |
+
echo $before_title;
|
98 |
+
if( isset ( $instance["title_link"] ) ) {
|
99 |
+
echo '<a href="' . get_category_link($instance["cat"]) . '">' . $instance["title"] . '</a>';
|
100 |
+
} else {
|
101 |
+
echo $instance["title"];
|
102 |
+
}
|
103 |
+
echo $after_title;
|
104 |
+
|
105 |
+
// Post list
|
106 |
+
echo "<ul>\n";
|
107 |
+
|
108 |
+
while ( $cat_posts->have_posts() )
|
109 |
+
{
|
110 |
+
$cat_posts->the_post();
|
111 |
+
?>
|
112 |
+
<li <?php if( !isset( $instance['disable_css'] ) ) {
|
113 |
+
echo "class=\"cat-post-item";
|
114 |
+
if ( is_single(get_the_title() ) ) { echo " cat-post-current"; }
|
115 |
+
echo "\"";
|
116 |
+
} ?> >
|
117 |
+
<a class="post-title <?php if( !isset( $instance['disable_css'] ) ) { echo " cat-post-title"; } ?>"
|
118 |
+
href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
|
119 |
+
|
120 |
+
<?php if ( isset( $instance['date'] ) ) : ?>
|
121 |
+
<p class="post-date <?php if( !isset( $instance['disable_css'] ) ) { echo " cat-post-date"; } ?>">
|
122 |
+
<?php the_time("j M Y"); ?>
|
123 |
+
</p>
|
124 |
+
<?php endif; ?>
|
125 |
+
|
126 |
+
<?php
|
127 |
+
if (
|
128 |
+
function_exists('the_post_thumbnail') &&
|
129 |
+
current_theme_supports("post-thumbnails") &&
|
130 |
+
isset( $instance["thumb"] ) &&
|
131 |
+
has_post_thumbnail()
|
132 |
+
) :
|
133 |
+
?>
|
134 |
+
<a <?php if( !isset( $instance['disable_css'] ) ) { echo "class=\"cat-post-thumbnail\""; } ?>
|
135 |
+
href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
|
136 |
+
<?php the_post_thumbnail( 'cat_post_thumb_size'.$this->id ); ?>
|
137 |
+
</a>
|
138 |
+
<?php endif; ?>
|
139 |
+
|
140 |
+
<?php if ( isset( $instance['excerpt'] ) ) : ?>
|
141 |
+
<?php the_excerpt(); ?>
|
142 |
+
<?php endif; ?>
|
143 |
+
|
144 |
+
<?php if ( isset( $instance['comment_num'] ) ) : ?>
|
145 |
+
<p class="comment-num <?php if( !isset( $instance['disable_css'] ) ) { echo "cat-post-comment-num"; } ?>">
|
146 |
+
(<?php comments_number(); ?>)
|
147 |
+
</p>
|
148 |
+
<?php endif; ?>
|
149 |
+
</li>
|
150 |
+
<?php
|
151 |
+
}
|
152 |
+
|
153 |
+
echo "</ul>\n";
|
154 |
+
|
155 |
+
echo $after_widget;
|
156 |
+
|
157 |
+
remove_filter('excerpt_length', $new_excerpt_length);
|
158 |
+
|
159 |
+
if (function_exists ('wp_reset_postdata')) //wp_reset_postdata only exists in WordPress >3.0.0
|
160 |
+
wp_reset_postdata();
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Update the options
|
166 |
+
*
|
167 |
+
* @param array $new_instance
|
168 |
+
* @param array $old_instance
|
169 |
+
* @return array
|
170 |
+
*/
|
171 |
+
function update($new_instance, $old_instance) {
|
172 |
+
$sizes = get_option('mkrdip_cat_post_thumb_sizes');
|
173 |
+
|
174 |
+
if ( !$sizes ) {
|
175 |
+
$sizes = array();
|
176 |
+
}
|
177 |
+
|
178 |
+
$sizes[$this->id] = array($new_instance['thumb_w'], $new_instance['thumb_h']);
|
179 |
+
update_option('mkrdip_cat_post_thumb_sizes', $sizes);
|
180 |
+
|
181 |
+
return $new_instance;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* The widget configuration form back end.
|
186 |
+
*
|
187 |
+
* @param array $instance
|
188 |
+
* @return void
|
189 |
+
*/
|
190 |
+
function form($instance) {
|
191 |
+
$instance = wp_parse_args( ( array ) $instance, array(
|
192 |
+
'title' => __( '' ),
|
193 |
+
'cat' => __( '' ),
|
194 |
+
'num' => __( '' ),
|
195 |
+
'sort_by' => __( '' ),
|
196 |
+
'asc_sort_order' => __( '' ),
|
197 |
+
'title_link' => __( '' ),
|
198 |
+
'excerpt' => __( '' ),
|
199 |
+
'excerpt_length' => __( '' ),
|
200 |
+
'comment_num' => __( '' ),
|
201 |
+
'date' => __( '' ),
|
202 |
+
'thumb' => __( '' ),
|
203 |
+
'thumb_w' => __( '' ),
|
204 |
+
'thumb_h' => __( '' ),
|
205 |
+
'disable_css' => __( '' )
|
206 |
+
) );
|
207 |
+
|
208 |
+
$title = $instance['title'];
|
209 |
+
$cat = $instance['cat'];
|
210 |
+
$num = $instance['num'];
|
211 |
+
$sort_by = $instance['sort_by'];
|
212 |
+
$asc_sort_order = $instance['asc_sort_order'];
|
213 |
+
$title_link = $instance['title_link'];
|
214 |
+
$excerpt = $instance['excerpt'];
|
215 |
+
$excerpt_length = $instance['excerpt_length'];
|
216 |
+
$comment_num = $instance['comment_num'];
|
217 |
+
$date = $instance['date'];
|
218 |
+
$thumb = $instance['thumb'];
|
219 |
+
$thumb_w = $instance['thumb_w'];
|
220 |
+
$thumb_h = $instance['thumb_h'];
|
221 |
+
$disable_css = $instance['disable_css'];
|
222 |
+
|
223 |
+
?>
|
224 |
+
<p>
|
225 |
+
<label for="<?php echo $this->get_field_id("title"); ?>">
|
226 |
+
<?php _e( 'Title' ); ?>:
|
227 |
+
<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"]); ?>" />
|
228 |
+
</label>
|
229 |
+
</p>
|
230 |
+
<p>
|
231 |
+
<label>
|
232 |
+
<?php _e( 'Category' ); ?>:
|
233 |
+
<?php wp_dropdown_categories( array( 'name' => $this->get_field_name("cat"), 'selected' => $instance["cat"] ) ); ?>
|
234 |
+
</label>
|
235 |
+
</p>
|
236 |
+
<p>
|
237 |
+
<label for="<?php echo $this->get_field_id("num"); ?>">
|
238 |
+
<?php _e('Number of posts to show'); ?>:
|
239 |
+
<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' />
|
240 |
+
</label>
|
241 |
+
</p>
|
242 |
+
<p>
|
243 |
+
<label for="<?php echo $this->get_field_id("sort_by"); ?>">
|
244 |
+
<?php _e('Sort by'); ?>:
|
245 |
+
<select id="<?php echo $this->get_field_id("sort_by"); ?>" name="<?php echo $this->get_field_name("sort_by"); ?>">
|
246 |
+
<option value="date"<?php selected( $instance["sort_by"], "date" ); ?>>Date</option>
|
247 |
+
<option value="title"<?php selected( $instance["sort_by"], "title" ); ?>>Title</option>
|
248 |
+
<option value="comment_count"<?php selected( $instance["sort_by"], "comment_count" ); ?>>Number of comments</option>
|
249 |
+
<option value="rand"<?php selected( $instance["sort_by"], "rand" ); ?>>Random</option>
|
250 |
+
</select>
|
251 |
+
</label>
|
252 |
+
</p>
|
253 |
+
<p>
|
254 |
+
<label for="<?php echo $this->get_field_id("asc_sort_order"); ?>">
|
255 |
+
<input type="checkbox" class="checkbox"
|
256 |
+
id="<?php echo $this->get_field_id("asc_sort_order"); ?>"
|
257 |
+
name="<?php echo $this->get_field_name("asc_sort_order"); ?>"
|
258 |
+
<?php checked( (bool) $instance["asc_sort_order"], true ); ?> />
|
259 |
+
<?php _e( 'Reverse sort order (ascending)' ); ?>
|
260 |
+
</label>
|
261 |
+
</p>
|
262 |
+
<p>
|
263 |
+
<label for="<?php echo $this->get_field_id("title_link"); ?>">
|
264 |
+
<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 ); ?> />
|
265 |
+
<?php _e( 'Make widget title link' ); ?>
|
266 |
+
</label>
|
267 |
+
</p>
|
268 |
+
<p>
|
269 |
+
<label for="<?php echo $this->get_field_id("excerpt"); ?>">
|
270 |
+
<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 ); ?> />
|
271 |
+
<?php _e( 'Show post excerpt' ); ?>
|
272 |
+
</label>
|
273 |
+
</p>
|
274 |
+
<p>
|
275 |
+
<label for="<?php echo $this->get_field_id("excerpt_length"); ?>">
|
276 |
+
<?php _e( 'Excerpt length (in words):' ); ?>
|
277 |
+
</label>
|
278 |
+
<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" />
|
279 |
+
</p>
|
280 |
+
<p>
|
281 |
+
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
|
282 |
+
<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 ); ?> />
|
283 |
+
<?php _e( 'Show number of comments' ); ?>
|
284 |
+
</label>
|
285 |
+
</p>
|
286 |
+
<p>
|
287 |
+
<label for="<?php echo $this->get_field_id("date"); ?>">
|
288 |
+
<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 ); ?> />
|
289 |
+
<?php _e( 'Show post date' ); ?>
|
290 |
+
</label>
|
291 |
+
</p>
|
292 |
+
<?php if ( function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") ) : ?>
|
293 |
+
<p>
|
294 |
+
<label for="<?php echo $this->get_field_id("thumb"); ?>">
|
295 |
+
<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 ); ?> />
|
296 |
+
<?php _e( 'Show post thumbnail' ); ?>
|
297 |
+
</label>
|
298 |
+
</p>
|
299 |
+
<p>
|
300 |
+
<label>
|
301 |
+
<?php _e('Thumbnail dimensions (in pixels)'); ?>:<br />
|
302 |
+
<label for="<?php echo $this->get_field_id("thumb_w"); ?>">
|
303 |
+
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"]; ?>" />
|
304 |
+
</label>
|
305 |
+
|
306 |
+
<label for="<?php echo $this->get_field_id("thumb_h"); ?>">
|
307 |
+
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"]; ?>" />
|
308 |
+
</label>
|
309 |
+
</label>
|
310 |
+
</p>
|
311 |
+
<?php endif; ?>
|
312 |
+
<p>
|
313 |
+
<label for="<?php echo $this->get_field_id("disable_css"); ?>">
|
314 |
+
<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 ); ?> />
|
315 |
+
<?php _e( 'Disable widget CSS' ); ?>
|
316 |
+
</label>
|
317 |
+
</p>
|
318 |
+
<?php
|
319 |
+
|
320 |
+
}
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
add_action( 'widgets_init', create_function('', 'return register_widget("CategoryPosts");') );
|
readme.txt
CHANGED
@@ -1,102 +1,109 @@
|
|
1 |
-
|
2 |
-
Contributors: mkrdip
|
3 |
-
Donate link:
|
4 |
-
Tags: category, posts, widget, single category widget, posts widget, category recent posts
|
5 |
-
Requires at least: 2.8
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 4.0
|
8 |
-
License: GPLv2 or later
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
|
11 |
-
Adds a widget that shows the most recent posts from a single category.
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
Category Posts Widget is a light widget designed to do one thing and do it well: display the most recent posts from a certain category.
|
16 |
-
|
17 |
-
= Features =
|
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 =
|
30 |
-
While using this plugin if you find any bug or any conflict, please submit an issue at
|
31 |
-
[Github](https://github.com/mkrdip/category-posts-widget) (If possible with a pull request).
|
32 |
-
|
33 |
-
== Installation ==
|
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 |
-
|
45 |
-
= Manual installation =
|
46 |
-
|
47 |
-
1. Download the plugin.
|
48 |
-
2. Upload it to the plugins folder of your blog.
|
49 |
-
3. Activate the plugin through the 'Plugins' menu in WordPress
|
50 |
-
4. Now, goto the Widgets page of the Appearance section and configure the Category Posts widget.
|
51 |
-
|
52 |
-
== Upgrade Notice ==
|
53 |
-
|
54 |
-
* Please consider to re-configure the widget as the latest version has numerous changes from previous.
|
55 |
-
* Version 4.0 uses CSS file for styling the widget in front end.
|
56 |
-
* Version 3.0 or later version uses WordPress 2.9's built in post thumbnail functionality.
|
57 |
-
|
58 |
-
|
59 |
-
== Screenshots ==
|
60 |
-
|
61 |
-
1. The widget configuration dialog.
|
62 |
-
2. Front end of the widget using a default WordPress Theme.
|
63 |
-
|
64 |
-
== Changelog ==
|
65 |
-
|
66 |
-
4.0
|
67 |
-
|
68 |
-
* Added
|
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 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Category Posts Widget ===
|
2 |
+
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.0
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Adds a widget that shows the most recent posts from a single category.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
Category Posts Widget is a light widget designed to do one thing and do it well: display the most recent posts from a certain category.
|
16 |
+
|
17 |
+
= Features =
|
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 =
|
30 |
+
While using this plugin if you find any bug or any conflict, please submit an issue at
|
31 |
+
[Github](https://github.com/mkrdip/category-posts-widget) (If possible with a pull request).
|
32 |
+
|
33 |
+
== Installation ==
|
34 |
+
|
35 |
+
= Automatic installation =
|
36 |
+
|
37 |
+
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,
|
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've found plugin, you can install it by simply clicking “Install Now”.
|
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 |
+
|
45 |
+
= Manual installation =
|
46 |
+
|
47 |
+
1. Download the plugin.
|
48 |
+
2. Upload it to the plugins folder of your blog.
|
49 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress
|
50 |
+
4. Now, goto the Widgets page of the Appearance section and configure the Category Posts widget.
|
51 |
+
|
52 |
+
== Upgrade Notice ==
|
53 |
+
|
54 |
+
* Please consider to re-configure the widget as the latest version has numerous changes from previous.
|
55 |
+
* Version 4.0 uses CSS file for styling the widget in front end.
|
56 |
+
* Version 3.0 or later version uses WordPress 2.9's built in post thumbnail functionality.
|
57 |
+
|
58 |
+
|
59 |
+
== Screenshots ==
|
60 |
+
|
61 |
+
1. The widget configuration dialog.
|
62 |
+
2. Front end of the widget using a default WordPress Theme.
|
63 |
+
|
64 |
+
== Changelog ==
|
65 |
+
|
66 |
+
4.1.0
|
67 |
+
|
68 |
+
* Added PHP5 Constructor
|
69 |
+
* Added Option to allow/disallow widget CSS
|
70 |
+
* Now, compatible with WordPress 4.3
|
71 |
+
* Meet new plugin author [kometschuh](https://profiles.wordpress.org/kometschuh)
|
72 |
+
|
73 |
+
4.0
|
74 |
+
|
75 |
+
* Added CSS file for post styling
|
76 |
+
* Now compatible with latest versions of WordPress
|
77 |
+
|
78 |
+
3.3
|
79 |
+
|
80 |
+
* Fixed random sort bug.
|
81 |
+
|
82 |
+
3.2
|
83 |
+
|
84 |
+
* Added option to change ordering of posts. Defaults to showing newest posts first.
|
85 |
+
|
86 |
+
3.1
|
87 |
+
|
88 |
+
* Fixed a bug in the thumbnail size registration routine.
|
89 |
+
|
90 |
+
3.0
|
91 |
+
|
92 |
+
* Added support for WP 2.9's post thumbnail feature.
|
93 |
+
* Removed support for Simple Post Thumbnails plugin.
|
94 |
+
* Added option to show the post date.
|
95 |
+
* Added option to set the excerpt length.
|
96 |
+
* Added option to show the number of comments.
|
97 |
+
|
98 |
+
2.3
|
99 |
+
|
100 |
+
* Really tried to fix bug where wp_query global was getting over written by manually instantiating a WP_Query object
|
101 |
+
|
102 |
+
2.1
|
103 |
+
|
104 |
+
* Fixed bug where wp_query global was getting over written.
|
105 |
+
|
106 |
+
2.0
|
107 |
+
|
108 |
+
* Updated to use the WP 2.8 widget API.
|
109 |
+
* Added support for [Simple Post Thumbnails plugin](http://wordpress.org/extend/plugins/simple-post-thumbnails/).
|
screenshot-1.png
DELETED
Binary file
|