Version Description
Download this release
Release Info
Developer | billerickson |
Plugin | Display Posts Shortcode |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0 to 2.1
- display-posts-shortcode.php +28 -4
- readme.txt +7 -1
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/
|
@@ -46,15 +46,18 @@ function be_display_posts_shortcode( $atts ) {
|
|
46 |
|
47 |
// Pull in shortcode attributes and set defaults
|
48 |
$atts = shortcode_atts( array(
|
|
|
49 |
'category' => '',
|
50 |
'date_format' => '(n/j/Y)',
|
51 |
'id' => false,
|
52 |
'image_size' => false,
|
53 |
'include_date' => false,
|
54 |
'include_excerpt' => false,
|
|
|
55 |
'order' => 'DESC',
|
56 |
'orderby' => 'date',
|
57 |
'post_parent' => false,
|
|
|
58 |
'post_type' => 'post',
|
59 |
'posts_per_page' => '10',
|
60 |
'tag' => '',
|
@@ -64,15 +67,18 @@ function be_display_posts_shortcode( $atts ) {
|
|
64 |
'wrapper' => 'ul',
|
65 |
), $atts );
|
66 |
|
|
|
67 |
$category = sanitize_text_field( $atts['category'] );
|
68 |
$date_format = sanitize_text_field( $atts['date_format'] );
|
69 |
$id = $atts['id']; // Sanitized later as an array of integers
|
70 |
$image_size = sanitize_key( $atts['image_size'] );
|
71 |
$include_date = (bool)$atts['include_date'];
|
72 |
$include_excerpt = (bool)$atts['include_excerpt'];
|
|
|
73 |
$order = sanitize_key( $atts['order'] );
|
74 |
$orderby = sanitize_key( $atts['orderby'] );
|
75 |
-
$post_parent =
|
|
|
76 |
$post_type = sanitize_text_field( $atts['post_type'] );
|
77 |
$posts_per_page = intval( $atts['posts_per_page'] );
|
78 |
$tag = sanitize_text_field( $atts['tag'] );
|
@@ -98,6 +104,24 @@ function be_display_posts_shortcode( $atts ) {
|
|
98 |
$args['post__in'] = $posts_in;
|
99 |
}
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
// If taxonomy attributes, create a taxonomy query
|
103 |
if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
|
@@ -128,7 +152,7 @@ function be_display_posts_shortcode( $atts ) {
|
|
128 |
global $post;
|
129 |
$post_parent = $post->ID;
|
130 |
}
|
131 |
-
$args['post_parent'] = $post_parent;
|
132 |
}
|
133 |
|
134 |
// Set up html elements used to wrap the posts.
|
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.1
|
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.1
|
19 |
* @author Bill Erickson <bill@billerickson.net>
|
20 |
* @copyright Copyright (c) 2011, Bill Erickson
|
21 |
* @link http://www.billerickson.net/shortcode-to-display-posts/
|
46 |
|
47 |
// Pull in shortcode attributes and set defaults
|
48 |
$atts = shortcode_atts( array(
|
49 |
+
'author' => '',
|
50 |
'category' => '',
|
51 |
'date_format' => '(n/j/Y)',
|
52 |
'id' => false,
|
53 |
'image_size' => false,
|
54 |
'include_date' => false,
|
55 |
'include_excerpt' => false,
|
56 |
+
'offset' => 0,
|
57 |
'order' => 'DESC',
|
58 |
'orderby' => 'date',
|
59 |
'post_parent' => false,
|
60 |
+
'post_status' => 'publish',
|
61 |
'post_type' => 'post',
|
62 |
'posts_per_page' => '10',
|
63 |
'tag' => '',
|
67 |
'wrapper' => 'ul',
|
68 |
), $atts );
|
69 |
|
70 |
+
$author = sanitize_text_field( $atts['author'] );
|
71 |
$category = sanitize_text_field( $atts['category'] );
|
72 |
$date_format = sanitize_text_field( $atts['date_format'] );
|
73 |
$id = $atts['id']; // Sanitized later as an array of integers
|
74 |
$image_size = sanitize_key( $atts['image_size'] );
|
75 |
$include_date = (bool)$atts['include_date'];
|
76 |
$include_excerpt = (bool)$atts['include_excerpt'];
|
77 |
+
$offset = intval( $atts['offset'] );
|
78 |
$order = sanitize_key( $atts['order'] );
|
79 |
$orderby = sanitize_key( $atts['orderby'] );
|
80 |
+
$post_parent = $atts['post_parent']; // Validated later, after check for 'current'
|
81 |
+
$post_status = $atts['post_status']; // Validated later as one of a few values
|
82 |
$post_type = sanitize_text_field( $atts['post_type'] );
|
83 |
$posts_per_page = intval( $atts['posts_per_page'] );
|
84 |
$tag = sanitize_text_field( $atts['tag'] );
|
104 |
$args['post__in'] = $posts_in;
|
105 |
}
|
106 |
|
107 |
+
// Post Author
|
108 |
+
if( !empty( $author ) )
|
109 |
+
$args['author_name'] = $author;
|
110 |
+
|
111 |
+
// Offset
|
112 |
+
if( !empty( $offset ) )
|
113 |
+
$args['offset'] = $offset;
|
114 |
+
|
115 |
+
// Post Status
|
116 |
+
$post_status = explode( ', ', $post_status );
|
117 |
+
$validated = array();
|
118 |
+
$available = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash', 'any' );
|
119 |
+
foreach ( $post_status as $unvalidated )
|
120 |
+
if ( in_array( $unvalidated, $available ) )
|
121 |
+
$validated[] = $unvalidated;
|
122 |
+
if( !empty( $validated ) )
|
123 |
+
$args['post_status'] = $validated;
|
124 |
+
|
125 |
|
126 |
// If taxonomy attributes, create a taxonomy query
|
127 |
if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
|
152 |
global $post;
|
153 |
$post_parent = $post->ID;
|
154 |
}
|
155 |
+
$args['post_parent'] = intval( $post_parent );
|
156 |
}
|
157 |
|
158 |
// Set up html elements used to wrap the posts.
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: shortcode, pages, posts, page, query, display, list
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.4.2
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
Display a listing of posts using the [display-posts] shortcode
|
10 |
|
@@ -27,6 +27,12 @@ See the [WordPress Codex](http://codex.wordpress.org/Class_Reference/WP_Query) f
|
|
27 |
|
28 |
== Changelog ==
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
**Version 2.0**
|
31 |
|
32 |
* Explicitly declare arguments, props danielbachhuber
|
4 |
Tags: shortcode, pages, posts, page, query, display, list
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.4.2
|
7 |
+
Stable tag: 2.1
|
8 |
|
9 |
Display a listing of posts using the [display-posts] shortcode
|
10 |
|
27 |
|
28 |
== Changelog ==
|
29 |
|
30 |
+
**Veresion 2.1**
|
31 |
+
|
32 |
+
* Add support for post status
|
33 |
+
* Add support for post author
|
34 |
+
* Add support for post author
|
35 |
+
|
36 |
**Version 2.0**
|
37 |
|
38 |
* Explicitly declare arguments, props danielbachhuber
|