WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 2 months ago

#21899 new enhancement

Missing class identifier for password protected posts

Reported by: mdgl Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.4.2
Component: Posts, Post Types Keywords:
Focuses: template Cc:

Description

Password protected posts are insufficiently identified for good CSS styling.

Presently, the class name "post-password-required" is added to protected posts if a valid password cannot be found in the cookie. On the other hand, no special class name is added to protected posts if a valid password *can* be found, even though this is just a temporary condition until the cookie expires.

I suggest that both cases are interesting from a CSS styling perspective. Note that the title of protected posts is prefixed by the string "Protected:" in both situations.

This behaviour occurs because get_post_class() just checks post_password_required() [which validates the cookie] but get_the_title() just checks if the $post->post_password field is not empty.

I suggest an additional class name should be added by get_post_class() for the case when the post->post_password field is not empty. Current usage of class names here is not very consistent with the admin tool, so options might be "visibility-protected", "status-protected" [similar to "status-private" which is added for those with visibility "Private" and reflecting the underlying implementation] or perhaps just simply "protected".

Protected posts would thus be identified as follows:

Protected, with correct password: class="protected"
Protected, missing or invalid password: class="protected post-password-required"

See also #13860 and #18729. I can do a patch if needed but this is literally just a couple of lines of code (three if you include a comment).

Attachments (1)

21899.diff (353 bytes) - added by mdgl 19 months ago.
Suggested patch using class name "protected" (this is against 3.4.2 not trunk - sorry!)

Download all attachments as: .zip

Change History (2)

mdgl19 months ago

Suggested patch using class name "protected" (this is against 3.4.2 not trunk - sorry!)

comment:1 nacin2 months ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added
Note: See TracTickets for help on using tickets.