List category posts - Version 0.20.5

Version Description

  • Brought back the multiple categories functionality for the id parameter. Hopefully the last 0.20 bugfix release so I can start working on new stuff to implement.
  • Now the name parameter accepts multiple categories too. Just use: [catlist name=category1,category2]
Download this release

Release Info

Developer fernandobt
Plugin Icon 128x128 List category posts
Version 0.20.5
Comparing to
See all releases

Code changes from version 0.20.4 to 0.20.5

Files changed (3) hide show
  1. include/CatList.php +29 -19
  2. list_cat_posts.php +1 -3
  3. readme.txt +13 -18
include/CatList.php CHANGED
@@ -7,8 +7,8 @@
7
 
8
  class CatList{
9
  private $params = array();
10
- private $lcp_categories_posts = array();
11
  private $lcp_category_id = 0;
 
12
 
13
  /**
14
  * Constructor gets the shortcode attributes as parameter
@@ -17,28 +17,16 @@ class CatList{
17
  public function __construct($atts) {
18
  $this->params = $atts;
19
  //Get the category posts:
20
- $this->lcp_set_categories();
 
21
  }
22
 
23
  /**
24
- * Get the categories & posts
25
  */
26
- private function lcp_set_categories(){
27
- $args = array();
28
- if ( isset($this->params['categorypage']) && $this->params['categorypage'] == 'yes' ){
29
- global $post;
30
- $categories = get_the_category($post->ID);
31
- $this->lcp_category_id = $categories[0]->cat_ID;
32
- } elseif ( isset($this->params['name']) && $this->params['name'] != '' ){
33
- $this->lcp_category_id = $this->get_category_id_by_name($this->params['name']);
34
- } elseif ( isset($this->params['id']) && $this->params['id'] != '0' ){
35
- $this->lcp_category_id = $this->params['id'];
36
- }
37
 
38
- if ($this->lcp_category_id != 0){
39
- $args['category'] = $this->lcp_category_id;
40
- }
41
-
42
  $args = array_merge($args, array(
43
  'numberposts' => $this->params['numberposts'],
44
  'orderby' => $this->params['orderby'],
@@ -72,10 +60,32 @@ class CatList{
72
  } else if (isset($this->params['tags'])) {
73
  $args['tag'] = $this->params['tags'];
74
  }
75
-
76
  $this->lcp_categories_posts = get_posts($args);
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  /**
80
  * Get the category id from its name
81
  * by Eric Celeste / http://eric.clst.org
7
 
8
  class CatList{
9
  private $params = array();
 
10
  private $lcp_category_id = 0;
11
+ private $category_param;
12
 
13
  /**
14
  * Constructor gets the shortcode attributes as parameter
17
  public function __construct($atts) {
18
  $this->params = $atts;
19
  //Get the category posts:
20
+ $this->get_lcp_category();
21
+ $this->set_lcp_parameters();
22
  }
23
 
24
  /**
25
+ * Order the parameters and query the DB for posts
26
  */
27
+ private function set_lcp_parameters(){
28
+ $args = array('cat'=> $this->lcp_category_id);
 
 
 
 
 
 
 
 
 
29
 
 
 
 
 
30
  $args = array_merge($args, array(
31
  'numberposts' => $this->params['numberposts'],
32
  'orderby' => $this->params['orderby'],
60
  } else if (isset($this->params['tags'])) {
61
  $args['tag'] = $this->params['tags'];
62
  }
 
63
  $this->lcp_categories_posts = get_posts($args);
64
  }
65
 
66
+
67
+ private function get_lcp_category(){
68
+ if ( isset($this->params['categorypage']) && $this->params['categorypage'] == 'yes' ){
69
+ global $post;
70
+ $categories = get_the_category($post->ID);
71
+ $this->lcp_category_id = $categories[0]->cat_ID;
72
+ } elseif ( isset($this->params['name']) && $this->params['name'] != '' ){
73
+ if (preg_match('/,/', $this->params['name'])){
74
+ $categories = '';
75
+ $cat_array = explode(",", $this->params['name']);
76
+ foreach ($cat_array as $category) {
77
+ $id = $this->get_category_id_by_name($category);
78
+ $categories .= $id . ",";
79
+ }
80
+ $this->lcp_category_id = $categories;
81
+ } else {
82
+ $this->lcp_category_id = $this->get_category_id_by_name($this->params['name']);
83
+ }
84
+ } elseif ( isset($this->params['id']) && $this->params['id'] != '0' ){
85
+ $this->lcp_category_id = $this->params['id'];
86
+ }
87
+ }
88
+
89
  /**
90
  * Get the category id from its name
91
  * by Eric Celeste / http://eric.clst.org
list_cat_posts.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: List category posts
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
5
  Description: List Category Posts allows you to list posts from a category into 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, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
6
- Version: 0.20.4
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
  */
@@ -76,8 +76,6 @@ add_shortcode( 'catlist', array('ListCategoryPosts', 'catlist_func') );
76
 
77
  /**
78
  * TO-DO:
79
- * http://wordpress.org/support/topic/plugin-list-category-posts-titlelink
80
- * From WordPress Answers:
81
  Add Older Posts at bottom of List Category Post page
82
  http://wordpress.stackexchange.com/questions/26398/add-older-posts-at-bottom-of-list-category-post-page
83
  Getting the “more” tag to work with plugin-list-category-post
3
  Plugin Name: List category posts
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
5
  Description: List Category Posts allows you to list posts from a category into 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, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
6
+ Version: 0.20.5
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
  */
76
 
77
  /**
78
  * TO-DO:
 
 
79
  Add Older Posts at bottom of List Category Post page
80
  http://wordpress.stackexchange.com/questions/26398/add-older-posts-at-bottom-of-list-category-post-page
81
  Getting the “more” tag to work with plugin-list-category-post
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.8
6
  Tested up to: 3.2.1
7
- Stable tag: 0.20.4
8
 
9
  == Description ==
10
  List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode.
@@ -17,9 +17,6 @@ It includes a widget which works pretty much the same as the plugin. Just add as
17
 
18
  Since version 0.18, **this plugins does not work on servers with PHP 4**. If you're still using PHP 4 on your webhost, you should consider upgrading to PHP 5. WordPress 3.1 will be the last version to support PHP 4, from 3.2 and forward, only PHP 5 will be supported. You can still [download an older version of the plugin](https://wordpress.org/extend/plugins/list-category-posts/download/ "download an older version of the plugin") if you're using PHP 4.
19
 
20
- Works correctly with WordPress 3.1 and default Twenty Ten theme
21
- (http://wordpress.org/support/topic/399754)
22
-
23
  Please, read the information on [Other Notes](http://wordpress.org/extend/plugins/list-category-posts/other_notes/) and [Changelog](http://wordpress.org/extend/plugins/list-category-posts/changelog/) to be aware of new functionality, and improvements to the plugin.
24
 
25
  **Usage**
@@ -28,21 +25,19 @@ Please, read the information on [Other Notes](http://wordpress.org/extend/plugin
28
 
29
  **Support the plugin**
30
 
31
- If you've found the plugin useful, consider making a [donation via PayPal](http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/ "Donate via PayPal") or visit my [Amazon Wishlist](http://www.amazon.com/gp/registry/wishlist/2HU1JYOF7DX5Q/ref=wl_web "Amazon Wishlist").
32
 
33
 
34
  ==Installation==
35
 
36
  * Upload listcat directory into you wp-content/plugins/ directory.
37
  * Login to your WordPress Admin menu, go to Plugins, and activate it.
38
- * Edit the default.php file on templates to customize the way the categories are displayed, or use the default one included in the plugin's code. You can use several different templates if you want.
39
- * You can find the ListCategoryPostsWidget in the Appearence > Widgets section on your WordPress Dashboard.
40
 
41
  ==Other notes==
42
 
43
- **Usage**
44
-
45
- *Selecting the category*
46
 
47
  The plugin can figure out the category from which you want to list posts in three different ways: Using the *category id*, the *category name or slug* and *detecting the current post's category*.
48
  When using List Category Posts inside a post, if you don't pass the category id, name or slug, it will post the latest posts from every category.
@@ -55,7 +50,7 @@ You can use the *categorypage* parameter to make it detect the category id of th
55
 
56
  * **categorypage** - Set it to "yes" if you want to list the posts from the current post's category.
57
 
58
- *Other parameters*
59
 
60
  * **tags** - Tag support, you can display posts from a certain tag.
61
 
@@ -116,7 +111,7 @@ You can use the *categorypage* parameter to make it detect the category id of th
116
 
117
  * **template** - File name of template from templates directory without extension. Example: For 'template.php' value is only 'template'. Default is 'default', which displays an unordered list (ul html tag) with a CSS class. This class can be passed as a parameter or by default it's: 'lcp_catlist'. You can also use the default 'div' value. This will output a div with the 'lcp_catlist' CSS class (or one you pass as parameter with the class argument). The inner items (posts) will be displayed between p tags.
118
 
119
- **Template System**
120
 
121
  Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under 'wp-content/themes/your-theme-folder'. Template files are .php files.
122
 
@@ -126,9 +121,6 @@ If the template file were templatename.php.
126
 
127
  You can have as many different templates as you want, and use them in different pages and posts. The template code is pretty well documented, so if you're a bit familiar with HTML and PHP, you'll have no problems creating your own template. I'm planning on reworking the template system in order to have a really user friendly way to create templates.
128
 
129
-
130
- **New Code is always welcome** :D
131
-
132
  == Frequently Asked Questions ==
133
  * **Instructions** on how to use the plugin: http://wordpress.org/extend/plugins/list-category-posts/other_notes/
134
  * **Template system** how to customize the way the posts are shown: http://wordpress.org/extend/plugins/list-category-posts/other_notes/. I am aware the Template System is not really friendly right now, I'll work on this whenever I get the time to work on the plugin for a while.
@@ -138,9 +130,7 @@ You can have as many different templates as you want, and use them in different
138
  * **FAQ**
139
 
140
  **Plugin could not be activated because it triggered a fatal error.**
141
-
142
  *Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /.../wp-content/plugins/list-category-posts/include/CatListDisplayer.php on line 10*
143
-
144
  Please check:
145
  http://wordpress.stackexchange.com/questions/9338/list-category-posts-plugin-upgrade-fails-fatal-error/9340#9340
146
 
@@ -166,6 +156,10 @@ Template system has changed. Custom templates should be stored in WordPress them
166
 
167
  == Changelog ==
168
 
 
 
 
 
169
  = 0.20.4 =
170
  * Yet another bugfix, regarding nothing being displayed when using tags.
171
 
@@ -228,7 +222,8 @@ This update is dedicated to S. Keller from Switzerland who gave me "The Ultimate
228
  = 0.16 =
229
  * Changed STYLESHEETPATH to TEMPLATEPATH to point to the parent theme.
230
  * Added support to display custom fields. (http://picod.net/wp03)
231
- * Tested with WordPress 3.1.
 
232
 
233
  = 0.15.1 =
234
  * Fixed a bug with undeclared variable. (Check http://picod.net/walcp, thanks Das!)
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.8
6
  Tested up to: 3.2.1
7
+ Stable tag: 0.20.5
8
 
9
  == Description ==
10
  List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode.
17
 
18
  Since version 0.18, **this plugins does not work on servers with PHP 4**. If you're still using PHP 4 on your webhost, you should consider upgrading to PHP 5. WordPress 3.1 will be the last version to support PHP 4, from 3.2 and forward, only PHP 5 will be supported. You can still [download an older version of the plugin](https://wordpress.org/extend/plugins/list-category-posts/download/ "download an older version of the plugin") if you're using PHP 4.
19
 
 
 
 
20
  Please, read the information on [Other Notes](http://wordpress.org/extend/plugins/list-category-posts/other_notes/) and [Changelog](http://wordpress.org/extend/plugins/list-category-posts/changelog/) to be aware of new functionality, and improvements to the plugin.
21
 
22
  **Usage**
25
 
26
  **Support the plugin**
27
 
28
+ If you've found the plugin useful, consider making a [donation via PayPal](http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/ "Donate via PayPal") or visit my [Amazon Wishlist](http://www.amazon.com/gp/registry/wishlist/2HU1JYOF7DX5Q/ref=wl_web "Amazon Wishlist"). **New Code is always welcome** :D
29
 
30
 
31
  ==Installation==
32
 
33
  * Upload listcat directory into you wp-content/plugins/ directory.
34
  * Login to your WordPress Admin menu, go to Plugins, and activate it.
35
+ * You can find the List Category Posts widget in the Appearence > Widgets section on your WordPress Dashboard.
36
+ * If you want to customize the way the plugin displays the information, check the section on Templates on this documentation.
37
 
38
  ==Other notes==
39
 
40
+ **Selecting the category**
 
 
41
 
42
  The plugin can figure out the category from which you want to list posts in three different ways: Using the *category id*, the *category name or slug* and *detecting the current post's category*.
43
  When using List Category Posts inside a post, if you don't pass the category id, name or slug, it will post the latest posts from every category.
50
 
51
  * **categorypage** - Set it to "yes" if you want to list the posts from the current post's category.
52
 
53
+ **Other parameters**
54
 
55
  * **tags** - Tag support, you can display posts from a certain tag.
56
 
111
 
112
  * **template** - File name of template from templates directory without extension. Example: For 'template.php' value is only 'template'. Default is 'default', which displays an unordered list (ul html tag) with a CSS class. This class can be passed as a parameter or by default it's: 'lcp_catlist'. You can also use the default 'div' value. This will output a div with the 'lcp_catlist' CSS class (or one you pass as parameter with the class argument). The inner items (posts) will be displayed between p tags.
113
 
114
+ == Template System ==
115
 
116
  Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under 'wp-content/themes/your-theme-folder'. Template files are .php files.
117
 
121
 
122
  You can have as many different templates as you want, and use them in different pages and posts. The template code is pretty well documented, so if you're a bit familiar with HTML and PHP, you'll have no problems creating your own template. I'm planning on reworking the template system in order to have a really user friendly way to create templates.
123
 
 
 
 
124
  == Frequently Asked Questions ==
125
  * **Instructions** on how to use the plugin: http://wordpress.org/extend/plugins/list-category-posts/other_notes/
126
  * **Template system** how to customize the way the posts are shown: http://wordpress.org/extend/plugins/list-category-posts/other_notes/. I am aware the Template System is not really friendly right now, I'll work on this whenever I get the time to work on the plugin for a while.
130
  * **FAQ**
131
 
132
  **Plugin could not be activated because it triggered a fatal error.**
 
133
  *Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /.../wp-content/plugins/list-category-posts/include/CatListDisplayer.php on line 10*
 
134
  Please check:
135
  http://wordpress.stackexchange.com/questions/9338/list-category-posts-plugin-upgrade-fails-fatal-error/9340#9340
136
 
156
 
157
  == Changelog ==
158
 
159
+ = 0.20.5 =
160
+ * Brought back the multiple categories functionality for the id parameter. Hopefully the last 0.20 bugfix release so I can start working on new stuff to implement.
161
+ * Now the name parameter accepts multiple categories too. Just use: `[catlist name=category1,category2]`
162
+
163
  = 0.20.4 =
164
  * Yet another bugfix, regarding nothing being displayed when using tags.
165
 
222
  = 0.16 =
223
  * Changed STYLESHEETPATH to TEMPLATEPATH to point to the parent theme.
224
  * Added support to display custom fields. (http://picod.net/wp03)
225
+ * Tested with WordPress 3.1 - http://wordpress.org/support/topic/399754
226
+
227
 
228
  = 0.15.1 =
229
  * Fixed a bug with undeclared variable. (Check http://picod.net/walcp, thanks Das!)