Make WordPress Core

Changeset 34881


Ignore:
Timestamp:
10/06/2015 09:53:20 PM (9 years ago)
Author:
obenland
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r34843 r34881  
    452452    }
    453453
    454     // Post requires password
    455     if ( post_password_required( $post->ID ) ) {
     454    $post_password_required = post_password_required( $post->ID );
     455
     456    // Post requires password.
     457    if ( $post_password_required ) {
    456458        $classes[] = 'post-password-required';
    457     // Post thumbnails
    458     } elseif ( ! is_attachment( $post ) && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
     459    } elseif ( ! empty( $post->post_password ) ) {
     460        $classes[] = 'post-password-protected';
     461    }
     462
     463    // Post thumbnails.
     464    if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) {
    459465        $classes[] = 'has-post-thumbnail';
    460466    }
Note: See TracChangeset for help on using the changeset viewer.