From cb4554b3df5057311a4b0e10027d7c4e09105c1a Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Tue, 6 Oct 2015 21:53:20 +0000 Subject: [PATCH] Posts: Add post class for password protected posts. Up until now password protected posts would only get a identifying class when the password was still required. This adds a class for the case when that requirement has been met. For the other visibility types we already have `status-publish` and `status-private`. Props mdgl, F4rkie, wonderboymusic for initial patches. Fixes #21899. git-svn-id: https://develop.svn.wordpress.org/trunk@34881 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post-template.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index dbfddb7ffe..1c98e49ede 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -451,11 +451,17 @@ function get_post_class( $class = '', $post_id = null ) { $classes[] = 'format-standard'; } - // Post requires password - if ( post_password_required( $post->ID ) ) { + $post_password_required = post_password_required( $post->ID ); + + // Post requires password. + if ( $post_password_required ) { $classes[] = 'post-password-required'; - // Post thumbnails - } elseif ( ! is_attachment( $post ) && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) { + } elseif ( ! empty( $post->post_password ) ) { + $classes[] = 'post-password-protected'; + } + + // Post thumbnails. + if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) { $classes[] = 'has-post-thumbnail'; }