List category posts - Version 0.82

Version Description

  • Adds support for several authors. To select posts from one author, you can use the author_posts parameter and use 'user_nicename' (NOT name). Example: [catlist author_posts="fernando"]. If you want to select posts from several authors, you need to use the author id instead. You can find the id for each author in wp-admin/users.php. It needs to be a comma separated value, example: [catlist author_posts="1,2"]
  • Rewrote excludeposts function. It wasn't working very well with this.
Download this release

Release Info

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

Code changes from version 0.81 to 0.82

include/lcp-parameters.php CHANGED
@@ -51,12 +51,18 @@ class LcpParameters{
51
  endif;
52
 
53
  if($this->utils->lcp_not_empty('author_posts')):
54
- if ($params['author_posts'] == 'current_user'){
 
55
  $args['author'] = wp_get_current_user()->ID;
56
  } else {
57
- $args['author_name'] = $params['author_posts'];
 
 
 
 
58
  }
59
  endif;
 
60
  // Parameters which need to be checked simply, if they exist, add them to
61
  // final return array ($args)
62
  $args = $this->lcp_check_basic_params($args);
@@ -230,16 +236,21 @@ class LcpParameters{
230
  // Check posts to exclude
231
  private function lcp_check_excludes($args){
232
  if( $this->utils->lcp_not_empty('excludeposts') ){
233
- $exclude = array(
234
- 'post__not_in' => explode(",", $this->params['excludeposts'])
235
- );
236
- if (strpos($this->params['excludeposts'], 'this') > -1){
237
- $exclude = array_merge(
238
- $exclude,
239
- array('post__not_in' => array($this->lcp_get_current_post_id() ) )
 
 
240
  );
241
  }
242
- $args = array_merge($args, $exclude);
 
 
 
243
  }
244
  return $args;
245
  }
51
  endif;
52
 
53
  if($this->utils->lcp_not_empty('author_posts')):
54
+ $authors = $params['author_posts'];
55
+ if ($authors == 'current_user'){
56
  $args['author'] = wp_get_current_user()->ID;
57
  } else {
58
+ if(preg_match('/,/', $authors)){
59
+ $args['author__in'] = $authors;
60
+ } else {
61
+ $args['author_name'] = $authors;
62
+ }
63
  }
64
  endif;
65
+
66
  // Parameters which need to be checked simply, if they exist, add them to
67
  // final return array ($args)
68
  $args = $this->lcp_check_basic_params($args);
236
  // Check posts to exclude
237
  private function lcp_check_excludes($args){
238
  if( $this->utils->lcp_not_empty('excludeposts') ){
239
+ $excludeposts = explode(',', $this->params['excludeposts']);
240
+
241
+ $this_index = array_search("this", $excludeposts);
242
+
243
+ if ($this_index > -1){
244
+ unset($excludeposts[$this_index]);
245
+ $excludeposts = array_merge(
246
+ $excludeposts,
247
+ array($this->lcp_get_current_post_id())
248
  );
249
  }
250
+ $excludeposts = array(
251
+ 'post__not_in' => $excludeposts
252
+ );
253
+ $args = array_merge($args, $excludeposts);
254
  }
255
  return $args;
256
  }
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.81
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.82
7
  Author: Fernando Briano
8
  Author URI: http://fernandobriano.com
9
 
readme.txt CHANGED
@@ -3,9 +3,9 @@ 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: 5.2.2
7
  Requires PHP: 5.4
8
- Stable tag: 0.81
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -229,6 +229,11 @@ Template system has changed. Custom templates should be stored in WordPress them
229
 
230
  == Changelog ==
231
 
 
 
 
 
 
232
  = 0.81 =
233
 
234
  * Adds "<span class='lcp_elipsis'>" to the "..." in pagination.
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: 5.4.1
7
  Requires PHP: 5.4
8
+ Stable tag: 0.82
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
229
 
230
  == Changelog ==
231
 
232
+ = 0.82 =
233
+
234
+ * Adds support for several authors. To select posts from one author, you can use the **author_posts** parameter and use 'user_nicename' (NOT name). Example: `[catlist author_posts="fernando"]`. If you want to select posts from several authors, you need to use the author id instead. You can find the id for each author in `wp-admin/users.php`. It needs to be a comma separated value, example: `[catlist author_posts="1,2"]`
235
+ * Rewrote `excludeposts` function. It wasn't working very well with `this`.
236
+
237
  = 0.81 =
238
 
239
  * Adds "<span class='lcp_elipsis'>" to the "..." in pagination.