Version Description
Download this release
Release Info
Developer | billerickson |
Plugin | Display Posts Shortcode |
Version | 2.6.0 |
Comparing to | |
See all releases |
Code changes from version 2.5.1 to 2.6.0
- display-posts-shortcode.php +21 -8
- readme.txt +9 -2
display-posts-shortcode.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Display Posts Shortcode
|
4 |
* Plugin URI: http://www.billerickson.net/shortcode-to-display-posts/
|
5 |
* Description: Display a listing of posts using the [display-posts] shortcode
|
6 |
-
* Version: 2.
|
7 |
* Author: Bill Erickson
|
8 |
* Author URI: http://www.billerickson.net
|
9 |
*
|
@@ -15,7 +15,7 @@
|
|
15 |
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
16 |
*
|
17 |
* @package Display Posts
|
18 |
-
* @version 2.
|
19 |
* @author Bill Erickson <bill@billerickson.net>
|
20 |
* @copyright Copyright (c) 2011, Bill Erickson
|
21 |
* @link http://www.billerickson.net/shortcode-to-display-posts/
|
@@ -66,6 +66,8 @@ function be_display_posts_shortcode( $atts ) {
|
|
66 |
'date_query_column' => '',
|
67 |
'date_query_compare' => '',
|
68 |
'display_posts_off' => false,
|
|
|
|
|
69 |
'exclude_current' => false,
|
70 |
'id' => false,
|
71 |
'ignore_sticky_posts' => false,
|
@@ -112,6 +114,8 @@ function be_display_posts_shortcode( $atts ) {
|
|
112 |
$date_query_after = sanitize_text_field( $atts['date_query_after'] );
|
113 |
$date_query_column = sanitize_text_field( $atts['date_query_column'] );
|
114 |
$date_query_compare = sanitize_text_field( $atts['date_query_compare'] );
|
|
|
|
|
115 |
$exclude_current = filter_var( $atts['exclude_current'], FILTER_VALIDATE_BOOLEAN );
|
116 |
$id = $atts['id']; // Sanitized later as an array of integers
|
117 |
$ignore_sticky_posts = filter_var( $atts['ignore_sticky_posts'], FILTER_VALIDATE_BOOLEAN );
|
@@ -137,10 +141,10 @@ function be_display_posts_shortcode( $atts ) {
|
|
137 |
$taxonomy = sanitize_key( $atts['taxonomy'] );
|
138 |
$time = sanitize_text_field( $atts['time'] );
|
139 |
$wrapper = sanitize_text_field( $atts['wrapper'] );
|
140 |
-
$wrapper_class = sanitize_html_class( $atts['wrapper_class'] );
|
141 |
|
142 |
if( !empty( $wrapper_class ) )
|
143 |
-
$wrapper_class = ' class="' . $wrapper_class . '"';
|
144 |
$wrapper_id = sanitize_html_class( $atts['wrapper_id'] );
|
145 |
if( !empty( $wrapper_id ) )
|
146 |
$wrapper_id = ' id="' . $wrapper_id . '"';
|
@@ -258,8 +262,14 @@ function be_display_posts_shortcode( $atts ) {
|
|
258 |
$args['post__not_in'] = array( get_the_ID() );
|
259 |
|
260 |
// Post Author
|
261 |
-
if( !empty( $author ) )
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
// Offset
|
265 |
if( !empty( $offset ) )
|
@@ -404,8 +414,11 @@ function be_display_posts_shortcode( $atts ) {
|
|
404 |
*/
|
405 |
$author = apply_filters( 'display_posts_shortcode_author', ' <span class="author">by ' . get_the_author() . '</span>' );
|
406 |
|
407 |
-
if ( $include_excerpt )
|
408 |
-
$
|
|
|
|
|
|
|
409 |
|
410 |
if( $include_content ) {
|
411 |
add_filter( 'shortcode_atts_display-posts', 'be_display_posts_off', 10, 3 );
|
3 |
* Plugin Name: Display Posts Shortcode
|
4 |
* Plugin URI: http://www.billerickson.net/shortcode-to-display-posts/
|
5 |
* Description: Display a listing of posts using the [display-posts] shortcode
|
6 |
+
* Version: 2.6.0
|
7 |
* Author: Bill Erickson
|
8 |
* Author URI: http://www.billerickson.net
|
9 |
*
|
15 |
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
16 |
*
|
17 |
* @package Display Posts
|
18 |
+
* @version 2.6
|
19 |
* @author Bill Erickson <bill@billerickson.net>
|
20 |
* @copyright Copyright (c) 2011, Bill Erickson
|
21 |
* @link http://www.billerickson.net/shortcode-to-display-posts/
|
66 |
'date_query_column' => '',
|
67 |
'date_query_compare' => '',
|
68 |
'display_posts_off' => false,
|
69 |
+
'excerpt_length' => false,
|
70 |
+
'excerpt_more' => false,
|
71 |
'exclude_current' => false,
|
72 |
'id' => false,
|
73 |
'ignore_sticky_posts' => false,
|
114 |
$date_query_after = sanitize_text_field( $atts['date_query_after'] );
|
115 |
$date_query_column = sanitize_text_field( $atts['date_query_column'] );
|
116 |
$date_query_compare = sanitize_text_field( $atts['date_query_compare'] );
|
117 |
+
$excerpt_length = intval( $atts['excerpt_length'] );
|
118 |
+
$excerpt_more = sanitize_text_field( $atts['excerpt_more'] );
|
119 |
$exclude_current = filter_var( $atts['exclude_current'], FILTER_VALIDATE_BOOLEAN );
|
120 |
$id = $atts['id']; // Sanitized later as an array of integers
|
121 |
$ignore_sticky_posts = filter_var( $atts['ignore_sticky_posts'], FILTER_VALIDATE_BOOLEAN );
|
141 |
$taxonomy = sanitize_key( $atts['taxonomy'] );
|
142 |
$time = sanitize_text_field( $atts['time'] );
|
143 |
$wrapper = sanitize_text_field( $atts['wrapper'] );
|
144 |
+
$wrapper_class = array_map( 'sanitize_html_class', ( explode( ' ', $atts['wrapper_class'] ) ) );
|
145 |
|
146 |
if( !empty( $wrapper_class ) )
|
147 |
+
$wrapper_class = ' class="' . implode( ' ', $wrapper_class ) . '"';
|
148 |
$wrapper_id = sanitize_html_class( $atts['wrapper_id'] );
|
149 |
if( !empty( $wrapper_id ) )
|
150 |
$wrapper_id = ' id="' . $wrapper_id . '"';
|
262 |
$args['post__not_in'] = array( get_the_ID() );
|
263 |
|
264 |
// Post Author
|
265 |
+
if( !empty( $author ) ) {
|
266 |
+
if( 'current' == $author && is_user_logged_in() )
|
267 |
+
$args['author_name'] = wp_get_current_user()->user_login;
|
268 |
+
elseif( 'current' == $author )
|
269 |
+
$args['meta_key'] = 'dps_no_results';
|
270 |
+
else
|
271 |
+
$args['author_name'] = $author;
|
272 |
+
}
|
273 |
|
274 |
// Offset
|
275 |
if( !empty( $offset ) )
|
414 |
*/
|
415 |
$author = apply_filters( 'display_posts_shortcode_author', ' <span class="author">by ' . get_the_author() . '</span>' );
|
416 |
|
417 |
+
if ( $include_excerpt ) {
|
418 |
+
$excerpt_length = $excerpt_length ? $excerpt_length : apply_filters( 'excerpt_length', 55 );
|
419 |
+
$excerpt_more = $excerpt_more ? $excerpt_more : apply_filters( 'excerpt_more', ' ' . '[…]' );
|
420 |
+
$excerpt = ' <span class="excerpt-dash">-</span> <span class="excerpt">' . wp_trim_words( strip_shortcodes( get_the_content('') ), $excerpt_length, $excerpt_more ) . '</span>';
|
421 |
+
}
|
422 |
|
423 |
if( $include_content ) {
|
424 |
add_filter( 'shortcode_atts_display-posts', 'be_display_posts_off', 10, 3 );
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: billerickson
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MQKRBRFVRUV8C
|
4 |
Tags: shortcode, pages, posts, page, query, display, list
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
Display a listing of posts using the [display-posts] shortcode
|
10 |
|
@@ -29,6 +29,13 @@ See the [WordPress Codex](http://codex.wordpress.org/Class_Reference/WP_Query) f
|
|
29 |
|
30 |
== Changelog ==
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
**Version 2.5.1**
|
33 |
|
34 |
* Fix an issue with manually specified excerpts
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MQKRBRFVRUV8C
|
4 |
Tags: shortcode, pages, posts, page, query, display, list
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.5.2
|
7 |
+
Stable tag: 2.6.0
|
8 |
|
9 |
Display a listing of posts using the [display-posts] shortcode
|
10 |
|
29 |
|
30 |
== Changelog ==
|
31 |
|
32 |
+
**Version 2.6**
|
33 |
+
|
34 |
+
* Add support for author="current"
|
35 |
+
* Add support for multiple wrapper classes
|
36 |
+
* Add support for excerpt_length parameter
|
37 |
+
* Add support for excerpt_more parameter
|
38 |
+
|
39 |
**Version 2.5.1**
|
40 |
|
41 |
* Fix an issue with manually specified excerpts
|