Display Posts Shortcode - Version 2.0

Version Description

Download this release

Release Info

Developer billerickson
Plugin Icon 128x128 Display Posts Shortcode
Version 2.0
Comparing to
See all releases

Code changes from version 1.9 to 2.0

Files changed (2) hide show
  1. display-posts-shortcode.php +23 -5
  2. readme.txt +7 -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: 1.9
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 1.8
19
  * @author Bill Erickson <bill@billerickson.net>
20
  * @copyright Copyright (c) 2011, Bill Erickson
21
  * @link http://www.billerickson.net/shortcode-to-display-posts/
@@ -45,7 +45,7 @@ add_shortcode( 'display-posts', 'be_display_posts_shortcode' );
45
  function be_display_posts_shortcode( $atts ) {
46
 
47
  // Pull in shortcode attributes and set defaults
48
- extract( shortcode_atts( array(
49
  'category' => '',
50
  'date_format' => '(n/j/Y)',
51
  'id' => false,
@@ -62,7 +62,25 @@ function be_display_posts_shortcode( $atts ) {
62
  'tax_term' => false,
63
  'taxonomy' => false,
64
  'wrapper' => 'ul',
65
- ), $atts ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  // Set up initial query for post
68
  $args = array(
@@ -76,7 +94,7 @@ function be_display_posts_shortcode( $atts ) {
76
 
77
  // If Post IDs
78
  if( $id ) {
79
- $posts_in = explode( ',', $id );
80
  $args['post__in'] = $posts_in;
81
  }
82
 
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.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.0
19
  * @author Bill Erickson <bill@billerickson.net>
20
  * @copyright Copyright (c) 2011, Bill Erickson
21
  * @link http://www.billerickson.net/shortcode-to-display-posts/
45
  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,
62
  'tax_term' => false,
63
  'taxonomy' => false,
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 = intval( $atts['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'] );
79
+ $tax_operator = $atts['tax_operator']; // Validated later as one of a few values
80
+ $tax_term = sanitize_text_field( $atts['tax_term'] );
81
+ $taxonomy = sanitize_key( $atts['taxonomy'] );
82
+ $wrapper = sanitize_text_field( $atts['wrapper'] );
83
+
84
 
85
  // Set up initial query for post
86
  $args = array(
94
 
95
  // If Post IDs
96
  if( $id ) {
97
+ $posts_in = array_map( 'intval', explode( ',', $id ) );
98
  $args['post__in'] = $posts_in;
99
  }
100
 
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: 3.4.1
7
- Stable tag: 1.9
8
 
9
  Display a listing of posts using the [display-posts] shortcode
10
 
@@ -27,6 +27,11 @@ See the [WordPress Codex](http://codex.wordpress.org/Class_Reference/WP_Query) f
27
 
28
  == Changelog ==
29
 
 
 
 
 
 
30
  **Version 1.9**
31
 
32
  * Add 'date_format' parameter, so you can customize how dates are displayed
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: 3.4.2
7
+ Stable tag: 2.0
8
 
9
  Display a listing of posts using the [display-posts] shortcode
10
 
27
 
28
  == Changelog ==
29
 
30
+ **Version 2.0**
31
+
32
+ * Explicitly declare arguments, props danielbachhuber
33
+ * Sanitize each shortcode attribute for security, props danielbachhuber
34
+
35
  **Version 1.9**
36
 
37
  * Add 'date_format' parameter, so you can customize how dates are displayed