List category posts - Version 0.78

Version Description

  • Adds before=today, when you use it the plugin will get today's date dynamically and display only old posts. Thanks @nnasirzada for the PR implementing this!
  • Changes in pagination: You can now have no anchor links in the pagination. Check the wiki for more info. Thanks @zymeth25 for this feature! If you're using the lcp_page_link somewhere or customized the lcp-paginator.php file somehow, watch out because we refactored this function. Also, let us know what you changed to see if we can incorporate it in the core plugin :)
Download this release

Release Info

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

Code changes from version 0.77.1 to 0.78

include/lcp-catlist.php CHANGED
@@ -434,7 +434,8 @@ class CatList{
434
  'page' => $this->get_page(),
435
  'pagination' => $this->params['pagination'],
436
  'posts_count' => $this->get_posts_count(),
437
- 'previous' => $this->params['pagination_prev']
 
438
  );
439
  return LcpPaginator::get_instance()->get_pagination($paginator_params);
440
  }
434
  'page' => $this->get_page(),
435
  'pagination' => $this->params['pagination'],
436
  'posts_count' => $this->get_posts_count(),
437
+ 'previous' => $this->params['pagination_prev'],
438
+ 'bookmarks' => $this->params['pagination_bookmarks']
439
  );
440
  return LcpPaginator::get_instance()->get_pagination($paginator_params);
441
  }
