Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#24906 closed defect (bug) (fixed)

Post Formats: Allow to check for any post format

Reported by: obenland's profile obenland Owned by: duck_'s profile duck_
Milestone: 3.8 Priority: normal
Severity: normal Version: 3.8
Component: Post Formats Keywords: has-patch commit
Focuses: Cc:


It would be great if themes could check if any post format has been assigned to a post. This would make it especially easy to check if no post format has been assigned, something that is hard to do in has_post_format's current setup.

With the change in r24934 it is only a matter of making the passed format argument optional and checking for it.

Attachments (3)

24906.diff (1.2 KB) - added by obenland 11 years ago.
24906.2.diff (1.4 KB) - added by DrewAPicture 11 years ago.
24906.3.diff (1.4 KB) - added by nacin 11 years ago.

Download all attachments as: .zip

Change History (7)

11 years ago

#1 @DrewAPicture
11 years ago

+1 for this. @obenland: Looks like you missed marking $format (optional) in the docblock.

We need to update the short description anyway following [24934] since it can (currently) be one or many.

11 years ago

#2 @nacin
11 years ago

The use of ! empty( $single ) felt like a code smell — under what circumstances would an item in this array be empty? It seems like that could occur if someone passed false, null, etc., as $format, which would then get converted to array( 0 => false ).

24906.3.diff tries a different branching of the logic.

#3 @nacin
10 years ago

  • Keywords commit added
  • Milestone changed from 3.7 to 3.8

#4 @duck_
10 years ago

  • Owner set to duck_
  • Resolution set to fixed
  • Status changed from new to closed

In 26350:

Allow has_post_format() to be used to check for any format.

Calling has_post_format() with an empty list of $format will check if the
provided post has any associated format at all.

Props obenland, DrewAPicture, nacin. Fixes #24906.

Note: See TracTickets for help on using tickets.