From a11e02e8bcd009cb8fd49f0cce0df16b7878eb15 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 7 Jan 2019 07:12:05 -0600 Subject: [PATCH] add has_password parameter --- CHANGELOG.md | 1 + display-posts-shortcode.php | 6 ++++++ readme.txt | 1 + 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0c1c6..6cd5e95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file, formatted v ### [3.0.0] #### Added * Added author_id parameter, see #195 +* Added has_password parameter * Added s parameter for performing a site search, see #184 * Added date_format="relative" format option (ex: 2 days ago), see #194 * Added post_parent__in and post_parent__not_in parameters, see #193 diff --git a/display-posts-shortcode.php b/display-posts-shortcode.php index 545715e..370a3d2 100644 --- a/display-posts-shortcode.php +++ b/display-posts-shortcode.php @@ -58,6 +58,7 @@ function be_display_posts_shortcode( $atts ) { 'excerpt_more_link' => false, 'exclude' => false, 'exclude_current' => false, + 'has_password' => null, 'id' => false, 'ignore_sticky_posts' => false, 'image_size' => false, @@ -118,6 +119,7 @@ function be_display_posts_shortcode( $atts ) { $excerpt_more_link = filter_var( $atts['excerpt_more_link'], FILTER_VALIDATE_BOOLEAN ); $exclude = $atts['exclude']; // Sanitized later as an array of integers $exclude_current = filter_var( $atts['exclude_current'], FILTER_VALIDATE_BOOLEAN ); + $has_password = null !== $atts['has_password'] ? filter_var( $atts['has_password'], FILTER_VALIDATE_BOOLEAN ) : null; $id = $atts['id']; // Sanitized later as an array of integers $ignore_sticky_posts = filter_var( $atts['ignore_sticky_posts'], FILTER_VALIDATE_BOOLEAN ); $image_size = sanitize_key( $atts['image_size'] ); @@ -255,6 +257,10 @@ function be_display_posts_shortcode( $atts ) { if( $ignore_sticky_posts ) $args['ignore_sticky_posts'] = true; + // Password protected content + if( null !== $has_password ) + $args['has_password'] = $has_password; + // Meta key (for ordering) if( !empty( $meta_key ) ) $args['meta_key'] = $meta_key; diff --git a/readme.txt b/readme.txt index 78a3dcb..924e51c 100644 --- a/readme.txt +++ b/readme.txt @@ -68,6 +68,7 @@ Here are [tutorials for popular event calendar plugins](https://displayposts.com **Version 3.0.0** * Added author_id parameter, see [#195](https://github.com/billerickson/display-posts-shortcode/issues/195) +* Added has_password parameter * Added s parameter for performing a site search, see [#184](https://github.com/billerickson/display-posts-shortcode/issues/184) * Added date_format="relative" format option (ex: 2 days ago), see [#194](https://github.com/billerickson/display-posts-shortcode/issues/194) * Added post_parent__in and post_parent__not_in parameters, see [#193](https://github.com/billerickson/display-posts-shortcode/issues/193)