List category posts - Version 0.71.1

Version Description

  • Fixes "Undefined index: tags_as_class". Thanks @vacuus for the Pull Request! :)
Download this release

Release Info

Developer fernandobt
Plugin Icon 128x128 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 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
- 'template' => ''
25
- );
26
- $instance = wp_parse_args( (array) $instance, $default);
27
-
28
- $title = strip_tags($instance['title']);
29
- $limit = strip_tags($instance['limit']);
30
- $orderby = strip_tags($instance['orderby']);
31
- $order = strip_tags($instance['order']);
32
- $showdate = strip_tags($instance['show_date']);
33
- $showmodifieddate = strip_tags($instance['show_modified_date']);
34
- $showauthor = strip_tags($instance['show_author']);
35
- $exclude = strip_tags($instance['exclude']);
36
- $excludeposts = strip_tags($instance['excludeposts']);
37
- $offset = strip_tags($instance['offset']);
38
- $showcatlink = strip_tags($instance['show_catlink']);
39
- $categoryid = strip_tags($instance['categoryid']);
40
- $showexcerpt = strip_tags($instance['show_excerpt']);
41
- $excerptsize = strip_tags($instance['excerpt_size']);
42
- $thumbnail = strip_tags($instance['thumbnail']);
43
- $thumbnail_size = strip_tags($instance['thumbnail_size']);
44
- $morelink = strip_tags($instance['morelink']);
45
- $template = strip_tags($instance['template']);
46
-
47
- ?>
48
-
49
- <p>
50
- <label for="<?php echo $this->get_field_id('title'); ?>">
51
- <?php _e("Title", 'list-category-posts')?>
52
- </label>
53
- <br/>
54
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
55
- name="<?php echo $this->get_field_name('title'); ?>" type="text"
56
- value="<?php echo esc_attr($title); ?>" />
57
- </p>
58
-
59
- <p>
60
- <label for="<?php echo $this->get_field_id('categoryid'); ?>">
61
- <?php _e("Category", 'list-category-posts')?>
62
- </label>
63
- <br/>
64
- <select id="<?php echo $this->get_field_id('categoryid'); ?>" name="<?php echo $this->get_field_name('categoryid'); ?>">
65
- <?php
66
- $categories= get_categories();
67
- $option = '<option value="-1"';
68
- if ($categoryid == -1) :
69
- $option .= ' selected = "selected" ';
70
- endif;
71
- $option .= '">' . "Current category" . '</option>';
72
- echo $option;
73
-
74
- foreach ($categories as $cat) :
75
- $option = '<option value="' . $cat->cat_ID . '" ';
76
- if ($cat->cat_ID == $categoryid) :
77
- $option .= ' selected = "selected" ';
78
- endif;
79
- $option .= '">';
80
- $option .= $cat->cat_name;
81
- $option .= '</option>';
82
- echo $option;
83
- endforeach;
84
- ?>
85
- </select>
86
- </p>
87
-
88
- <p>
89
- <label for="<?php echo $this->get_field_id('limit'); ?>">
90
- <?php _e("Number of posts", 'list-category-posts')?>
91
- </label>
92
- <br/>
93
- <input size="2" id="<?php echo $this->get_field_id('limit'); ?>"
94
- name="<?php echo $this->get_field_name('limit'); ?>" type="text"
95
- value="<?php echo esc_attr($limit); ?>" />
96
- </p>
97
-
98
- <p>
99
- <label for="<?php echo $this->get_field_id('offset'); ?>">
100
- <?php _e("Offset", 'list-category-posts')?>: <br/>
101
- <input size="2" id="<?php echo $this->get_field_id('offset'); ?>"
102
- name="<?php echo $this->get_field_name('offset'); ?>" type="text"
103
- value="<?php echo esc_attr($offset); ?>" />
104
- </label>
105
- </p>
106
-
107
- <p>
108
- <label for="<?php echo $this->get_field_id('orderby'); ?>">
109
- <?php _e("Order by", 'list-category-posts')?>
110
- </label> <br/>
111
- <select id="<?php echo $this->get_field_id('orderby'); ?>"
112
- name="<?php echo $this->get_field_name('orderby'); ?>" type="text" >
113
- <?php $lcp_orders = array("date" => __("Date", "list-category-posts"),
114
- "modified" => __("Modified Date", "list-category-posts"),
115
- "title" => __("Post title", "list-category-posts"),
116
- "author" => __("Author", "list-category-posts"),
117
- "rand" => __("Random", "list-category-posts"));
118
- foreach ($lcp_orders as $key=>$value):
119
- $option = '<option value="' . $key . '" ';
120
- if ($orderby == $key):
121
- $option .= ' selected = "selected" ';
122
- endif;
123
- $option .= '>';
124
- echo $option;
125
- _e($value, 'list-category-posts');
126
- echo '</option>';
127
- endforeach;
128
- ?>
129
- </select>
130
- </p>
131
-
132
- <p>
133
- <label for="<?php echo $this->get_field_id('order'); ?>">
134
- <?php _e("Order", 'list-category-posts')?>
135
- </label>
136
- <br/>
137
- <select id="<?php echo $this->get_field_id('order'); ?>"
138
- name="<?php echo $this->get_field_name('order'); ?>" type="text">
139
- <option value='desc' <?php if($order == 'desc'): echo "selected: selected"; endif;?>>
140
- <?php _e("Descending", 'list-category-posts')?>
141
- </option>
142
- <option value='asc' <?php if($order == 'asc'): echo "selected: selected"; endif; ?>>
143
- <?php _e("Ascending", 'list-category-posts')?>
144
- </option>
145
- </select>
146
- </p>
147
-
148
- <p>
149
- <label for="<?php echo $this->get_field_id('exclude'); ?>">
150
- <?php _e("Exclude categories (id's)", 'list-category-posts')?>
151
- </label>
152
- <br/>
153
- <input id="<?php echo $this->get_field_id('exclude'); ?>"
154
- name="<?php echo $this->get_field_name('exclude'); ?>" type="text"
155
- value="<?php echo esc_attr($exclude); ?>" />
156
- </p>
157
-
158
- <p>
159
- <label for="<?php echo $this->get_field_id('excludeposts'); ?>">
160
- <?php _e("Exclude posts (id's)", 'list-category-posts')?>
161
- </label>
162
- <br/>
163
- <input id="<?php echo $this->get_field_id('excludeposts'); ?>"
164
- name="<?php echo $this->get_field_name('excludeposts'); ?>" type="text"
165
- value="<?php echo esc_attr($excludeposts); ?>" />
166
- </p>
167
-
168
- <p>
169
- <?php $image_sizes = get_intermediate_image_sizes() ?>
170
- <label><?php _e("Show", 'list-category-posts')?>: </label><br/>
171
- <input type="checkbox" <?php checked( (bool) $instance['thumbnail'], true ); ?>
172
- name="<?php echo $this->get_field_name( 'thumbnail'); ?>" /> <?php _e("Thumbnail - size", 'list-category-posts')?>
173
- <select id="<?php echo $this->get_field_id('thumbnail_size'); ?>"
174
- name="<?php echo $this->get_field_name( 'thumbnail_size' ); ?>" type="text">
175
- <?php foreach($image_sizes as $image_size) { ?>
176
- <option value='<?php echo $image_size ?>' <?php
177
- if($thumbnail_size == $image_size) echo 'selected';
178
- ?>><?php echo $image_size ?></option>
179
- <?php } ?>
180
- </select>
181
- </p>
182
-
183
- <p>
184
- <input class="checkbox" type="checkbox"
185
- <?php checked( (bool) $instance['show_date'], true ); ?>
186
- name="<?php echo $this->get_field_name( 'show_date' ); ?>" />
187
- <?php _e("Date", 'list-category-posts')?>
188
- </p>
189
- <p>
190
- <input class="checkbox" type="checkbox"
191
- <?php checked( (bool) $instance['show_modified_date'], true ); ?>
192
- name="<?php echo $this->get_field_name( 'show_modified_date' ); ?>" />
193
- <?php _e("Modified Date", 'list-category-posts')?>
194
- </p>
195
- <p>
196
- <input class="checkbox" input type="checkbox"
197
- <?php checked( (bool) $instance['show_author'], true ); ?>
198
- name="<?php echo $this->get_field_name( 'show_author' ); ?>" />
199
- <?php _e("Author", 'list-category-posts')?>
200
- </p>
201
- <p>
202
- <input class="checkbox" input type="checkbox"
203
- <?php checked( (bool) $instance['show_catlink'], true ); ?>
204
- name="<?php echo $this->get_field_name( 'show_catlink' ); ?>" />
205
- <?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')?>
206
- </p>
207
- <p>
208
- <input class="checkbox" input type="checkbox"
209
- <?php checked( (bool) $instance['show_excerpt'], true ); ?>
210
- name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" />
211
- <?php _e("Excerpt", 'list-category-posts')?>
212
- </p>
213
- <p>
214
- <label for="<?php echo $this->get_field_id('excerpt_size'); ?>">
215
- <?php _e("Excerpt size", 'list-category-posts')?>:
216
- </label>
217
- <br/>
218
- <input class="widefat" id="<?php echo $this->get_field_id('excerpt_size'); ?>"
219
- name="<?php echo $this->get_field_name('excerpt_size'); ?>" type="text"
220
- value="<?php echo esc_attr($excerptsize); ?>" />
221
- </p>
222
- <p>
223
- <label for="<?php echo $this->get_field_id('morelink'); ?>">
224
- <?php _e("More link", 'list-category-posts')?>:
225
- </label>
226
- <br/>
227
- <input class="widefat" id="<?php echo $this->get_field_id('morelink'); ?>"
228
- name="<?php echo $this->get_field_name('morelink'); ?>" type="text"
229
- value="<?php echo esc_attr($morelink); ?>" />
230
- </p>
231
-
232
- <p>
233
- <label for="<?php echo $this->get_field_id('template'); ?>">
234
- <?php _e("Template", 'list-category-posts')?>:
235
- </label>
236
- <br/>
237
- <select id="<?php echo $this->get_field_id('template'); ?>" name="<?php echo $this->get_field_name('template'); ?>">
238
- <?php
239
- $templates = CatListDisplayer::get_templates();
240
- $templates[] = 'default';
241
- foreach ($templates as $tmp) :
242
- $option = '<option value="' . $tmp . '" ';
243
- if ($tmp == $template) :
244
- $option .= ' selected = "selected" ';
245
- endif;
246
- $option .= '">';
247
- $option .= $tmp;
248
- $option .= '</option>';
249
- echo $option;
250
- endforeach;
251
- ?>
252
- </select>
253
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- $template = empty($instance['template']) ? 'default' : $instance['template'];
41
-
42
- $atts = array(
43
- 'id' => $category_id,
44
- 'orderby' => $orderby,
45
- 'order' => $order,
46
- 'numberposts' => $limit,
47
- 'date' => $showdate,
48
- 'date_modified' => $showmodifieddate,
49
- 'author' => $showauthor,
50
- 'dateformat' => $dateformat,
51
- 'template' => 'default',
52
- 'excerpt' => $showexcerpt,
53
- 'excerpt_size' => $excerptsize,
54
- 'exclude' => $exclude,
55
- 'excludeposts' => $excludeposts,
56
- 'offset' => $offset,
57
- 'catlink' => $showcatlink,
58
- 'thumbnail' => $thumbnail,
59
- 'thumbnail_size' => $thumbnail_size,
60
- 'morelink' => $morelink,
61
- 'template' => $template
62
- );
63
-
64
- echo $before_widget;
65
-
66
- if ($title == 'catlink') {
67
- // If the user has setup 'catlink' as the title, replace it with
68
- // the category link:
69
- $lcp_category = get_category($category_id);
70
- $title = '<a href="' . get_category_link($lcp_category->cat_ID) . '">' .
71
- $lcp_category->name . '</a>';
72
- } elseif ($title == 'catname') {
73
- // If the user has setup 'catname' as the title, replace it with
74
- // the category link:
75
- $lcp_category = get_the_category($post->ID);
76
- $title = $lcp_category[0]->name;
77
- }
78
- echo $before_title . $title . $after_title;
79
-
80
- $catlist_displayer = new CatListDisplayer($atts);
81
- echo $catlist_displayer->display();
82
- echo $after_widget;
83
- }
84
-
85
- /** @see WP_Widget::update */
86
- function update($new_instance, $old_instance) {
87
- $instance = $old_instance;
88
- $instance['title'] = strip_tags($new_instance['title']);
89
- $instance['limit'] = strip_tags($new_instance['limit']);
90
- $instance['orderby'] = strip_tags($new_instance['orderby']);
91
- $instance['order'] = strip_tags($new_instance['order']);
92
- $instance['exclude'] = strip_tags($new_instance['exclude']);
93
- $instance['excludeposts'] = strip_tags($new_instance['excludeposts']);
94
- $instance['offset'] = strip_tags($new_instance['offset']);
95
- $instance['categoryid'] = strip_tags($new_instance['categoryid']);
96
- $instance['dateformat'] = strip_tags($new_instance['dateformat']);
97
- $instance['show_date'] = strip_tags($new_instance['show_date']);
98
- $instance['show_modified_date'] = strip_tags($new_instance['show_modified_date']);
99
- $instance['show_excerpt'] = strip_tags($new_instance['show_excerpt']);
100
- $instance['excerpt_size'] = strip_tags($new_instance['excerpt_size']);
101
- $instance['show_author'] = strip_tags($new_instance['show_author']);
102
- $instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
103
- $instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
104
- $instance['thumbnail'] = strip_tags($new_instance['thumbnail']);
105
- $instance['thumbnail_size'] = strip_tags($new_instance['thumbnail_size']);
106
- $instance['morelink'] = strip_tags($new_instance['morelink']);
107
- $instance['template'] = strip_tags($new_instance['template']);
108
-
109
- return $instance;
110
- }
111
-
112
- /** @see WP_Widget::form */
113
- function form($instance) {
114
- include('lcp-widget-form.php');
115
- }
116
- }
117
-
118
- add_action('widgets_init', create_function('', 'return register_widget("listCategoryPostsWidget");'));
 
 
 
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!