List category posts - Version 0.52

Version Description

  • Small fix for pagination and query string.
    • Fix on multiple categories with AND relationship.
    • Fixes options page 404 and saving options.
    • Tested with WordPress 4.1.
Download this release

Release Info

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

Code changes from version 0.51 to 0.52

include/lcp-catlist.php CHANGED
@@ -122,12 +122,15 @@ class CatList{
122
  endif;
123
 
124
  if ( $this->lcp_not_empty('pagination')):
125
- if( preg_match('/lcp_page' . preg_quote($this->instance) .
126
- '=([0-9]+)/i', $_SERVER['QUERY_STRING'], $match) ):
127
- $this->page = $match[1];
128
- $offset = ($this->page - 1) * $this->params['numberposts'];
129
- $args = array_merge($args, array('offset' => $offset));
130
- endif;
 
 
 
131
  endif;
132
 
133
  // Posts that start with a given letter:
@@ -227,10 +230,12 @@ class CatList{
227
  }
228
 
229
  private function get_lcp_category(){
 
230
  if ( $this->lcp_not_empty('categorypage') &&
231
  $this->params['categorypage'] == 'yes' ||
232
  $this->params['id'] == -1):
233
  $this->lcp_category_id = $this->lcp_get_current_category();
 
234
  elseif ( $this->lcp_not_empty('name') ):
235
  if (preg_match('/\+/', $this->params['name'])):
236
  $categories = array();
@@ -257,12 +262,13 @@ class CatList{
257
  else:
258
  $this->lcp_category_id = $this->get_category_id_by_name($this->params['name']);
259
  endif;
 
260
  elseif ( isset($this->params['id']) && $this->params['id'] != '0' ):
261
  if (preg_match('/\+/', $this->params['id'])):
262
  if ( preg_match('/(-[0-9]+)+/', $this->params['id'], $matches) ):
263
  $this->exclude = implode(',', explode("-", ltrim($matches[0], '-') ));
264
  endif;
265
- $this->lcp_category_id = explode("+", $this->params['id']);
266
  else:
267
  $this->lcp_category_id = $this->params['id'];
268
  endif;
122
  endif;
123
 
124
  if ( $this->lcp_not_empty('pagination')):
125
+ if(isset($_SERVER['QUERY_STRING']) &&
126
+ !empty($_SERVER['QUERY_STRING']) ){
127
+ if( preg_match('/lcp_page' . preg_quote($this->instance) .
128
+ '=([0-9]+)/i', $_SERVER['QUERY_STRING'], $match) ):
129
+ $this->page = $match[1];
130
+ $offset = ($this->page - 1) * $this->params['numberposts'];
131
+ $args = array_merge($args, array('offset' => $offset));
132
+ endif;
133
+ }
134
  endif;
135
 
136
  // Posts that start with a given letter:
230
  }
231
 
232
  private function get_lcp_category(){
233
+ // In a category page:
234
  if ( $this->lcp_not_empty('categorypage') &&
235
  $this->params['categorypage'] == 'yes' ||
236
  $this->params['id'] == -1):
237
  $this->lcp_category_id = $this->lcp_get_current_category();
238
+ // Using the category name:
239
  elseif ( $this->lcp_not_empty('name') ):
240
  if (preg_match('/\+/', $this->params['name'])):
241
  $categories = array();
262
  else:
263
  $this->lcp_category_id = $this->get_category_id_by_name($this->params['name']);
264
  endif;
265
+ // Using the id:
266
  elseif ( isset($this->params['id']) && $this->params['id'] != '0' ):
267
  if (preg_match('/\+/', $this->params['id'])):
268
  if ( preg_match('/(-[0-9]+)+/', $this->params['id'], $matches) ):
269
  $this->exclude = implode(',', explode("-", ltrim($matches[0], '-') ));
270
  endif;
271
+ $this->lcp_category_id = array_map('intval', explode( "+", $this->params['id'] ) );
272
  else:
273
  $this->lcp_category_id = $this->params['id'];
274
  endif;
include/lcp-options.php CHANGED
@@ -18,11 +18,10 @@ function list_category_posts_options() {
18
  if ( !current_user_can( 'manage_options' ) ) {
19
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
20
  }
21
- $numberposts = get_option('numberposts');
22
  ?>
23
  <div class="wrap">
24
  <h2>List Category Posts</h2>
25
- <form method="post" action="lcp-options.php">
26
  <?php
27
  settings_fields('list_category_posts_group');
28
  do_settings_sections('list_category_posts_group');
@@ -37,7 +36,7 @@ function list_category_posts_options() {
37
  </label>
38
  </th>
39
  <td>
40
- <input type="text" id="numberposts" name="numberposts" value="<?php echo $numberposts; ?>"/>
41
  <small>
42
  <ul>
43
  <li>
18
  if ( !current_user_can( 'manage_options' ) ) {
19
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
20
  }
 
21
  ?>
22
  <div class="wrap">
23
  <h2>List Category Posts</h2>
24
+ <form method="post" action="options.php">
25
  <?php
26
  settings_fields('list_category_posts_group');
27
  do_settings_sections('list_category_posts_group');
36
  </label>
37
  </th>
38
  <td>
39
+ <input type="text" id="numberposts" name="numberposts" value="<?php echo esc_attr( get_option('numberposts') ); ?>"/>
40
  <small>
41
  <ul>
42
  <li>
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 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.51
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.52
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.0
7
- Stable tag: 0.51
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -422,6 +422,12 @@ Template system has changed. Custom templates should be stored in WordPress them
422
 
423
  == Changelog ==
424
 
 
 
 
 
 
 
425
  = 0.51 =
426
  * Fixes translations, updates Spanish translation. Translators, please update your po and mo files and submit them via pull request on GitHub :)
427
  * Test compatibility with WordPress 4.0
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.1
7
+ Stable tag: 0.52
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
422
 
423
  == Changelog ==
424
 
425
+ = 0.52 =
426
+ * Small fix for pagination and query string.
427
+ * Fix on multiple categories with AND relationship.
428
+ * Fixes options page 404 and saving options.
429
+ * Tested with WordPress 4.1.
430
+
431
  = 0.51 =
432
  * Fixes translations, updates Spanish translation. Translators, please update your po and mo files and submit them via pull request on GitHub :)
433
  * Test compatibility with WordPress 4.0