List category posts - Version 0.49

Version Description

  • Adds author_posts_link, to show an author's page.
  • Adds catname parameter to show just the category name (and not the link). Thanks user sirenAri from the forum.
  • Small bug fix for getting current category. Used to check against simple string, now checking against i18n'ed one.
Download this release

Release Info

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

Code changes from version 0.48 to 0.49

include/CatList.php CHANGED
@@ -270,7 +270,7 @@ class CatList{
270
 
271
  public function lcp_get_current_category(){
272
  $category = get_category( get_query_var( 'category' ) );
273
- if(isset($category->errors) && $category->errors["invalid_term"][0] == "Empty Term"):
274
  global $post;
275
  $categories = get_the_category($post->ID);
276
  return $categories[0]->cat_ID;
@@ -316,18 +316,29 @@ class CatList{
316
  * Load category name and link to the category:
317
  */
318
  public function get_category_link(){
319
- if($this->params['catlink'] == 'yes' && $this->lcp_category_id != 0):
320
- $ids = is_array($this->lcp_category_id) ?
321
- $this->lcp_category_id :
322
- explode(",", $this->lcp_category_id);
 
 
 
 
 
 
323
 
324
  $link = array();
325
  foreach($ids as $lcp_id){
326
  $cat_link = get_category_link($lcp_id);
327
  $cat_title = get_cat_name($lcp_id);
328
- array_push($link, '<a href="' . $cat_link . '" title="' . $cat_title . '">' .
329
- ($this->lcp_not_empty('catlink_string') ? $this->params['catlink_string'] : $cat_title) .
330
- $this->get_category_count($lcp_id) . '</a>');
 
 
 
 
 
331
  }
332
 
333
  return implode(", ", $link);
@@ -364,7 +375,8 @@ class CatList{
364
  * @param int $post_id
365
  */
366
  public function get_custom_fields($custom_key, $post_id){
367
- if($this->params['customfield_display'] != ''):
 
368
  $lcp_customs = '';
369
 
370
  //Doesn't work for many custom fields when having spaces:
@@ -407,9 +419,17 @@ class CatList{
407
  }
408
 
409
  public function get_author_to_show($single){
410
- if ($this->params['author']=='yes'):
411
  $lcp_userdata = get_userdata($single->post_author);
412
- return $lcp_userdata->display_name;
 
 
 
 
 
 
 
 
413
  else:
414
  return null;
415
  endif;
270
 
271
  public function lcp_get_current_category(){
272
  $category = get_category( get_query_var( 'category' ) );
273
+ if(isset($category->errors) && $category->errors["invalid_term"][0] == __("Empty Term") ):
274
  global $post;
275
  $categories = get_the_category($post->ID);
276
  return $categories[0]->cat_ID;
316
  * Load category name and link to the category:
317
  */
318
  public function get_category_link(){
319
+ if( ($this->params['catlink'] == 'yes' || $this->params['catname'] == 'yes') &&
320
+ $this->lcp_category_id != 0):
321
+
322
+ // Check for one id or several:
323
+ $ids = null;
324
+ if (is_array($this->lcp_category_id)){
325
+ $ids = $this->lcp_category_id;
326
+ } else{
327
+ $ids = explode(",", $this->lcp_category_id);
328
+ }
329
 
330
  $link = array();
331
  foreach($ids as $lcp_id){
332
  $cat_link = get_category_link($lcp_id);
333
  $cat_title = get_cat_name($lcp_id);
334
+ $cat_string = ($this->lcp_not_empty('catlink_string') ? $this->params['catlink_string'] : $cat_title);
335
+
336
+ if ($this->params['catlink'] == 'yes'){
337
+ $cat_string .= '<a href="' . $cat_link . '" title="' . $cat_title . '">' .
338
+ $cat_string .
339
+ $this->get_category_count($lcp_id) . '</a>';
340
+ }
341
+ array_push($link, $cat_string);
342
  }
343
 
344
  return implode(", ", $link);
375
  * @param int $post_id
376
  */
377
  public function get_custom_fields($custom_key, $post_id){
378
+ if( $this->lcp_not_empty('customfield_display') &&
379
+ ( $this->params['customfield_display'] != '') ):
380
  $lcp_customs = '';
381
 
382
  //Doesn't work for many custom fields when having spaces:
419
  }
420
 
421
  public function get_author_to_show($single){
422
+ if ($this->params['author'] == 'yes'):
423
  $lcp_userdata = get_userdata($single->post_author);
424
+ $author_name = $lcp_userdata->display_name;
425
+ if($this->lcp_not_empty('author_posts_link') &&
426
+ $this->params['author_posts_link'] == 'yes'){
427
+ $link = get_author_posts_url($lcp_userdata->ID);
428
+ return "<a href=" . $link . " title='" . $author_name .
429
+ "'>" . $author_name . "</a>";
430
+ } else {
431
+ return $author_name;
432
+ }
433
  else:
434
  return null;
435
  endif;
include/CatListDisplayer.php CHANGED
@@ -59,18 +59,7 @@ class CatListDisplayer {
59
  }
60
 
61
  private function build_output($tag){
62
- // More link
63
- if (!empty($this->params['catlink_tag'])):
64
- if (!empty($this->params['catlink_class'])):
65
- $this->lcp_output .= $this->get_category_link(
66
- $this->params['catlink_tag'],
67
- $this->params['catlink_class']);
68
- else:
69
- $this->lcp_output .= $this->get_category_link($this->params['catlink_tag']);
70
- endif;
71
- else:
72
- $this->lcp_output .= $this->get_category_link("strong");
73
- endif;
74
 
75
  $this->lcp_output .= '<' . $tag;
76
 
@@ -303,6 +292,22 @@ class CatListDisplayer {
303
  return $lcp_display_output;
304
  }
305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  /**
307
  * Auxiliary functions for templates
308
  */
59
  }
60
 
61
  private function build_output($tag){
62
+ $this->category_title();
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  $this->lcp_output .= '<' . $tag;
65
 
292
  return $lcp_display_output;
293
  }
294
 
295
+ private function category_title(){
296
+ // More link
297
+ if (!empty($this->params['catlink_tag'])):
298
+ if (!empty($this->params['catlink_class'])):
299
+ $this->lcp_output .= $this->get_category_link(
300
+ $this->params['catlink_tag'],
301
+ $this->params['catlink_class']
302
+ );
303
+ else:
304
+ $this->lcp_output .= $this->get_category_link($this->params['catlink_tag']);
305
+ endif;
306
+ else:
307
+ $this->lcp_output .= $this->get_category_link("strong");
308
+ endif;
309
+ }
310
+
311
  /**
312
  * Auxiliary functions for templates
313
  */
include/ListCategoryPostsWidget.php CHANGED
@@ -56,10 +56,18 @@ class ListCategoryPostsWidget extends WP_Widget{
56
 
57
  echo $before_widget;
58
 
59
- if($title == 'catlink'){
60
- //if the user has setup 'catlink' as the title, replace it with the category link:
 
61
  $lcp_category = get_category($category_id);
62
- $title = '<a href="' . get_category_link($lcp_category->cat_ID) . '">' . $lcp_category->name . '</a>';
 
 
 
 
 
 
 
63
  }
64
  echo $before_title . $title . $after_title;
65
 
56
 
57
  echo $before_widget;
58
 
59
+ if ($title == 'catlink') {
60
+ // If the user has setup 'catlink' as the title, replace it with
61
+ // the category link:
62
  $lcp_category = get_category($category_id);
63
+ $title = '<a href="' . get_category_link($lcp_category->cat_ID) . '">' .
64
+ $lcp_category->name . '</a>';
65
+ } elseif ($title == 'catname') {
66
+ global $post;
67
+ // If the user has setup 'catname' as the title, replace it with
68
+ // the category link:
69
+ $lcp_category = get_the_category($post->ID);
70
+ $title = $lcp_category[0]->name;
71
  }
72
  echo $before_title . $title . $after_title;
73
 
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.48
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
 
@@ -54,6 +54,7 @@ class ListCategoryPosts{
54
  'date_modified_tag' => '',
55
  'date_modified_class' => '',
56
  'author' => 'no',
 
57
  'author_tag' =>'',
58
  'author_class' => '',
59
  'author_posts' => '',
@@ -75,6 +76,7 @@ class ListCategoryPosts{
75
  'content_class' => '',
76
  'display_id' => 'no',
77
  'catlink' => 'no',
 
78
  'catlink_string' => '',
79
  'catlink_tag' =>'',
80
  'catlink_class' => '',
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.49
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
 
54
  'date_modified_tag' => '',
55
  'date_modified_class' => '',
56
  'author' => 'no',
57
+ 'author_posts_link' => 'no',
58
  'author_tag' =>'',
59
  'author_class' => '',
60
  'author_posts' => '',
76
  'content_class' => '',
77
  'display_id' => 'no',
78
  'catlink' => 'no',
79
+ 'catname' => 'no',
80
  'catlink_string' => '',
81
  'catlink_tag' =>'',
82
  'catlink_class' => '',
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.9.1
7
- Stable tag: 0.48
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -195,6 +195,13 @@ update the plugin.
195
  tag to wrap the author name in with `author_class` and `author_tag` (see HTML
196
  & CSS Customization further below).
197
 
 
 
 
 
 
 
 
198
  * **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.
199
 
200
  * **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,6 +222,8 @@ update the plugin.
215
 
216
  * **catlink** - Show the title of the category with a link to the category. Use the **catlink_string** option to change the link text. Default is 'no'. Ex: `[catlist catlink=yes]`. The way it's programmed, it should only display the title for the first category you chose, and include the posts from all of the categories. I thought of this parameter mostly for using several shortcodes on one page or post, so that each group of posts would have the title of that group's category. If you need to display several titles with posts, you should use one [catlist] shortcode for each category you want to display.
217
 
 
 
218
  * **category_count** - Shows the posts count in that category, only works when using the **catlink** option: `[catlist name=nintendo catlink=yes category_count=yes]`
219
 
220
  * **comments** - Show comments count for each post. Default is 'no'. Ex: `[catlist comments=yes]`.
@@ -410,6 +419,12 @@ Template system has changed. Custom templates should be stored in WordPress them
410
 
411
  == Changelog ==
412
 
 
 
 
 
 
 
413
  = 0.48 =
414
 
415
  * Bug fixes
4
  Tags: list, categories, posts, cms
5
  Requires at least: 3.3
6
  Tested up to: 3.9.1
7
+ Stable tag: 0.49
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
195
  tag to wrap the author name in with `author_class` and `author_tag` (see HTML
196
  & CSS Customization further below).
197
 
198
+ When displaying the post author, you can also display a link to the
199
+ author's page. The following parameter **only works if author=yes
200
+ is present in the shortcode**:
201
+
202
+ * **author_posts_link** - Gets the URL of the author page for the
203
+ author. The HTML and CSS customization are the ones applied to `author`.
204
+
205
  * **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.
206
 
207
  * **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.
222
 
223
  * **catlink** - Show the title of the category with a link to the category. Use the **catlink_string** option to change the link text. Default is 'no'. Ex: `[catlist catlink=yes]`. The way it's programmed, it should only display the title for the first category you chose, and include the posts from all of the categories. I thought of this parameter mostly for using several shortcodes on one page or post, so that each group of posts would have the title of that group's category. If you need to display several titles with posts, you should use one [catlist] shortcode for each category you want to display.
224
 
225
+ * **catname** - Show the title of the category (or categories), works exactly as `catlink`, but it doesn't add a link to the category.
226
+
227
  * **category_count** - Shows the posts count in that category, only works when using the **catlink** option: `[catlist name=nintendo catlink=yes category_count=yes]`
228
 
229
  * **comments** - Show comments count for each post. Default is 'no'. Ex: `[catlist comments=yes]`.
419
 
420
  == Changelog ==
421
 
422
+ = 0.49 =
423
+
424
+ * Adds `author_posts_link`, to show an author's page.
425
+ * Adds catname parameter to show just the category name (and not the link). Thanks user sirenAri from the [forum](http://wordpress.org/support/topic/a-couple-of-suggestions-and-one-teensy-error).
426
+ * Small bug fix for getting current category. Used to check against simple string, now checking against i18n'ed one.
427
+
428
  = 0.48 =
429
 
430
  * Bug fixes