List category posts - Version 0.59

Version Description

Thanks Sophist from UK for this release :)

By Sophist:

  • Fix error causing call to undefined method
  • Add excerpt=full to allow either full explicit excerpt or use <?--more--> to define where the excerpt ends.
  • Fixes link_titles=false creates plain text rather than unlinked formatted text as you might expect.
  • Fixes title_limit not working correctly

Other minor fixes by me.

Download this release

Release Info

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

Code changes from version 0.58.1 to 0.59

include/lcp-catlist.php CHANGED
@@ -317,22 +317,29 @@ class CatList{
317
  }
318
 
319
  public function get_excerpt($single){
320
- if ( !empty($this->params['excerpt']) && $this->params['excerpt']=='yes'){
321
-
322
- if($single->post_excerpt == ("")){
323
- //No excerpt, generate one:
324
- $lcp_excerpt = $this->lcp_trim_excerpt($single->post_content);
 
 
 
 
 
 
 
 
 
 
325
  }else{
326
- if(!empty($this->params['excerpt_overwrite']) &&
327
- $this->params['excerpt_overwrite'] == 'yes'){
328
- // Excerpt but we want to overwrite it:";
329
- $lcp_excerpt = $this->lcp_trim_excerpt($single->post_content);
330
  } else {
331
- // Bring post excerpt;
332
  $lcp_excerpt = $this->lcp_trim_excerpt($single->post_excerpt);
333
  }
334
  }
335
-
336
  if( strlen($lcp_excerpt) < 1 ){
337
  $lcp_excerpt = $single->post_title;
338
  }
317
  }
318
 
319
  public function get_excerpt($single){
320
+ if ( !empty( $this->params['excerpt'] ) &&
321
+ ( $this->params['excerpt']=='yes' || $this->params['excerpt']=='full') ){
322
+
323
+ if( $single->post_excerpt == "" ||
324
+ ( !empty($this->params['excerpt_overwrite']) && $this->params['excerpt_overwrite'] == 'yes' ) ){
325
+ // No explicit excerpt or excerpt_overwrite=yes, so generate from content:
326
+ $lcp_content = $single->post_content;
327
+ // <!--more--> tag?
328
+ if( $this->params['excerpt']=='full' &&
329
+ preg_match('/[\S\s]+(<!--more(.*?)?-->)[\S\s]+/', $lcp_content, $matches) ) {
330
+ $lcp_excerpt = explode($matches[1], $lcp_content);
331
+ $lcp_excerpt = $lcp_excerpt[0];
332
+ }else{
333
+ $lcp_excerpt = $this->lcp_trim_excerpt($lcp_content);
334
+ }
335
  }else{
336
+ // Explicit excerpt and excerpt_overwrite=no:
337
+ if( $this->params['excerpt']=='full' ){
338
+ $lcp_excerpt = $single->post_excerpt;
 
339
  } else {
 
340
  $lcp_excerpt = $this->lcp_trim_excerpt($single->post_excerpt);
341
  }
342
  }
 
343
  if( strlen($lcp_excerpt) < 1 ){
344
  $lcp_excerpt = $single->post_title;
345
  }
include/lcp-catlistdisplayer.php CHANGED
@@ -195,9 +195,7 @@ class CatListDisplayer {
195
  $url = strtok($request_uri,'?');
196
  $protocol = "http";
197
  $port = $_SERVER['SERVER_PORT'];
198
- $https = $_SERVER['HTTPS'];
199
- if ( (!empty($https) && $https !== 'off') ||
200
- $port == 443){
201
  $protocol = "https";
202
  }
203
  $http_host = $_SERVER['HTTP_HOST'];
@@ -224,9 +222,10 @@ class CatListDisplayer {
224
  global $post;
225
 
226
  $class ='';
227
- if ( $post->ID == $single->ID ):
 
228
  $class = " class = current ";
229
- endif;
230
 
231
  $lcp_display_output = '<'. $tag . $class . '>';
232
 
@@ -294,7 +293,7 @@ class CatListDisplayer {
294
  $stuffFunction = 'get_' . $entity;
295
  if (!empty($this->params[$entity . '_tag'])):
296
  if (!empty($this->params[$entity . '_class'])):
297
- $result = $this->stuffFunction($single, $this->params[$entity . '_tag'], $this->params[$entity . '_class']);
298
  else:
299
  $result = $this->$stuffFunction($single, $this->params[$entity . '_tag']);
300
  endif;
@@ -398,22 +397,33 @@ class CatListDisplayer {
398
  // Link is a parameter here in case you want to use it on a template
399
  // and not show the links for all the shortcodes using this template:
400
  private function get_post_title($single, $tag = null, $css_class = null, $link = true){
401
- if ( !$link || !empty($this->params['link_titles']) && $this->params['link_titles'] === "false" ) {
402
- return $single->post_title;
403
- }
404
-
405
- $info = '<a href="' . get_permalink($single->ID);
406
-
407
  $lcp_post_title = apply_filters('the_title', $single->post_title, $single->ID);
408
 
409
- if ( !empty($this->params['title_limit']) && $this->params['title_limit'] != "0" ):
410
- $lcp_post_title = substr($lcp_post_title, 0, intval($this->params['title_limit']));
411
- if( strlen($lcp_post_title) >= intval($this->params['title_limit']) ):
412
- $lcp_post_title .= "&hellip;";
413
  endif;
414
  endif;
415
 
416
- $info.= '" title="' . wptexturize($single->post_title) . '"';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
 
418
  if (!empty($this->params['link_target'])):
419
  $info .= ' target="' . $this->params['link_target'] . '" ';
@@ -430,15 +440,7 @@ class CatListDisplayer {
430
  $info .= " " . $this->params['post_suffix'];
431
  endif;
432
 
433
- if (!empty($this->params['title_tag'])){
434
- $pre = "<" . $this->params['title_tag'];
435
- if (!empty($this->params['title_class'])){
436
- $pre .= ' class="' . $this->params['title_class'] . '"';
437
- }
438
- $pre .= '>';
439
- $post = "</" . $this->params['title_tag'] . ">";
440
- $info = $pre . $info . $post;
441
- }
442
 
443
  if( $tag !== null || $css_class !== null){
444
  $info = $this->assign_style($info, $tag, $css_class);
195
  $url = strtok($request_uri,'?');
196
  $protocol = "http";
197
  $port = $_SERVER['SERVER_PORT'];
198
+ if ( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $port == 443){
 
 
199
  $protocol = "https";
200
  }
201
  $http_host = $_SERVER['HTTP_HOST'];
222
  global $post;
223
 
224
  $class ='';
225
+
226
+ if ( is_object($post->ID) && is_object($single->ID) && $post->ID == $single->ID ){
227
  $class = " class = current ";
228
+ }
229
 
230
  $lcp_display_output = '<'. $tag . $class . '>';
231
 
293
  $stuffFunction = 'get_' . $entity;
294
  if (!empty($this->params[$entity . '_tag'])):
295
  if (!empty($this->params[$entity . '_class'])):
296
+ $result = $this->$stuffFunction($single, $this->params[$entity . '_tag'], $this->params[$entity . '_class']);
297
  else:
298
  $result = $this->$stuffFunction($single, $this->params[$entity . '_tag']);
299
  endif;
397
  // Link is a parameter here in case you want to use it on a template
398
  // and not show the links for all the shortcodes using this template:
399
  private function get_post_title($single, $tag = null, $css_class = null, $link = true){
 
 
 
 
 
 
400
  $lcp_post_title = apply_filters('the_title', $single->post_title, $single->ID);
401
 
402
+ if ( !empty($this->params['title_limit']) && $this->params['title_limit'] !== "0" ):
403
+ $title_limit = intval($this->params['title_limit']);
404
+ if( mb_strlen($lcp_post_title) > $title_limit ):
405
+ $lcp_post_title = mb_substr($lcp_post_title, 0, $title_limit) . "&hellip;";
406
  endif;
407
  endif;
408
 
409
+ if (!empty($this->params['title_tag'])){
410
+ $pre = "<" . $this->params['title_tag'];
411
+ if (!empty($this->params['title_class'])){
412
+ $pre .= ' class="' . $this->params['title_class'] . '"';
413
+ }
414
+ $pre .= '>';
415
+ $post = "</" . $this->params['title_tag'] . ">";
416
+ }else{
417
+ $pre = $post = '';
418
+ }
419
+
420
+ if ( !$link ||
421
+ (!empty($this->params['link_titles']) &&
422
+ ( $this->params['link_titles'] === "false" || $this->params['link_titles'] === "no" ) ) ) {
423
+ return $pre . $lcp_post_title . $post;
424
+ }
425
+
426
+ $info = '<a href="' . get_permalink($single->ID) . '" title="' . wptexturize($single->post_title) . '"';
427
 
428
  if (!empty($this->params['link_target'])):
429
  $info .= ' target="' . $this->params['link_target'] . '" ';
440
  $info .= " " . $this->params['post_suffix'];
441
  endif;
442
 
443
+ $info = $pre . $info . $post;
 
 
 
 
 
 
 
 
444
 
445
  if( $tag !== null || $css_class !== null){
446
  $info = $this->assign_style($info, $tag, $css_class);
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.58.1
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.59
7
  Author: Fernando Briano
8
  Author URI: http://fernandobriano.com
9
 
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: 4.1.1
7
- Stable tag: 0.58.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -211,7 +211,13 @@ update the plugin.
211
 
212
  * **dateformat** - Format of the date output. The default format is the one you've set on your WordPress settings. Example: `[catlist id=42 dateformat="l F dS, Y"]` would display the date as "Monday January 21st, 2013". Check http://codex.wordpress.org/Formatting_Date_and_Time for more options to display date.
213
 
214
- * **excerpt** - Display the post's excerpt. Default is 'no', use `excerpt=yes` to activate it. If you don't have an excerpt in your post, the plugin will fetch this text from the content, striping its images, shortcodes and HTML tags. The limit is set by the *excerpt_size* parameter (55 words by default). If you want the automatically generated excerpt to respect your theme's allowed HTML tags, you should use `excerpt_strip=no`. If the post has an excerpt, the HTML tags are automatically stripped. If you want to overwrite the post's excerpt with an automatically generated one (may be usefull to allow HTML tags), use `excerpt_overwrite=yes`. I added this last parameter to have consistency across excerpts.
 
 
 
 
 
 
215
 
216
  * **excerpt_size** - Set the number of *words* to display from the excerpt. Default is 55. Eg: `excerpt_size=30`
217
 
@@ -445,8 +451,21 @@ Template system has changed. Custom templates should be stored in WordPress them
445
 
446
  == Changelog ==
447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
  = 0.58.1 =
449
- * Fixes an error with pagination links. Accessing $_SERVER filtered not working on some servers, have to investigate further for a future version.
450
  * Addresses warning messages when debug enabled.
451
 
452
  = 0.58 =
4
  Tags: list, categories, posts, cms
5
  Requires at least: 3.3
6
  Tested up to: 4.1.1
7
+ Stable tag: 0.59
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
211
 
212
  * **dateformat** - Format of the date output. The default format is the one you've set on your WordPress settings. Example: `[catlist id=42 dateformat="l F dS, Y"]` would display the date as "Monday January 21st, 2013". Check http://codex.wordpress.org/Formatting_Date_and_Time for more options to display date.
213
 
214
+ * **excerpt** - Display a plain text excerpt of the post. Default is 'no', use `excerpt=yes` or `excerpt=full` to activate it. If you have a separate excerpt in your post, this text will be used. If you don't have an explicit excerpt in your post, the plugin will generate one from the content, striping its images, shortcodes and HTML tags. If you want to overwrite the post's separate excerpt with an automatically generated one (may be useful to allow HTML tags), use `excerpt_overwrite=yes`.
215
+
216
+ If you use `excerpt=yes`, the separate excerpt or content will be limited to the number of words set by the *excerpt_size* parameter (55 words by default).
217
+
218
+ If you use `excerpt=full` the plugin will act more like Wordpress. If the post has a separate excerpt, it will be used in full. Otherwise if the content has a &lt;!--more--&gt; tag then the excerpt will be the text before this tag, and if there is no &lt;!--more--&gt; tag then the result will be the same as `excerpt=yes`.
219
+
220
+ If you want the automatically generated excerpt to respect your theme's allowed HTML tags, you should use `excerpt_strip=no`, otherwise the HTML tags are automatically stripped.
221
 
222
  * **excerpt_size** - Set the number of *words* to display from the excerpt. Default is 55. Eg: `excerpt_size=30`
223
 
451
 
452
  == Changelog ==
453
 
454
+ = 0.59 =
455
+
456
+ **Thanks Sophist from UK for this release** :)
457
+
458
+ By Sophist:
459
+
460
+ * Fix error causing call to undefined method
461
+ * Add excerpt=full to allow either full explicit excerpt or use <?--more--> to define where the excerpt ends.
462
+ * Fixes link_titles=false creates plain text rather than unlinked formatted text as you might expect.
463
+ * Fixes title_limit not working correctly
464
+
465
+ Other minor fixes by me.
466
+
467
  = 0.58.1 =
468
+ * Fixes an error with pagination links. Accessing $_SERVER filtered not working on some servers, have to investigate further for a future version.
469
  * Addresses warning messages when debug enabled.
470
 
471
  = 0.58 =