List category posts - Version 0.22

Version Description

  • Added CSS "current" class hook for current post in the list: .current class attached to either the li or a tag of the currently viewed page in the said list. http://wordpress.stackexchange.com/q/35552/298
    • Added morelink parameter, check Other notes for usage.
Download this release

Release Info

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

Code changes from version 0.21.2 to 0.22

.gitignore ADDED
@@ -0,0 +1 @@
 
1
+ .project
include/CatList.php CHANGED
@@ -69,9 +69,7 @@ class CatList{
69
 
70
  private function get_lcp_category(){
71
  if ( isset($this->params['categorypage']) && $this->params['categorypage'] == 'yes' ){
72
- global $post;
73
- $categories = get_the_category($post->ID);
74
- $this->lcp_category_id = $categories[0]->cat_ID;
75
  } elseif ( !empty($this->params['name']) ){
76
  if (preg_match('/,/', $this->params['name'])){
77
  $categories = '';
@@ -89,6 +87,12 @@ class CatList{
89
  }
90
  }
91
 
 
 
 
 
 
 
92
  /**
93
  * Get the category id from its name
94
  * by Eric Celeste / http://eric.clst.org
69
 
70
  private function get_lcp_category(){
71
  if ( isset($this->params['categorypage']) && $this->params['categorypage'] == 'yes' ){
72
+ $this->lcp_category_id = lcp_get_current_category();
 
 
73
  } elseif ( !empty($this->params['name']) ){
74
  if (preg_match('/,/', $this->params['name'])){
75
  $categories = '';
87
  }
88
  }
89
 
90
+ public function lcp_get_current_category(){
91
+ global $post;
92
+ $categories = get_the_category($post->ID);
93
+ return $categories[0]->cat_ID;
94
+ }
95
+
96
  /**
97
  * Get the category id from its name
98
  * by Eric Celeste / http://eric.clst.org
include/CatListDisplayer.php CHANGED
@@ -54,7 +54,6 @@ class CatListDisplayer {
54
  }
55
 
56
  private function build_output($tag){
57
- $this->lcp_output .= $this->get_category_link('strong');
58
  $this->lcp_output .= '<' . $tag;
59
  if (isset($this->params['class'])): $this->lcp_output .= ' class="' . $this->params['class'] . '"'; endif;
60
  $this->lcp_output .= '>';
@@ -65,8 +64,14 @@ class CatListDisplayer {
65
  $this->lcp_output .= $this->lcp_build_post($single, $inner_tag);
66
  }
67
  endforeach;
68
-
69
  $this->lcp_output .= '</' . $tag . '>';
 
 
 
 
 
 
 
70
  }
71
 
72
  /**
@@ -76,7 +81,13 @@ class CatListDisplayer {
76
  * @return string
77
  */
78
  private function lcp_build_post($single, $tag){
79
- $lcp_display_output = '<'. $tag . '>' . $this->get_post_title($single);
 
 
 
 
 
 
80
 
81
  $lcp_display_output .= $this->get_comments($single);
82
 
54
  }
55
 
56
  private function build_output($tag){
 
57
  $this->lcp_output .= '<' . $tag;
58
  if (isset($this->params['class'])): $this->lcp_output .= ' class="' . $this->params['class'] . '"'; endif;
59
  $this->lcp_output .= '>';
64
  $this->lcp_output .= $this->lcp_build_post($single, $inner_tag);
65
  }
66
  endforeach;
 
67
  $this->lcp_output .= '</' . $tag . '>';
68
+
69
+ if (!empty($this->params['morelink'])):
70
+ $this->lcp_output .= '<a href="' . get_category_link($this->catlist->get_category_id()) . '">'
71
+ . $this->params['morelink'] . '</a>';
72
+ endif;
73
+
74
+
75
  }
76
 
77
  /**
81
  * @return string
82
  */
83
  private function lcp_build_post($single, $tag){
84
+ global $post;
85
+ $class ='';
86
+ if ( $post->ID == $single->ID ):
87
+ $class = " class = current ";
88
+ endif;
89
+ $lcp_display_output = '<'. $tag . $class . '>';
90
+ $lcp_display_output .= $this->get_post_title($single);
91
 
92
  $lcp_display_output .= $this->get_comments($single);
93
 
include/ListCategoryPostsWidget.php CHANGED
@@ -29,6 +29,7 @@ class ListCategoryPostsWidget extends WP_Widget{
29
  $showcatlink = ($instance['show_catlink'] == 'on') ? 'yes' : 'no';
30
  $thumbnail = ($instance['thumbnail'] == 'on') ? 'yes' : 'no';
31
  $thumbnail_size = ($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 'thumbnail';
 
32
 
33
  echo $before_widget;
34
  echo $before_title . $title . $after_title;
@@ -48,7 +49,8 @@ class ListCategoryPostsWidget extends WP_Widget{
48
  'offset' => $offset,
49
  'catlink' => $showcatlink,
50
  'thumbnail' => $thumbnail,
51
- 'thumbnail_size' => $thumbnail_size
 
52
  );
53
 
54
  $catlist_displayer = new CatListDisplayer($atts);
@@ -75,6 +77,7 @@ class ListCategoryPostsWidget extends WP_Widget{
75
  $instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
76
  $instance['thumbnail'] = strip_tags($new_instance['thumbnail']);
77
  $instance['thumbnail_size'] = strip_tags($new_instance['thumbnail_size']);
 
78
 
79
  return $instance;
80
  }
29
  $showcatlink = ($instance['show_catlink'] == 'on') ? 'yes' : 'no';
30
  $thumbnail = ($instance['thumbnail'] == 'on') ? 'yes' : 'no';
31
  $thumbnail_size = ($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 'thumbnail';
32
+ $morelink = empty($instance['morelink']) ? ' ' : $instance['morelink'];
33
 
34
  echo $before_widget;
35
  echo $before_title . $title . $after_title;
49
  'offset' => $offset,
50
  'catlink' => $showcatlink,
51
  'thumbnail' => $thumbnail,
52
+ 'thumbnail_size' => $thumbnail_size,
53
+ 'morelink' => $morelink
54
  );
55
 
56
  $catlist_displayer = new CatListDisplayer($atts);
77
  $instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
78
  $instance['thumbnail'] = strip_tags($new_instance['thumbnail']);
79
  $instance['thumbnail_size'] = strip_tags($new_instance['thumbnail_size']);
80
+ $instance['morelink'] = strip_tags($new_instance['morelink']);
81
 
82
  return $instance;
83
  }
include/lcp_widget_form.php CHANGED
@@ -17,7 +17,8 @@ $instance = wp_parse_args( (array) $instance, array(
17
  'excludeposts'=>'',
18
  'thumbnail' =>'',
19
  'offset'=>'',
20
- 'show_catlink'=>'' ) );
 
21
  $title = strip_tags($instance['title']);
22
  $limit = strip_tags($instance['limit']);
23
  $orderby = strip_tags($instance['orderby']);
@@ -32,6 +33,7 @@ $categoryid = strip_tags($instance['categoryid']);
32
  $showexcerpt = strip_tags($instance['show_excerpt']);
33
  $thumbnail = strip_tags($instance['thumbnail']);
34
  $thumbnail_size = strip_tags($instance['thumbnail_size']);
 
35
  ?>
36
 
37
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e("Title", 'list-category-posts')?></label>
@@ -103,31 +105,38 @@ $thumbnail_size = strip_tags($instance['thumbnail_size']);
103
  </p>
104
 
105
 
106
- <label><?php _e("Show", 'list-category-posts')?>: </label><br/>
107
- <p>
108
- <input type="checkbox" <?php checked( (bool) $instance['thumbnail'], true ); ?>
109
- name="<?php echo $this->get_field_name( 'thumbnail'); ?>" /><?php _e("Thumbnail - size", 'list-category-posts')?>
110
- <select id="<?php echo $this->get_field_id('thumbnail_size'); ?>"
111
- name="<?php echo $this->get_field_name( 'thumbnail_size' ); ?>" type="text">
112
- <option value='thumbnail'>thumbnail</option>
113
- <option value='medium'>medium</option>
114
- <option value='large'>large</option>
115
- <option value='full'>full</option>
116
- </select>
117
- </p>
118
- <p>
119
- <input type="checkbox" <?php checked( (bool) $instance['show_date'], true ); ?>
120
- name="<?php echo $this->get_field_name( 'show_date' ); ?>" /><?php _e("Date", 'list-category-posts')?>
121
- </p>
122
- <p>
123
- <input type="checkbox" <?php checked( (bool) $instance['show_author'], true ); ?>
124
- name="<?php echo $this->get_field_name( 'show_author' ); ?>" /><?php _e("Author", 'list-category-posts')?>
125
- </p>
126
- <p>
127
- <input type="checkbox" <?php checked( (bool) $instance['show_catlink'], true ); ?>
128
- name="<?php echo $this->get_field_name( 'show_catlink' ); ?>" /><?php _e("Link to category", 'list-category-posts')?>
129
- </p>
130
- <p>
131
- <input type="checkbox" <?php checked( (bool) $instance['show_excerpt'], true ); ?>
132
- name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" /><?php _e("Excerpt", 'list-category-posts')?>
133
- </p>
 
 
 
 
 
 
 
17
  'excludeposts'=>'',
18
  'thumbnail' =>'',
19
  'offset'=>'',
20
+ 'show_catlink'=>'',
21
+ 'morelink' =>'' ) );
22
  $title = strip_tags($instance['title']);
23
  $limit = strip_tags($instance['limit']);
24
  $orderby = strip_tags($instance['orderby']);
33
  $showexcerpt = strip_tags($instance['show_excerpt']);
34
  $thumbnail = strip_tags($instance['thumbnail']);
35
  $thumbnail_size = strip_tags($instance['thumbnail_size']);
36
+ $morelink = strip_tags($instance['morelink']);
37
  ?>
38
 
39
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e("Title", 'list-category-posts')?></label>
105
  </p>
106
 
107
 
108
+ <label><?php _e("Show", 'list-category-posts')?>: </label><br/>
109
+ <p>
110
+ <input type="checkbox" <?php checked( (bool) $instance['thumbnail'], true ); ?>
111
+ name="<?php echo $this->get_field_name( 'thumbnail'); ?>" /> <?php _e("Thumbnail - size", 'list-category-posts')?>
112
+ <select id="<?php echo $this->get_field_id('thumbnail_size'); ?>"
113
+ name="<?php echo $this->get_field_name( 'thumbnail_size' ); ?>" type="text">
114
+ <option value='thumbnail'>thumbnail</option>
115
+ <option value='medium'>medium</option>
116
+ <option value='large'>large</option>
117
+ <option value='full'>full</option>
118
+ </select>
119
+ </p>
120
+ <p>
121
+ <input type="checkbox" <?php checked( (bool) $instance['show_date'], true ); ?>
122
+ name="<?php echo $this->get_field_name( 'show_date' ); ?>" /> <?php _e("Date", 'list-category-posts')?>
123
+ </p>
124
+ <p>
125
+ <input type="checkbox" <?php checked( (bool) $instance['show_author'], true ); ?>
126
+ name="<?php echo $this->get_field_name( 'show_author' ); ?>" /> <?php _e("Author", 'list-category-posts')?>
127
+ </p>
128
+ <p>
129
+ <input type="checkbox" <?php checked( (bool) $instance['show_catlink'], true ); ?>
130
+ name="<?php echo $this->get_field_name( 'show_catlink' ); ?>" /> <?php _e("Link to category", 'list-category-posts')?>
131
+ </p>
132
+ <p>
133
+ <input type="checkbox" <?php checked( (bool) $instance['show_excerpt'], true ); ?>
134
+ name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" /> <?php _e("Excerpt", 'list-category-posts')?>
135
+ </p>
136
+ <p>
137
+ <label for="<?php echo $this->get_field_id('morelink'); ?>"><?php _e("More link", 'list-category-posts')?>: <br/>
138
+ <input class="widefat" id="<?php echo $this->get_field_id('morelink'); ?>"
139
+ name="<?php echo $this->get_field_name('morelink'); ?>" type="text"
140
+ value="<?php echo esc_attr($morelink); ?>" />
141
+ </p>
142
+
list_cat_posts.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: List category posts
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
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.21.2
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
  */
@@ -63,7 +63,8 @@ class ListCategoryPosts{
63
  'customfield_value' =>'',
64
  'customfield_display' =>'',
65
  'taxonomy' => '',
66
- 'categorypage' => ''
 
67
  ), $atts);
68
 
69
  $catlist_displayer = new CatListDisplayer($atts);
3
  Plugin Name: List category posts
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
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.22
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
  */
63
  'customfield_value' =>'',
64
  'customfield_display' =>'',
65
  'taxonomy' => '',
66
+ 'categorypage' => '',
67
+ 'morelink' => ''
68
  ), $atts);
