Version Description
-
New feature: use
link_current=no
to prevent the current post from being wrapped in a link. -
New feature: display categories and tags of each post with
posts_cats
andposts_tags
, a bunch of new parameters have been added to customise this feature, see the docs. - Fixed an issue with
currenttags
, when navigating to a post with no tags, no posts are displayed, same as withcategorypage
. - Updated the testing environment and CI scripts.
Download this release
Release Info
Developer | fernandobt |
Plugin | List category posts |
Version | 0.86 |
Comparing to | |
See all releases |
Code changes from version 0.85.1 to 0.86
- include/lcp-catlist.php +71 -0
- include/lcp-catlistdisplayer.php +24 -2
- include/lcp-parameters.php +10 -0
- list-category-posts.php +16 -1
- readme.txt +8 -1
- templates/default.php +6 -0
include/lcp-catlist.php
CHANGED
@@ -286,6 +286,77 @@ class CatList{
|
|
286 |
}
|
287 |
}
|
288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
public function get_author_to_show($single) {
|
290 |
if ($this->params['author'] == 'yes') {
|
291 |
$lcp_userdata = get_userdata($single->post_author);
|
286 |
}
|
287 |
}
|
288 |
|
289 |
+
/**
|
290 |
+
* Parse posts_tags parameters
|
291 |
+
*/
|
292 |
+
public function get_posts_terms($single, $tax) {
|
293 |
+
// Check if terms should be displayed.
|
294 |
+
if ('yes' !== $this->params["posts_{$tax}s"]) {
|
295 |
+
return null;
|
296 |
+
}
|
297 |
+
// Get parsed parameters.
|
298 |
+
$params = $this->get_pt_params($tax);
|
299 |
+
|
300 |
+
// Get the post's terms IDs, returns false if post has none.
|
301 |
+
$terms = get_the_terms($single->ID, $params['tax_slug']);
|
302 |
+
|
303 |
+
// Construct output string based on $params.
|
304 |
+
$output = '';
|
305 |
+
if (is_array($terms)) {
|
306 |
+
$output .= $params['prefix'];
|
307 |
+
$parsed_terms = array();
|
308 |
+
foreach($terms as $term) {
|
309 |
+
$term_string = $term->name;
|
310 |
+
$term_string = $this->pt_link_wrapper($params['link'], $term, $term_string);
|
311 |
+
$term_string = $this->pt_inner_wrapper(
|
312 |
+
$params['inner'],
|
313 |
+
$tax,
|
314 |
+
$term,
|
315 |
+
$term_string
|
316 |
+
);
|
317 |
+
$parsed_terms[] = $term_string;
|
318 |
+
}
|
319 |
+
$output .= implode($params['glue'], $parsed_terms);
|
320 |
+
return $output;
|
321 |
+
} else {
|
322 |
+
return null;
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
private function get_pt_params($tax) {
|
327 |
+
$taxonomies = ['cat' => 'category', 'tag' => 'post_tag'];
|
328 |
+
$slug = array_key_exists($tax, $taxonomies) ? $taxonomies[$tax] : '';
|
329 |
+
return array(
|
330 |
+
'tax_slug' => $slug,
|
331 |
+
'link' => 'yes' === $this->params["posts_{$tax}link"] ? true : false,
|
332 |
+
'prefix' => $this->params["posts_{$tax}s_prefix"] ?: null,
|
333 |
+
'glue' => $this->params["posts_{$tax}s_glue"] ?: null,
|
334 |
+
'inner' => $this->params["posts_{$tax}s_inner"] ?: null,
|
335 |
+
);
|
336 |
+
}
|
337 |
+
|
338 |
+
private function pt_link_wrapper($link, $term, $term_string) {
|
339 |
+
if ($link) {
|
340 |
+
$term_string = $this->wrapper->to_html(
|
341 |
+
'a',
|
342 |
+
['href' => get_term_link($term->term_id)],
|
343 |
+
$term_string
|
344 |
+
);
|
345 |
+
}
|
346 |
+
return $term_string;
|
347 |
+
}
|
348 |
+
|
349 |
+
private function pt_inner_wrapper($inner, $tax, $term, $term_string) {
|
350 |
+
if ($inner) {
|
351 |
+
$term_string = $this->wrapper->to_html(
|
352 |
+
$inner,
|
353 |
+
['class' => "{$tax}-{$term->slug}"],
|
354 |
+
$term_string
|
355 |
+
);
|
356 |
+
}
|
357 |
+
return $term_string;
|
358 |
+
}
|
359 |
+
|
360 |
public function get_author_to_show($single) {
|
361 |
if ($this->params['author'] == 'yes') {
|
362 |
$lcp_userdata = get_userdata($single->post_author);
|
include/lcp-catlistdisplayer.php
CHANGED
@@ -120,6 +120,14 @@ class CatListDisplayer {
|
|
120 |
return $this->content_getter('excerpt', $single, $tag, $css_class);
|
121 |
}
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
private function get_modified_date($single, $tag = null, $css_class = null){
|
124 |
return $info = $this->content_getter('date_modified', $single, $tag, $css_class);
|
125 |
}
|
@@ -205,6 +213,13 @@ class CatListDisplayer {
|
|
205 |
// Default wrapper behavior not supported here,
|
206 |
// class is only used inside the <a> element.
|
207 |
$css_class = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
}
|
209 |
return $this->wrapper->wrap($info, $tag, $css_class);
|
210 |
}
|
@@ -232,7 +247,8 @@ class CatListDisplayer {
|
|
232 |
|
233 |
// Link is a parameter here in case you want to use it on a template
|
234 |
// and not show the links for all the shortcodes using this template:
|
235 |
-
public function get_post_title($single, $tag = null, $css_class = null,
|
|
|
236 |
|
237 |
// Don't do anything if no_post_titles is specified.
|
238 |
if ('yes' === $this->params['no_post_titles']) {
|
@@ -244,7 +260,13 @@ class CatListDisplayer {
|
|
244 |
$css_class = $this->params['title_class'] ?: $css_class;
|
245 |
$suffix = $this->params['post_suffix'] ? ' ' . $this->params['post_suffix'] : '';
|
246 |
|
247 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
$link = false;
|
249 |
}
|
250 |
|
120 |
return $this->content_getter('excerpt', $single, $tag, $css_class);
|
121 |
}
|
122 |
|
123 |
+
public function get_posts_tags($single, $tag = null, $css_class = null){
|
124 |
+
return $this->content_getter('posts_tags', $single, $tag, $css_class);
|
125 |
+
}
|
126 |
+
|
127 |
+
public function get_posts_cats($single, $tag = null, $css_class = null){
|
128 |
+
return $this->content_getter('posts_cats', $single, $tag, $css_class);
|
129 |
+
}
|
130 |
+
|
131 |
private function get_modified_date($single, $tag = null, $css_class = null){
|
132 |
return $info = $this->content_getter('date_modified', $single, $tag, $css_class);
|
133 |
}
|
213 |
// Default wrapper behavior not supported here,
|
214 |
// class is only used inside the <a> element.
|
215 |
$css_class = null;
|
216 |
+
break;
|
217 |
+
case 'posts_tags':
|
218 |
+
$info = $this->catlist->get_posts_terms($post, 'tag');
|
219 |
+
break;
|
220 |
+
case 'posts_cats':
|
221 |
+
$info = $this->catlist->get_posts_terms($post, 'cat');
|
222 |
+
break;
|
223 |
}
|
224 |
return $this->wrapper->wrap($info, $tag, $css_class);
|
225 |
}
|
247 |
|
248 |
// Link is a parameter here in case you want to use it on a template
|
249 |
// and not show the links for all the shortcodes using this template:
|
250 |
+
public function get_post_title($single, $tag = null, $css_class = null,
|
251 |
+
$link = true, $link_current = true) {
|
252 |
|
253 |
// Don't do anything if no_post_titles is specified.
|
254 |
if ('yes' === $this->params['no_post_titles']) {
|
260 |
$css_class = $this->params['title_class'] ?: $css_class;
|
261 |
$suffix = $this->params['post_suffix'] ? ' ' . $this->params['post_suffix'] : '';
|
262 |
|
263 |
+
if ('no' === $this->params['link_current']) {
|
264 |
+
$link_current = false;
|
265 |
+
}
|
266 |
+
|
267 |
+
if (in_array($this->params['link_titles'], ['false', 'no'], true)
|
268 |
+
|| ((is_object( $this->parent) && is_object($single) && $this->parent->ID === $single->ID)
|
269 |
+
&& !$link_current)) {
|
270 |
$link = false;
|
271 |
}
|
272 |
|
include/lcp-parameters.php
CHANGED
@@ -97,6 +97,16 @@ class LcpParameters{
|
|
97 |
// AND relationship
|
98 |
$args['tag__and'] = $tags;
|
99 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
}
|
102 |
|
97 |
// AND relationship
|
98 |
$args['tag__and'] = $tags;
|
99 |
}
|
100 |
+
} else {
|
101 |
+
/*
|
102 |
+
Display nothing when a post has no tags.
|
103 |
+
Note that this will not prevent sticky posts
|
104 |
+
from being shown if they match other query parameters,
|
105 |
+
e.g. when no category is specified or a sticky post's
|
106 |
+
category matches the one given in `id` or `name`.
|
107 |
+
#80
|
108 |
+
*/
|
109 |
+
$args['post__in'] = [0];
|
110 |
}
|
111 |
}
|
112 |
|
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.
|
7 |
Author: Fernando Briano
|
8 |
Author URI: http://fernandobriano.com
|
9 |
|
@@ -78,6 +78,20 @@ class ListCategoryPosts{
|
|
78 |
'catlink_string' => '',
|
79 |
'catlink_tag' =>'',
|
80 |
'catlink_class' => '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
'child_categories' => 'yes',
|
82 |
'comments' => 'no',
|
83 |
'comments_tag' => '',
|
@@ -138,6 +152,7 @@ class ListCategoryPosts{
|
|
138 |
'instance' => '0',
|
139 |
'no_post_titles' => 'no',
|
140 |
'link_titles' => true,
|
|
|
141 |
'link_dates' => 'no',
|
142 |
'after' => '',
|
143 |
'after_year' => '',
|
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.86
|
7 |
Author: Fernando Briano
|
8 |
Author URI: http://fernandobriano.com
|
9 |
|
78 |
'catlink_string' => '',
|
79 |
'catlink_tag' =>'',
|
80 |
'catlink_class' => '',
|
81 |
+
'posts_tags' => '',
|
82 |
+
'posts_tags_tag' => '',
|
83 |
+
'posts_tags_class' => '',
|
84 |
+
'posts_tags_prefix' => ' ',
|
85 |
+
'posts_tags_glue' => ', ',
|
86 |
+
'posts_tags_inner' => '',
|
87 |
+
'posts_taglink' => 'no',
|
88 |
+
'posts_cats' => '',
|
89 |
+
'posts_cats_tag' => '',
|
90 |
+
'posts_cats_class' => '',
|
91 |
+
'posts_cats_prefix' => ' ',
|
92 |
+
'posts_cats_glue' => ', ',
|
93 |
+
'posts_cats_inner' => '',
|
94 |
+
'posts_catlink' => '',
|
95 |
'child_categories' => 'yes',
|
96 |
'comments' => 'no',
|
97 |
'comments_tag' => '',
|
152 |
'instance' => '0',
|
153 |
'no_post_titles' => 'no',
|
154 |
'link_titles' => true,
|
155 |
+
'link_current' => '',
|
156 |
'link_dates' => 'no',
|
157 |
'after' => '',
|
158 |
'after_year' => '',
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: list, categories, posts, cms
|
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.8
|
7 |
Requires PHP: 5.4
|
8 |
-
Stable tag: 0.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -237,6 +237,13 @@ Template system has changed. Custom templates should be stored in WordPress them
|
|
237 |
|
238 |
== Changelog ==
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
= 0.85.1 =
|
241 |
|
242 |
* Attempted fix of a compatibility issue with some versions of PHP 7.4
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.8
|
7 |
Requires PHP: 5.4
|
8 |
+
Stable tag: 0.86
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
237 |
|
238 |
== Changelog ==
|
239 |
|
240 |
+
= 0.86 =
|
241 |
+
|
242 |
+
* **New feature**: use `link_current=no` to prevent the current post from being wrapped in a link.
|
243 |
+
* **New feature**: display categories and tags of each post with `posts_cats` and `posts_tags`, a bunch of new parameters have been added to customise this feature, see [the docs](https://github.com/picandocodigo/List-Category-Posts/wiki/More-parameters-you-can-use).
|
244 |
+
* Fixed an issue with `currenttags`, when navigating to a post with no tags, no posts are displayed, same as with `categorypage`.
|
245 |
+
* Updated the testing environment and CI scripts.
|
246 |
+
|
247 |
= 0.85.1 =
|
248 |
|
249 |
* Attempted fix of a compatibility issue with some versions of PHP 7.4
|
templates/default.php
CHANGED
@@ -76,6 +76,12 @@ while ( $this->lcp_query->have_posts() ):
|
|
76 |
//Show the title and link to the post:
|
77 |
$lcp_display_output .= $this->get_post_title($post);
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
//Show comments:
|
80 |
$lcp_display_output .= $this->get_comments($post);
|
81 |
|
76 |
//Show the title and link to the post:
|
77 |
$lcp_display_output .= $this->get_post_title($post);
|
78 |
|
79 |
+
// Show categories
|
80 |
+
$lcp_display_output .= $this->get_posts_cats($post);
|
81 |
+
|
82 |
+
// Show tags
|
83 |
+
$lcp_display_output .= $this->get_posts_tags($post);
|
84 |
+
|
85 |
//Show comments:
|
86 |
$lcp_display_output .= $this->get_comments($post);
|
87 |
|