Version Description
- Fixes "Undefined index: tags_as_class". Thanks @vacuus for the Pull Request! :)
Download this release
Release Info
Developer | fernandobt |
Plugin | List category posts |
Version | 0.71.1 |
Comparing to | |
See all releases |
Code changes from version 0.71 to 0.71.1
- include/lcp-catlistdisplayer.php +1 -1
- include/lcp-widget-form.php +269 -253
- include/lcp-widget.php +121 -118
- list-category-posts.php +1 -1
- readme.txt +6 -2
include/lcp-catlistdisplayer.php
CHANGED
@@ -240,7 +240,7 @@ class CatListDisplayer {
|
|
240 |
$class = 'current';
|
241 |
}
|
242 |
|
243 |
-
if ( $this->params['tags_as_class'] == 'yes' ) {
|
244 |
$post_tags = wp_get_post_Tags($single->ID);
|
245 |
if ( !empty($post_tags) ){
|
246 |
foreach ($post_tags as $post_tag) {
|
240 |
$class = 'current';
|
241 |
}
|
242 |
|
243 |
+
if ( array_key_exists('tags_as_class', $this->params) && $this->params['tags_as_class'] == 'yes' ) {
|
244 |
$post_tags = wp_get_post_Tags($single->ID);
|
245 |
if ( !empty($post_tags) ){
|
246 |
foreach ($post_tags as $post_tag) {
|
include/lcp-widget-form.php
CHANGED
@@ -1,253 +1,269 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* List Category Posts sidebar widget form for Appearance > Widgets.
|
4 |
-
* @author fernando@picandocodigo.net
|
5 |
-
*/
|
6 |
-
$default = array (
|
7 |
-
'title' => '',
|
8 |
-
'categoryid' => '',
|
9 |
-
'limit' => '',
|
10 |
-
'orderby'=>'',
|
11 |
-
'order'=>'',
|
12 |
-
'show_date'=>'',
|
13 |
-
'show_modified_date'=>'',
|
14 |
-
'show_author'=>'',
|
15 |
-
'show_excerpt'=>'',
|
16 |
-
'excerpt_size' =>'',
|
17 |
-
'exclude'=>'',
|
18 |
-
'excludeposts'=>'',
|
19 |
-
'thumbnail' =>'',
|
20 |
-
'thumbnail_size' =>'',
|
21 |
-
'offset'=>'',
|
22 |
-
'show_catlink'=>'',
|
23 |
-
'morelink' =>'',
|
24 |
-
'
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
$
|
30 |
-
$
|
31 |
-
$
|
32 |
-
$
|
33 |
-
$
|
34 |
-
$
|
35 |
-
$
|
36 |
-
$
|
37 |
-
$
|
38 |
-
$
|
39 |
-
$
|
40 |
-
$
|
41 |
-
$
|
42 |
-
$
|
43 |
-
$
|
44 |
-
$
|
45 |
-
$
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
$option .=
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
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 |
-
echo
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
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 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* List Category Posts sidebar widget form for Appearance > Widgets.
|
4 |
+
* @author fernando@picandocodigo.net
|
5 |
+
*/
|
6 |
+
$default = array (
|
7 |
+
'title' => '',
|
8 |
+
'categoryid' => '',
|
9 |
+
'limit' => '',
|
10 |
+
'orderby'=>'',
|
11 |
+
'order'=>'',
|
12 |
+
'show_date'=>'',
|
13 |
+
'show_modified_date'=>'',
|
14 |
+
'show_author'=>'',
|
15 |
+
'show_excerpt'=>'',
|
16 |
+
'excerpt_size' =>'',
|
17 |
+
'exclude'=>'',
|
18 |
+
'excludeposts'=>'',
|
19 |
+
'thumbnail' =>'',
|
20 |
+
'thumbnail_size' =>'',
|
21 |
+
'offset'=>'',
|
22 |
+
'show_catlink'=>'',
|
23 |
+
'morelink' =>'',
|
24 |
+
'tags_as_class' => '',
|
25 |
+
'template' => '',
|
26 |
+
);
|
27 |
+
$instance = wp_parse_args( (array) $instance, $default);
|
28 |
+
|
29 |
+
$title = strip_tags($instance['title']);
|
30 |
+
$limit = strip_tags($instance['limit']);
|
31 |
+
$orderby = strip_tags($instance['orderby']);
|
32 |
+
$order = strip_tags($instance['order']);
|
33 |
+
$showdate = strip_tags($instance['show_date']);
|
34 |
+
$showmodifieddate = strip_tags($instance['show_modified_date']);
|
35 |
+
$showauthor = strip_tags($instance['show_author']);
|
36 |
+
$exclude = strip_tags($instance['exclude']);
|
37 |
+
$excludeposts = strip_tags($instance['excludeposts']);
|
38 |
+
$offset = strip_tags($instance['offset']);
|
39 |
+
$showcatlink = strip_tags($instance['show_catlink']);
|
40 |
+
$categoryid = strip_tags($instance['categoryid']);
|
41 |
+
$showexcerpt = strip_tags($instance['show_excerpt']);
|
42 |
+
$excerptsize = strip_tags($instance['excerpt_size']);
|
43 |
+
$thumbnail = strip_tags($instance['thumbnail']);
|
44 |
+
$thumbnail_size = strip_tags($instance['thumbnail_size']);
|
45 |
+
$morelink = strip_tags($instance['morelink']);
|
46 |
+
$tags_as_class = strip_tags($instance['tags_as_class']);
|
47 |
+
$template = strip_tags($instance['template']);
|
48 |
+
|
49 |
+
?>
|
50 |
+
|
51 |
+
<p>
|
52 |
+
<label for="<?php echo $this->get_field_id('title'); ?>">
|
53 |
+
<?php _e("Title", 'list-category-posts')?>
|
54 |
+
</label>
|
55 |
+
<br/>
|
56 |
+
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
|
57 |
+
name="<?php echo $this->get_field_name('title'); ?>" type="text"
|
58 |
+
value="<?php echo esc_attr($title); ?>" />
|
59 |
+
</p>
|
60 |
+
|
61 |
+
<p>
|
62 |
+
<label for="<?php echo $this->get_field_id('categoryid'); ?>">
|
63 |
+
<?php _e("Category", 'list-category-posts')?>
|
64 |
+
</label>
|
65 |
+
<br/>
|
66 |
+
<select id="<?php echo $this->get_field_id('categoryid'); ?>" name="<?php echo $this->get_field_name('categoryid'); ?>">
|
67 |
+
<?php
|
68 |
+
$categories= get_categories();
|
69 |
+
$option = '<option value="-1"';
|
70 |
+
if ($categoryid == -1) :
|
71 |
+
$option .= ' selected = "selected" ';
|
72 |
+
endif;
|
73 |
+
$option .= '">' . "Current category" . '</option>';
|
74 |
+
echo $option;
|
75 |
+
|
76 |
+
foreach ($categories as $cat) :
|
77 |
+
$option = '<option value="' . $cat->cat_ID . '" ';
|
78 |
+
if ($cat->cat_ID == $categoryid) :
|
79 |
+
$option .= ' selected = "selected" ';
|
80 |
+
endif;
|
81 |
+
$option .= '">';
|
82 |
+
$option .= $cat->cat_name;
|
83 |
+
$option .= '</option>';
|
84 |
+
echo $option;
|
85 |
+
endforeach;
|
86 |
+
?>
|
87 |
+
</select>
|
88 |
+
</p>
|
89 |
+
|
90 |
+
<p>
|
91 |
+
<label for="<?php echo $this->get_field_id('limit'); ?>">
|
92 |
+
<?php _e("Number of posts", 'list-category-posts')?>
|
93 |
+
</label>
|
94 |
+
<br/>
|
95 |
+
<input size="2" id="<?php echo $this->get_field_id('limit'); ?>"
|
96 |
+
name="<?php echo $this->get_field_name('limit'); ?>" type="text"
|
97 |
+
value="<?php echo esc_attr($limit); ?>" />
|
98 |
+
</p>
|
99 |
+
|
100 |
+
<p>
|
101 |
+
<label for="<?php echo $this->get_field_id('offset'); ?>">
|
102 |
+
<?php _e("Offset", 'list-category-posts')?>: <br/>
|
103 |
+
<input size="2" id="<?php echo $this->get_field_id('offset'); ?>"
|
104 |
+
name="<?php echo $this->get_field_name('offset'); ?>" type="text"
|
105 |
+
value="<?php echo esc_attr($offset); ?>" />
|
106 |
+
</label>
|
107 |
+
</p>
|
108 |
+
|
109 |
+
<p>
|
110 |
+
<label for="<?php echo $this->get_field_id('orderby'); ?>">
|
111 |
+
<?php _e("Order by", 'list-category-posts')?>
|
112 |
+
</label> <br/>
|
113 |
+
<select id="<?php echo $this->get_field_id('orderby'); ?>"
|
114 |
+
name="<?php echo $this->get_field_name('orderby'); ?>" type="text" >
|
115 |
+
<?php $lcp_orders = array("date" => __("Date", "list-category-posts"),
|
116 |
+
"modified" => __("Modified Date", "list-category-posts"),
|
117 |
+
"title" => __("Post title", "list-category-posts"),
|
118 |
+
"author" => __("Author", "list-category-posts"),
|
119 |
+
"rand" => __("Random", "list-category-posts"));
|
120 |
+
foreach ($lcp_orders as $key=>$value):
|
121 |
+
$option = '<option value="' . $key . '" ';
|
122 |
+
if ($orderby == $key):
|
123 |
+
$option .= ' selected = "selected" ';
|
124 |
+
endif;
|
125 |
+
$option .= '>';
|
126 |
+
echo $option;
|
127 |
+
_e($value, 'list-category-posts');
|
128 |
+
echo '</option>';
|
129 |
+
endforeach;
|
130 |
+
?>
|
131 |
+
</select>
|
132 |
+
</p>
|
133 |
+
|
134 |
+
<p>
|
135 |
+
<label for="<?php echo $this->get_field_id('order'); ?>">
|
136 |
+
<?php _e("Order", 'list-category-posts')?>
|
137 |
+
</label>
|
138 |
+
<br/>
|
139 |
+
<select id="<?php echo $this->get_field_id('order'); ?>"
|
140 |
+
name="<?php echo $this->get_field_name('order'); ?>" type="text">
|
141 |
+
<option value='desc' <?php if($order == 'desc'): echo "selected: selected"; endif;?>>
|
142 |
+
<?php _e("Descending", 'list-category-posts')?>
|
143 |
+
</option>
|
144 |
+
<option value='asc' <?php if($order == 'asc'): echo "selected: selected"; endif; ?>>
|
145 |
+
<?php _e("Ascending", 'list-category-posts')?>
|
146 |
+
</option>
|
147 |
+
</select>
|
148 |
+
</p>
|
149 |
+
|
150 |
+
<p>
|
151 |
+
<label for="<?php echo $this->get_field_id('exclude'); ?>">
|
152 |
+
<?php _e("Exclude categories (id's)", 'list-category-posts')?>
|
153 |
+
</label>
|
154 |
+
<br/>
|
155 |
+
<input id="<?php echo $this->get_field_id('exclude'); ?>"
|
156 |
+
name="<?php echo $this->get_field_name('exclude'); ?>" type="text"
|
157 |
+
value="<?php echo esc_attr($exclude); ?>" />
|
158 |
+
</p>
|
159 |
+
|
160 |
+
<p>
|
161 |
+
<label for="<?php echo $this->get_field_id('excludeposts'); ?>">
|
162 |
+
<?php _e("Exclude posts (id's)", 'list-category-posts')?>
|
163 |
+
</label>
|
164 |
+
<br/>
|
165 |
+
<input id="<?php echo $this->get_field_id('excludeposts'); ?>"
|
166 |
+
name="<?php echo $this->get_field_name('excludeposts'); ?>" type="text"
|
167 |
+
value="<?php echo esc_attr($excludeposts); ?>" />
|
168 |
+
</p>
|
169 |
+
|
170 |
+
<p>
|
171 |
+
<?php $image_sizes = get_intermediate_image_sizes() ?>
|
172 |
+
<label><?php _e("Show", 'list-category-posts')?>: </label><br/>
|
173 |
+
<input type="checkbox" <?php checked( (bool) $instance['thumbnail'], true ); ?>
|
174 |
+
name="<?php echo $this->get_field_name( 'thumbnail'); ?>" /> <?php _e("Thumbnail - size", 'list-category-posts')?>
|
175 |
+
<select id="<?php echo $this->get_field_id('thumbnail_size'); ?>"
|
176 |
+
name="<?php echo $this->get_field_name( 'thumbnail_size' ); ?>" type="text">
|
177 |
+
<?php foreach($image_sizes as $image_size) { ?>
|
178 |
+
<option value='<?php echo $image_size ?>' <?php
|
179 |
+
if($thumbnail_size == $image_size) echo 'selected';
|
180 |
+
?>><?php echo $image_size ?></option>
|
181 |
+
<?php } ?>
|
182 |
+
</select>
|
183 |
+
</p>
|
184 |
+
|
185 |
+
<p>
|
186 |
+
<input class="checkbox" type="checkbox"
|
187 |
+
<?php checked( (bool) $instance['show_date'], true ); ?>
|
188 |
+
name="<?php echo $this->get_field_name( 'show_date' ); ?>" />
|
189 |
+
<?php _e("Date", 'list-category-posts')?>
|
190 |
+
</p>
|
191 |
+
<p>
|
192 |
+
<input class="checkbox" type="checkbox"
|
193 |
+
<?php checked( (bool) $instance['show_modified_date'], true ); ?>
|
194 |
+
name="<?php echo $this->get_field_name( 'show_modified_date' ); ?>" />
|
195 |
+
<?php _e("Modified Date", 'list-category-posts')?>
|
196 |
+
</p>
|
197 |
+
<p>
|
198 |
+
<input class="checkbox" input type="checkbox"
|
199 |
+
<?php checked( (bool) $instance['show_author'], true ); ?>
|
200 |
+
name="<?php echo $this->get_field_name( 'show_author' ); ?>" />
|
201 |
+
<?php _e("Author", 'list-category-posts')?>
|
202 |
+
</p>
|
203 |
+
<p>
|
204 |
+
<input class="checkbox" input type="checkbox"
|
205 |
+
<?php checked( (bool) $instance['show_catlink'], true ); ?>
|
206 |
+
name="<?php echo $this->get_field_name( 'show_catlink' ); ?>" />
|
207 |
+
<?php _e("Link to category (use 'catlink' on the title field if you want the title of this widget to be a link to the category)", 'list-category-posts')?>
|
208 |
+
</p>
|
209 |
+
<p>
|
210 |
+
<input class="checkbox" input type="checkbox"
|
211 |
+
<?php checked( (bool) $instance['show_excerpt'], true ); ?>
|
212 |
+
name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" />
|
213 |
+
<?php _e("Excerpt", 'list-category-posts')?>
|
214 |
+
</p>
|
215 |
+
<p>
|
216 |
+
<label for="<?php echo $this->get_field_id('excerpt_size'); ?>">
|
217 |
+
<?php _e("Excerpt size", 'list-category-posts')?>:
|
218 |
+
</label>
|
219 |
+
<br/>
|
220 |
+
<input class="widefat" id="<?php echo $this->get_field_id('excerpt_size'); ?>"
|
221 |
+
name="<?php echo $this->get_field_name('excerpt_size'); ?>" type="text"
|
222 |
+
value="<?php echo esc_attr($excerptsize); ?>" />
|
223 |
+
</p>
|
224 |
+
<p>
|
225 |
+
<label for="<?php echo $this->get_field_id('morelink'); ?>">
|
226 |
+
<?php _e("More link", 'list-category-posts')?>:
|
227 |
+
</label>
|
228 |
+
<br/>
|
229 |
+
<input class="widefat" id="<?php echo $this->get_field_id('morelink'); ?>"
|
230 |
+
name="<?php echo $this->get_field_name('morelink'); ?>" type="text"
|
231 |
+
value="<?php echo esc_attr($morelink); ?>" />
|
232 |
+
</p>
|
233 |
+
<p>
|
234 |
+
<label for="<?php echo $this->get_field_id('tags_as_class'); ?>">
|
235 |
+
<?php _e("Tags as class", 'list-category-posts'); ?>:
|
236 |
+
</label>
|
237 |
+
<br/>
|
238 |
+
<select id="<?php echo $this->get_field_id('tags_as_class'); ?>" name="<?php echo $this->get_field_name('tags_as_class'); ?>" type="text">
|
239 |
+
<option value='no' <?php if($tags_as_class == 'no'): echo "selected: selected"; endif;?>>
|
240 |
+
<?php _e("No", 'list-category-posts')?>
|
241 |
+
</option>
|
242 |
+
<option value='yes' <?php if($tags_as_class == 'yes'): echo "selected: selected"; endif;?>>
|
243 |
+
<?php _e("Yes", 'list-category-posts')?>
|
244 |
+
</option>
|
245 |
+
</select>
|
246 |
+
</p>
|
247 |
+
|
248 |
+
<p>
|
249 |
+
<label for="<?php echo $this->get_field_id('template'); ?>">
|
250 |
+
<?php _e("Template", 'list-category-posts')?>:
|
251 |
+
</label>
|
252 |
+
<br/>
|
253 |
+
<select id="<?php echo $this->get_field_id('template'); ?>" name="<?php echo $this->get_field_name('template'); ?>">
|
254 |
+
<?php
|
255 |
+
$templates = CatListDisplayer::get_templates();
|
256 |
+
$templates[] = 'default';
|
257 |
+
foreach ($templates as $tmp) :
|
258 |
+
$option = '<option value="' . $tmp . '" ';
|
259 |
+
if ($tmp == $template) :
|
260 |
+
$option .= ' selected = "selected" ';
|
261 |
+
endif;
|
262 |
+
$option .= '">';
|
263 |
+
$option .= $tmp;
|
264 |
+
$option .= '</option>';
|
265 |
+
echo $option;
|
266 |
+
endforeach;
|
267 |
+
?>
|
268 |
+
</select>
|
269 |
+
</p>
|
include/lcp-widget.php
CHANGED
@@ -1,118 +1,121 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* List Category Posts sidebar widget.
|
4 |
-
* @author fernando@picandocodigo.net
|
5 |
-
*/
|
6 |
-
require_once 'lcp-catlistdisplayer.php';
|
7 |
-
|
8 |
-
class ListCategoryPostsWidget extends WP_Widget{
|
9 |
-
|
10 |
-
function __construct() {
|
11 |
-
$opts = array('description' => __('List posts from a specified category','list-category-posts') );
|
12 |
-
parent::__construct(false, $name = __('List Category Posts','list-category-posts'), $opts);
|
13 |
-
}
|
14 |
-
|
15 |
-
function widget($args, $instance) {
|
16 |
-
global $post;
|
17 |
-
extract( $args );
|
18 |
-
|
19 |
-
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
|
20 |
-
$limit = (is_numeric($instance['limit'])) ? $instance['limit'] : 5;
|
21 |
-
$orderby = ($instance['orderby']) ? $instance['orderby'] : 'date';
|
22 |
-
$order = ($instance['order']) ? $instance['order'] : 'desc';
|
23 |
-
$exclude = ($instance['exclude'] != '') ? $instance['exclude'] : 0;
|
24 |
-
if($instance['excludeposts'] == 'current')
|
25 |
-
$excludeposts = $post->ID;
|
26 |
-
if(!isset($excludeposts))
|
27 |
-
$excludeposts = ($instance['excludeposts'] != '') ? $instance['excludeposts'] : 0;
|
28 |
-
$offset = (is_numeric($instance['offset'])) ? $instance['offset'] : 0;
|
29 |
-
$category_id = $instance['categoryid'];
|
30 |
-
$dateformat = ($instance['dateformat']) ? $instance['dateformat'] : get_option('date_format');
|
31 |
-
$showdate = ($instance['show_date'] == 'on') ? 'yes' : 'no';
|
32 |
-
$showmodifieddate = ($instance['show_modified_date'] == 'on') ? 'yes' : 'no';
|
33 |
-
$showexcerpt = ($instance['show_excerpt'] == 'on') ? 'yes' : 'no';
|
34 |
-
$excerptsize = (empty($instance['excerpt_size']) ? 55 : $instance['excerpt_size']);
|
35 |
-
$showauthor = ($instance['show_author'] == 'on') ? 'yes' : 'no';
|
36 |
-
$showcatlink = ($instance['show_catlink'] == 'on') ? 'yes' : 'no';
|
37 |
-
$thumbnail = ($instance['thumbnail'] == 'on') ? 'yes' : 'no';
|
38 |
-
$thumbnail_size = ($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 'thumbnail';
|
39 |
-
$morelink = empty($instance['morelink']) ? ' ' : $instance['morelink'];
|
40 |
-
$
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
'
|
45 |
-
'
|
46 |
-
'
|
47 |
-
'
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
'
|
52 |
-
'
|
53 |
-
'
|
54 |
-
'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
'
|
61 |
-
'
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
$instance
|
90 |
-
$instance['
|
91 |
-
$instance['
|
92 |
-
$instance['
|
93 |
-
$instance['
|
94 |
-
$instance['
|
95 |
-
$instance['
|
96 |
-
$instance['
|
97 |
-
$instance['
|
98 |
-
$instance['
|
99 |
-
$instance['
|
100 |
-
$instance['
|
101 |
-
$instance['
|
102 |
-
$instance['
|
103 |
-
$instance['
|
104 |
-
$instance['
|
105 |
-
$instance['
|
106 |
-
$instance['
|
107 |
-
$instance['
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* List Category Posts sidebar widget.
|
4 |
+
* @author fernando@picandocodigo.net
|
5 |
+
*/
|
6 |
+
require_once 'lcp-catlistdisplayer.php';
|
7 |
+
|
8 |
+
class ListCategoryPostsWidget extends WP_Widget{
|
9 |
+
|
10 |
+
function __construct() {
|
11 |
+
$opts = array('description' => __('List posts from a specified category','list-category-posts') );
|
12 |
+
parent::__construct(false, $name = __('List Category Posts','list-category-posts'), $opts);
|
13 |
+
}
|
14 |
+
|
15 |
+
function widget($args, $instance) {
|
16 |
+
global $post;
|
17 |
+
extract( $args );
|
18 |
+
|
19 |
+
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
|
20 |
+
$limit = (is_numeric($instance['limit'])) ? $instance['limit'] : 5;
|
21 |
+
$orderby = ($instance['orderby']) ? $instance['orderby'] : 'date';
|
22 |
+
$order = ($instance['order']) ? $instance['order'] : 'desc';
|
23 |
+
$exclude = ($instance['exclude'] != '') ? $instance['exclude'] : 0;
|
24 |
+
if($instance['excludeposts'] == 'current')
|
25 |
+
$excludeposts = $post->ID;
|
26 |
+
if(!isset($excludeposts))
|
27 |
+
$excludeposts = ($instance['excludeposts'] != '') ? $instance['excludeposts'] : 0;
|
28 |
+
$offset = (is_numeric($instance['offset'])) ? $instance['offset'] : 0;
|
29 |
+
$category_id = $instance['categoryid'];
|
30 |
+
$dateformat = ($instance['dateformat']) ? $instance['dateformat'] : get_option('date_format');
|
31 |
+
$showdate = ($instance['show_date'] == 'on') ? 'yes' : 'no';
|
32 |
+
$showmodifieddate = ($instance['show_modified_date'] == 'on') ? 'yes' : 'no';
|
33 |
+
$showexcerpt = ($instance['show_excerpt'] == 'on') ? 'yes' : 'no';
|
34 |
+
$excerptsize = (empty($instance['excerpt_size']) ? 55 : $instance['excerpt_size']);
|
35 |
+
$showauthor = ($instance['show_author'] == 'on') ? 'yes' : 'no';
|
36 |
+
$showcatlink = ($instance['show_catlink'] == 'on') ? 'yes' : 'no';
|
37 |
+
$thumbnail = ($instance['thumbnail'] == 'on') ? 'yes' : 'no';
|
38 |
+
$thumbnail_size = ($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 'thumbnail';
|
39 |
+
$morelink = empty($instance['morelink']) ? ' ' : $instance['morelink'];
|
40 |
+
$tags_as_class = ($instance['tags_as_class'] == 'yes') ? 'yes' : 'no';
|
41 |
+
$template = empty($instance['template']) ? 'default' : $instance['template'];
|
42 |
+
|
43 |
+
$atts = array(
|
44 |
+
'id' => $category_id,
|
45 |
+
'orderby' => $orderby,
|
46 |
+
'order' => $order,
|
47 |
+
'numberposts' => $limit,
|
48 |
+
'date' => $showdate,
|
49 |
+
'date_modified' => $showmodifieddate,
|
50 |
+
'author' => $showauthor,
|
51 |
+
'dateformat' => $dateformat,
|
52 |
+
'template' => 'default',
|
53 |
+
'excerpt' => $showexcerpt,
|
54 |
+
'excerpt_size' => $excerptsize,
|
55 |
+
'exclude' => $exclude,
|
56 |
+
'excludeposts' => $excludeposts,
|
57 |
+
'offset' => $offset,
|
58 |
+
'catlink' => $showcatlink,
|
59 |
+
'thumbnail' => $thumbnail,
|
60 |
+
'thumbnail_size' => $thumbnail_size,
|
61 |
+
'morelink' => $morelink,
|
62 |
+
'tags_as_class' => $tags_as_class,
|
63 |
+
'template' => $template,
|
64 |
+
);
|
65 |
+
|
66 |
+
echo $before_widget;
|
67 |
+
|
68 |
+
if ($title == 'catlink') {
|
69 |
+
// If the user has setup 'catlink' as the title, replace it with
|
70 |
+
// the category link:
|
71 |
+
$lcp_category = get_category($category_id);
|
72 |
+
$title = '<a href="' . get_category_link($lcp_category->cat_ID) . '">' .
|
73 |
+
$lcp_category->name . '</a>';
|
74 |
+
} elseif ($title == 'catname') {
|
75 |
+
// If the user has setup 'catname' as the title, replace it with
|
76 |
+
// the category link:
|
77 |
+
$lcp_category = get_the_category($post->ID);
|
78 |
+
$title = $lcp_category[0]->name;
|
79 |
+
}
|
80 |
+
echo $before_title . $title . $after_title;
|
81 |
+
|
82 |
+
$catlist_displayer = new CatListDisplayer($atts);
|
83 |
+
echo $catlist_displayer->display();
|
84 |
+
echo $after_widget;
|
85 |
+
}
|
86 |
+
|
87 |
+
/** @see WP_Widget::update */
|
88 |
+
function update($new_instance, $old_instance) {
|
89 |
+
$instance = $old_instance;
|
90 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
91 |
+
$instance['limit'] = strip_tags($new_instance['limit']);
|
92 |
+
$instance['orderby'] = strip_tags($new_instance['orderby']);
|
93 |
+
$instance['order'] = strip_tags($new_instance['order']);
|
94 |
+
$instance['exclude'] = strip_tags($new_instance['exclude']);
|
95 |
+
$instance['excludeposts'] = strip_tags($new_instance['excludeposts']);
|
96 |
+
$instance['offset'] = strip_tags($new_instance['offset']);
|
97 |
+
$instance['categoryid'] = strip_tags($new_instance['categoryid']);
|
98 |
+
$instance['dateformat'] = strip_tags($new_instance['dateformat']);
|
99 |
+
$instance['show_date'] = strip_tags($new_instance['show_date']);
|
100 |
+
$instance['show_modified_date'] = strip_tags($new_instance['show_modified_date']);
|
101 |
+
$instance['show_excerpt'] = strip_tags($new_instance['show_excerpt']);
|
102 |
+
$instance['excerpt_size'] = strip_tags($new_instance['excerpt_size']);
|
103 |
+
$instance['show_author'] = strip_tags($new_instance['show_author']);
|
104 |
+
$instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
|
105 |
+
$instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
|
106 |
+
$instance['thumbnail'] = strip_tags($new_instance['thumbnail']);
|
107 |
+
$instance['thumbnail_size'] = strip_tags($new_instance['thumbnail_size']);
|
108 |
+
$instance['morelink'] = strip_tags($new_instance['morelink']);
|
109 |
+
$instance['tags_as_class'] = strip_tags($new_instance['tags_as_class']);
|
110 |
+
$instance['template'] = strip_tags($new_instance['template']);
|
111 |
+
|
112 |
+
return $instance;
|
113 |
+
}
|
114 |
+
|
115 |
+
/** @see WP_Widget::form */
|
116 |
+
function form($instance) {
|
117 |
+
include('lcp-widget-form.php');
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
add_action('widgets_init', create_function('', 'return register_widget("listCategoryPostsWidget");'));
|
list-category-posts.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: List category posts
|
4 |
Plugin URI: https://github.com/picandocodigo/List-Category-Posts
|
5 |
Description: List Category Posts allows you to list posts by category in a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
|
6 |
-
Version: 0.71
|
7 |
Author: Fernando Briano
|
8 |
Author URI: http://fernandobriano.com
|
9 |
|
3 |
Plugin Name: List category posts
|
4 |
Plugin URI: https://github.com/picandocodigo/List-Category-Posts
|
5 |
Description: List Category Posts allows you to list posts by category in a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
|
6 |
+
Version: 0.71.1
|
7 |
Author: Fernando Briano
|
8 |
Author URI: http://fernandobriano.com
|
9 |
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: fernandobt
|
|
3 |
Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/#support
|
4 |
Tags: list, categories, posts, cms
|
5 |
Requires at least: 3.3
|
6 |
-
Tested up to: 4.7
|
7 |
-
Stable tag: 0.71
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -458,6 +458,10 @@ Template system has changed. Custom templates should be stored in WordPress them
|
|
458 |
|
459 |
== Changelog ==
|
460 |
|
|
|
|
|
|
|
|
|
461 |
= 0.71 =
|
462 |
|
463 |
* Added tags_as_class: Use a post's tags as a class for the li that lists the posts. Default is no. Thanks @vacuus on GitHub for this PR!
|
3 |
Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/#support
|
4 |
Tags: list, categories, posts, cms
|
5 |
Requires at least: 3.3
|
6 |
+
Tested up to: 4.7.2
|
7 |
+
Stable tag: 0.71.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
458 |
|
459 |
== Changelog ==
|
460 |
|
461 |
+
= 0.71.1 =
|
462 |
+
|
463 |
+
* Fixes ["Undefined index: tags_as_class"](https://github.com/picandocodigo/List-Category-Posts/issues/227). Thanks @vacuus for the Pull Request! :)
|
464 |
+
|
465 |
= 0.71 =
|
466 |
|
467 |
* Added tags_as_class: Use a post's tags as a class for the li that lists the posts. Default is no. Thanks @vacuus on GitHub for this PR!
|