69
 
70
  $catlist_displayer = new CatListDisplayer($atts);
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: 2.8
6
  Tested up to: 3.2.1
7
- Stable tag: 0.21.2
8
 
9
  == Description ==
10
  List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode.
@@ -23,9 +23,14 @@ Please, read the information on [Other Notes](http://wordpress.org/extend/plugin
23
 
24
  `[catlist argument1=value1 argument2=value2]`
25
 
 
 
26
  **Support the plugin**
27
 
28
- If you've found the plugin useful, consider making a [donation via PayPal](http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/ "Donate via PayPal") or visit my [Amazon Wishlist](http://www.amazon.com/gp/registry/wishlist/2HU1JYOF7DX5Q/ref=wl_web "Amazon Wishlist"). **New Code is always welcome** :D
 
 
 
29
 
30
 
31
  ==Installation==
@@ -113,6 +118,8 @@ You can use the *categorypage* parameter to make it detect the category id of th
113
 
114
  * **template** - File name of template from templates directory without extension. Example: For 'template.php' value is only 'template'. Default is 'default', which displays an unordered list (ul html tag) with a CSS class. This class can be passed as a parameter or by default it's: 'lcp_catlist'. You can also use the default 'div' value. This will output a div with the 'lcp_catlist' CSS class (or one you pass as parameter with the class argument). The inner items (posts) will be displayed between p tags.
115
 
 
 
116
  == Template System ==
117
 
118
  Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under 'wp-content/themes/your-theme-folder'. Template files are .php files.
@@ -158,6 +165,10 @@ Template system has changed. Custom templates should be stored in WordPress them
158
 
159
  == Changelog ==
160
 
 
 
 
 
161
  = 0.21.2 =
162
  * Removed var_dump... (Sorry about that)
163
 
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.8
6
  Tested up to: 3.2.1
7
+ Stable tag: 0.22
8
 
9
  == Description ==
10
  List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode.
23
 
24
  `[catlist argument1=value1 argument2=value2]`
25
 
26
+
27
+
28
  **Support the plugin**
29
 
30
+ If you've found the plugin useful, consider making a [donation via PayPal](http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/ "Donate via PayPal") or visit my [Amazon Wishlist](http://www.amazon.com/gp/registry/wishlist/2HU1JYOF7DX5Q/ref=wl_web "Amazon Wishlist").
31
+
32
+ **New Code is always welcome** :D
33
+ [Fork the plugin on GitHub](https://github.com/picandocodigo/List-Category-Posts).
34
 
35
 
36
  ==Installation==
118
 
119
  * **template** - File name of template from templates directory without extension. Example: For 'template.php' value is only 'template'. Default is 'default', which displays an unordered list (ul html tag) with a CSS class. This class can be passed as a parameter or by default it's: 'lcp_catlist'. You can also use the default 'div' value. This will output a div with the 'lcp_catlist' CSS class (or one you pass as parameter with the class argument). The inner items (posts) will be displayed between p tags.
120
 
121
+ * **morelink** - Include a "more" link to access the category archive for the category. The link is inserted after listing the posts. It receives a string of characters as a parameter which will be used as the text of the link. Example: [catlist id=38 morelink="Read more"]
122
+
123
  == Template System ==
124
 
125
  Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under 'wp-content/themes/your-theme-folder'. Template files are .php files.
165
 
166
  == Changelog ==
167
 
168
+ = 0.22 =
169
+ * Added CSS "current" class hook for current post in the list: .current class attached to either the li or a tag of the currently viewed page in the said list. http://wordpress.stackexchange.com/q/35552/298
170
+ * Added *morelink* parameter, check Other notes for usage.
171
+
172
  = 0.21.2 =
173
  * Removed var_dump... (Sorry about that)
174