include/lcp-paginator.php CHANGED
@@ -37,7 +37,8 @@ class LcpPaginator {
37
  $this->next_page_num = null;
38
  if ($pages_count > 1){
39
  for($i = 1; $i <= $pages_count; $i++){
40
- $lcp_paginator .= $this->lcp_page_link($i, $params['page'], $params['instance']);
 
41
  }
42
 
43
  $pag_output .= "<ul class='lcp_paginator'>";
@@ -45,7 +46,8 @@ class LcpPaginator {
45
  // Add "Previous" link
46
  if ($params['page'] > 1){
47
  $this->prev_page_num = intval(intval($params['page']) - 1);
48
- $pag_output .= $this->lcp_page_link($this->prev_page_num , $params['page'], $params['instance'], $params['previous'] );
 
49
  }
50
 
51
  $pag_output .= $lcp_paginator;
@@ -53,7 +55,8 @@ class LcpPaginator {
53
  // Add "Next" link
54
  if ($params['page'] < $pages_count){
55
  $this->next_page_num = intval($params['page'] + 1);
56
- $pag_output .= $this->lcp_page_link($this->next_page_num, $params['page'], $params['instance'], $params['next']);
 
57
  }
58
 
59
  $pag_output .= "</ul>";
@@ -64,7 +67,7 @@ class LcpPaginator {
64
 
65
 
66
  // `char` is the string from pagination_prev/pagination_next
67
- private function lcp_page_link($page, $current_page, $lcp_instance, $char = null){
68
  $link = '';
69
 
70
  if ($page == $current_page){
@@ -85,8 +88,11 @@ class LcpPaginator {
85
  }
86
  $http_host = $server_vars['HTTP_HOST'];
87
  $page_link = "$protocol://$http_host$url?$query" .
88
- $amp . "lcp_page" . $lcp_instance . "=". $page .
89
- "#lcp_instance_" . $lcp_instance;
 
 
 
90
  $link .= "<li><a href='$page_link' title='$page'";
91
  if ($page === $this->prev_page_num) {
92
  $link .= " class='lcp_prevlink'";
@@ -102,4 +108,4 @@ class LcpPaginator {
102
  $link = str_replace('?&', '?', $link );
103
  return $link;
104
  }
105
- }
37
  $this->next_page_num = null;
38
  if ($pages_count > 1){
39
  for($i = 1; $i <= $pages_count; $i++){
40
+ $lcp_paginator .= $this->lcp_page_link($i, $params['page'], $params['instance'],
41
+ $params['bookmarks']);
42
  }
43
 
44
  $pag_output .= "<ul class='lcp_paginator'>";
46
  // Add "Previous" link
47
  if ($params['page'] > 1){
48
  $this->prev_page_num = intval(intval($params['page']) - 1);
49
+ $pag_output .= $this->lcp_page_link($this->prev_page_num , $params['page'], $params['instance'],
50
+ $params['bookmarks'], $params['previous']);
51
  }
52
 
53
  $pag_output .= $lcp_paginator;
55
  // Add "Next" link
56
  if ($params['page'] < $pages_count){
57
  $this->next_page_num = intval($params['page'] + 1);
58
+ $pag_output .= $this->lcp_page_link($this->next_page_num, $params['page'], $params['instance'],
59
+ $params['bookmarks'], $params['next']);
60
  }
61
 
62
  $pag_output .= "</ul>";
67
 
68
 
69
  // `char` is the string from pagination_prev/pagination_next
70
+ private function lcp_page_link($page, $current_page, $lcp_instance, $bookmark, $char = null){
71
  $link = '';
72
 
73
  if ($page == $current_page){
88
  }
89
  $http_host = $server_vars['HTTP_HOST'];
90
  $page_link = "$protocol://$http_host$url?$query" .
91
+ $amp . "lcp_page" . $lcp_instance . "=". $page;
92
+
93
+ // Append a bookmark if not disabled by 'pagination_bookmarks=no'
94
+ if ($bookmark !== "no") $page_link .= "#lcp_instance_" . $lcp_instance;
95
+
96
  $link .= "<li><a href='$page_link' title='$page'";
97
  if ($page === $this->prev_page_num) {
98
  $link .= " class='lcp_prevlink'";
108
  $link = str_replace('?&', '?', $link );
109
  return $link;
110
  }
111
+ }
include/lcp-parameters.php CHANGED
@@ -85,7 +85,11 @@ class LcpParameters{
85
  }
86
 
87
  if ( $this->utils->lcp_not_empty('before') ) {
88
- $this->before = $params['before'];
 
 
 
 
89
  $date_query = true;
90
  }
91
 
85
  }
86
 
87
  if ( $this->utils->lcp_not_empty('before') ) {
88
+ if('today' === strtolower($params['before'])) {
89
+ $this->before = date("Y/m/d");
90
+ } else {
91
+ $this->before = $params['before'];
92
+ }
93
  $date_query = true;
94
  }
95
 
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.77.1
7
  Author: Fernando Briano
8
  Author URI: http://fernandobriano.com
9
 
@@ -143,6 +143,7 @@ class ListCategoryPosts{
143
  'before_month' => '',
144
  'before_day' => '',
145
  'tags_as_class' => 'no',
 
146
  ), $atts);
147
  if($atts['numberposts'] == ''){
148
  $atts['numberposts'] = get_option('numberposts');
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.78
7
  Author: Fernando Briano
8
  Author URI: http://fernandobriano.com
9
 
143
  'before_month' => '',
144
  'before_day' => '',
145
  'tags_as_class' => 'no',
146
+ 'pagination_bookmarks' => '',
147
  ), $atts);
148
  if($atts['numberposts'] == ''){
149
  $atts['numberposts'] = get_option('numberposts');
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: list, categories, posts, cms
5
  Requires at least: 3.3
6
  Tested up to: 4.9.7
7
  Requires PHP: 5.2.4
8
- Stable tag: 0.77.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -110,7 +110,7 @@ When using List Category Posts whithout a category id, name or slug, it will pos
110
 
111
  * **monthnum** and **year** - List posts from a certain year or month. You can use these together or independently. Example: `[catlist year=2015]` will list posts from the year 2015. `[catlist monthnum=8]` will list posts published in August of every year. `[catlist year=2012 monthnum=12]` will list posts from December 2012.
112
 
113
- * **date ranges** - You can also use date ranges for listing posts. For example "list every post after March 14th, 2005". The parameters are: ```after, after_year, after_month, after_day, before, before_year, before_month, before_day```. These parameters are used to specify data_query arguments (see: [the codex](https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters)).
114
 
115
  If you want to list all the posts before a given date, say `Jun 17th, 2007` you can use these two options:
116
  `[catlist before_year=2007 before_month=06 before_day=17]`
@@ -440,6 +440,11 @@ Template system has changed. Custom templates should be stored in WordPress them
440
 
441
  == Changelog ==
442
 
 
 
 
 
 
443
  = 0.77.1 =
444
 
445
  * Bug fix by @zymeth25: In some rare cases wp_reset_query fails to reset global $post to its initial value. This manual reset ensures the plugin leaves the main query in a clean state regardless of circumstances. Fixes https://wordpress.org/support/topic/your-plugin-has-a-crazy-bug-conflict-with-elementor/#post-10145793 and https://github.com/picandocodigo/List-Category-Posts/issues/320.
5
  Requires at least: 3.3
6
  Tested up to: 4.9.7
7
  Requires PHP: 5.2.4
8
+ Stable tag: 0.78
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
110
 
111
  * **monthnum** and **year** - List posts from a certain year or month. You can use these together or independently. Example: `[catlist year=2015]` will list posts from the year 2015. `[catlist monthnum=8]` will list posts published in August of every year. `[catlist year=2012 monthnum=12]` will list posts from December 2012.
112
 
113
+ * **date ranges** - You can also use date ranges for listing posts. For example "list every post after March 14th, 2005". The parameters are: ```after, after_year, after_month, after_day, before, before_year, before_month, before_day```. You can use `today` as a value, the plugin will get today's date dynamically and display only old posts. These parameters are used to specify data_query arguments (see: [the codex](https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters)).
114
 
115
  If you want to list all the posts before a given date, say `Jun 17th, 2007` you can use these two options:
116
  `[catlist before_year=2007 before_month=06 before_day=17]`
440
 
441
  == Changelog ==
442
 
443
+ = 0.78 =
444
+
445
+ * Adds `before=today`, when you use it the plugin will get today's date dynamically and display only old posts. Thanks @nnasirzada for the PR implementing this!
446
+ * Changes in pagination: You can now have no anchor links in the pagination. Check [the wiki](https://github.com/picandocodigo/List-Category-Posts/wiki/Pagination) for more info. Thanks @zymeth25 for this feature! If you're using the `lcp_page_link` somewhere or customized the `lcp-paginator.php` file somehow, watch out because we refactored this function. Also, let us know what you changed to see if we can incorporate it in the core plugin :)
447
+
448
  = 0.77.1 =
449
 
450
  * Bug fix by @zymeth25: In some rare cases wp_reset_query fails to reset global $post to its initial value. This manual reset ensures the plugin leaves the main query in a clean state regardless of circumstances. Fixes https://wordpress.org/support/topic/your-plugin-has-a-crazy-bug-conflict-with-elementor/#post-10145793 and https://github.com/picandocodigo/List-Category-Posts/issues/320.