List category posts - Version 0.36

Version Description

  • Adds option for "target=_blank" for post links.
    • Adds option to exclude category when using the and relationship: [catlist id=1+2-3] will include posts from categories 1 and 2 but not 3.
Download this release

Release Info

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

Code changes from version 0.35 to 0.36

include/CatList.php CHANGED
@@ -9,6 +9,7 @@ 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
@@ -116,6 +117,10 @@ class CatList{
116
  $args['tag'] = $this->params['tags'];
117
  endif;
118
 
 
 
 
 
119
  if ( $this->lcp_not_empty('customfield_orderby') ):
120
  $args['orderby'] = 'meta_value';
121
  $args['meta_key'] = $this->params['customfield_orderby'];
@@ -151,10 +156,12 @@ class CatList{
151
  if (preg_match('/\+/', $this->params['name'])):
152
  $categories = array();
153
  $cat_array = explode("+", $this->params['name']);
 
154
  foreach ($cat_array as $category) :
155
  $id = $this->get_category_id_by_name($category);
156
  $categories[] = $id;
157
  endforeach;
 
158
  $this->lcp_category_id = $categories;
159
 
160
  elseif (preg_match('/,/', $this->params['name'])):
@@ -173,6 +180,9 @@ class CatList{
173
  endif;
174
  elseif ( isset($this->params['id']) && $this->params['id'] != '0' ):
175
  if (preg_match('/\+/', $this->params['id'])):
 
 
 
176
  $this->lcp_category_id = explode("+", $this->params['id']);
177
  else:
178
  $this->lcp_category_id = $this->params['id'];
9
  private $params = array();
10
  private $lcp_category_id = 0;
11
  private $category_param;
12
+ private $exclude;
13
 
14
  /**
15
  * Constructor gets the shortcode attributes as parameter
117
  $args['tag'] = $this->params['tags'];
118
  endif;
119
 
120
+ if ( !empty($this->exclude)):
121
+ $args['category__not_in'] = array($this->exclude);
122
+ endif;
123
+
124
  if ( $this->lcp_not_empty('customfield_orderby') ):
125
  $args['orderby'] = 'meta_value';
126
  $args['meta_key'] = $this->params['customfield_orderby'];
156
  if (preg_match('/\+/', $this->params['name'])):
157
  $categories = array();
158
  $cat_array = explode("+", $this->params['name']);
159
+
160
  foreach ($cat_array as $category) :
161
  $id = $this->get_category_id_by_name($category);
162
  $categories[] = $id;
163
  endforeach;
164
+
165
  $this->lcp_category_id = $categories;
166
 
167
  elseif (preg_match('/,/', $this->params['name'])):
180
  endif;
181
  elseif ( isset($this->params['id']) && $this->params['id'] != '0' ):
182
  if (preg_match('/\+/', $this->params['id'])):
183
+ if ( preg_match('/(-[0-9]+)+/', $this->params['id'], $matches) ):
184
+ $this->exclude = implode(',', explode("-", ltrim($matches[0], '-') ));
185
+ endif;
186
  $this->lcp_category_id = explode("+", $this->params['id']);
187
  else:
188
  $this->lcp_category_id = $this->params['id'];
include/CatListDisplayer.php CHANGED
@@ -111,10 +111,12 @@ class CatListDisplayer {
111
  */
112
  private function lcp_build_post($single, $tag){
113
  global $post;
 
114
  $class ='';
115
  if ( $post->ID == $single->ID ):
116
  $class = " class = current ";
117
  endif;
 
118
  $lcp_display_output = '<'. $tag . $class . '>';
119
 
120
  if (!empty($this->params['title_tag'])):
@@ -258,8 +260,12 @@ class CatListDisplayer {
258
 
259
  private function get_post_title($single, $tag = null, $css_class = null){
260
  $info = '<a href="' . get_permalink($single->ID) .
261
- '" title="'. $single->post_title . '">' .
262
- apply_filters('the_title', $single->post_title, $single->ID) . '</a>';
 
 
 
 
263
  return $this->assign_style($info, $tag, $css_class);
264
  }
265
 
111
  */
112
  private function lcp_build_post($single, $tag){
113
  global $post;
114
+
115
  $class ='';
116
  if ( $post->ID == $single->ID ):
117
  $class = " class = current ";
118
  endif;
119
+
120
  $lcp_display_output = '<'. $tag . $class . '>';
121
 
122
  if (!empty($this->params['title_tag'])):
260
 
261
  private function get_post_title($single, $tag = null, $css_class = null){
262
  $info = '<a href="' . get_permalink($single->ID) .
263
+ '" title="' . $single->post_title. '"';
264
+ if (!empty($this->params['link_target'])):
265
+ $info .= ' target="' . $this->params['link_target'] . '" ';
266
+ endif;
267
+ $info .= '>' . apply_filters('the_title', $single->post_title, $single->ID) . '</a>';
268
+
269
  return $this->assign_style($info, $tag, $css_class);
270
  }
271
 
list_cat_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 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.35
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
 
@@ -98,7 +98,8 @@ class ListCategoryPosts{
98
  'posts_morelink_class' => '',
99
  'year' => '',
100
  'monthnum' => '',
101
- 'search' => ''
 
102
  ), $atts);
103
 
104
  $catlist_displayer = new CatListDisplayer($atts);
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 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.36
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
 
98
  'posts_morelink_class' => '',
99
  'year' => '',
100
  'monthnum' => '',
101
+ 'search' => '',
102
+ 'link_target' => ''
103
  ), $atts);
104
 
105
  $catlist_displayer = new CatListDisplayer($atts);
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: 3.3
6
  Tested up to: 3.7.1
7
- Stable tag: 0.35
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -72,15 +72,14 @@ When using List Category Posts whithout a category id, name or slug, it will pos
72
 
73
  * **include** posts from several categories with **AND** relationship, posts that belong to all of the listed categories (note this does not show posts from any children of these categories): `[catlist id=17+25+2]` - `[catlist name=sega+nintendo]`.
74
  * **include** posts from several categories with **OR** relationship, posts that belong to either one of the listed categories: `[catlist id=17,24,32]` - `[catlist name=sega,nintendo]`.
75
- * **exclude** a category with the minus sign (-): `[catlist id=11,-32,16]`.
76
-
77
 
78
 
79
  ==Other parameters==
80
 
81
  * **tags** - Tag support, you can display posts from a certain tag.
82
 
83
- * **exclude_tags** - Exclude posts from one or more tags: `[catlist tag="videogames" exclude_tags="sega,sony"]`
84
 
85
  * **orderby** - To customize the order. Valid values are:
86
  * **author** - Sort by the numeric author IDs.
@@ -169,6 +168,8 @@ When using List Category Posts whithout a category id, name or slug, it will pos
169
 
170
  * **posts_morelink** - Include a "read more" link after each post. It receives a string of characters as a parameter which will be used as the text of the link. Example: `[catlist id=38 posts_morelink="Read more about this post"]`
171
 
 
 
172
  == HTML & CSS Customization ==
173
 
174
  You can customize what HTML tags different elements will be sorrounded with and a CSS class for this element, or just a CSS class which will wrap the element with a `span` tag.
@@ -209,7 +210,7 @@ You can have as many different templates as you want, and use them in different
209
  * **Instructions** on how to use the plugin: http://wordpress.org/extend/plugins/list-category-posts/other_notes/ - **Read it**.
210
  * **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.
211
  * **New feature requests, Bug fixes, enhancements** - You can post them on [GitHub Issues](https://github.com/picandocodigo/List-Category-Posts/issues).
212
- * **Questions** If you have any usage questions, go to [WordPress Answers](http://wordpress.stackexchange.com/) for support. It's a great place with a large community of WordPress users and developers. Just [ask your question](http://wordpress.stackexchange.com/questions/ask?tags=plugin-list-category-posts) using the 'plugin-list-category-post' tag.
213
 
214
 
215
  * **FAQ**
@@ -273,6 +274,11 @@ Template system has changed. Custom templates should be stored in WordPress them
273
 
274
  == Changelog ==
275
 
 
 
 
 
 
276
  = 0.35 =
277
  * Updated Turkish translation, thanks again [Hakan Er](http://hakanertr.wordpress.com/)!
278
  * Adds feature to order by custom field using the `customfield_orderby` parameter.
4
  Tags: list, categories, posts, cms
5
  Requires at least: 3.3
6
  Tested up to: 3.7.1
7
+ Stable tag: 0.36
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
72
 
73
  * **include** posts from several categories with **AND** relationship, posts that belong to all of the listed categories (note this does not show posts from any children of these categories): `[catlist id=17+25+2]` - `[catlist name=sega+nintendo]`.
74
  * **include** posts from several categories with **OR** relationship, posts that belong to either one of the listed categories: `[catlist id=17,24,32]` - `[catlist name=sega,nintendo]`.
75
+ * **exclude** a category with the minus sign (-): `[catlist id=11,-32,16]`, `[catlist id=1+2-3]`. **Important**: When using the *and* relationship, the order must be categories you want to include first, and exclude after. So `[catlist id=1+2-3]` will work, but `[catlist id=1+2-3+4]` won't.
 
76
 
77
 
78
  ==Other parameters==
79
 
80
  * **tags** - Tag support, you can display posts from a certain tag.
81
 
82
+ * **exclude_tags** - Exclude posts from one or more tags: `[catlist tags="videogames" exclude_tags="sega,sony"]`
83
 
84
  * **orderby** - To customize the order. Valid values are:
85
  * **author** - Sort by the numeric author IDs.
168
 
169
  * **posts_morelink** - Include a "read more" link after each post. It receives a string of characters as a parameter which will be used as the text of the link. Example: `[catlist id=38 posts_morelink="Read more about this post"]`
170
 
171
+ * **link_target** - Select the `target` attribute for links to posts (target=_blank, _self, _parent, _top, *framename*). Example: `[catlink id=3 link_target=_blank]` will create: `<a href="http://localhost/wordpress/?p=45" title="Test post" target="_blank">Test post</a>`
172
+
173
  == HTML & CSS Customization ==
174
 
175
  You can customize what HTML tags different elements will be sorrounded with and a CSS class for this element, or just a CSS class which will wrap the element with a `span` tag.
210
  * **Instructions** on how to use the plugin: http://wordpress.org/extend/plugins/list-category-posts/other_notes/ - **Read it**.
211
  * **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.
212
  * **New feature requests, Bug fixes, enhancements** - You can post them on [GitHub Issues](https://github.com/picandocodigo/List-Category-Posts/issues).
213
+ * **Questions** For questions either use the [Support forum](http://wordpress.org/support/plugin/list-category-posts) or [WordPress Answers](http://wordpress.stackexchange.com/). It's a great place with a large community of WordPress users and developers. Just [ask your question](http://wordpress.stackexchange.com/questions/ask?tags=plugin-list-category-posts) using the 'plugin-list-category-post' tag.
214
 
215
 
216
  * **FAQ**
274
 
275
  == Changelog ==
276
 
277
+ = 0.36 =
278
+
279
+ * Adds option for "target=_blank" for post links.
280
+ * Adds option to exclude category when using the *and* relationship: `[catlist id=1+2-3]` will include posts from categories 1 and 2 but not 3.
281
+
282
  = 0.35 =
283
  * Updated Turkish translation, thanks again [Hakan Er](http://hakanertr.wordpress.com/)!
284
  * Adds feature to order by custom field using the `customfield_orderby` parameter.