Make WordPress Core

Opened 15 years ago

Closed 13 years ago

Last modified 13 years ago

#17320 closed enhancement (fixed)

has_post_format() should accept an array

Reported by: janfabry Owned by: nacin
Priority: normal Milestone: 3.6
Component: Taxonomy Version: 3.2
Severity: normal Keywords: has-patch commit
Cc: Focuses:

Description

has_category(), has_tag(), and has_term() accept an array as the first argument and return true if the post has any of the given terms. has_post_format() also uses has_term() in the background, but it calls sanitize_key() and adds 'post-format-' to the passed format, which will fail when you pass an array.

For consistency, it would be better if has_post_format() would also accept an array.

Attachments (3)

17320.diff (1.1 KB ) - added by elky 15 years ago.
Catch arrays, check for non-string values, add prefix & send to has_term()
17320.1.diff (1.0 KB ) - added by ericmann 13 years ago.
Refreshed patch
17320.2.diff (1.2 KB ) - added by obenland 13 years ago.

Download all attachments as: .zip

Change History (14)

@elky
15 years ago

Catch arrays, check for non-string values, add prefix & send to has_term()

#1 @elky
15 years ago

  • Keywords has-patch added

#2 @F J Kaiser
14 years ago

  • Component GeneralTaxonomy
  • Keywords dev-feedback added

#3 @toscho
14 years ago

  • Cc info@… added

#4 @DrewAPicture
14 years ago

  • Cc xoodrew@… added

@ericmann
13 years ago

Refreshed patch

#5 @ericmann
13 years ago

Refreshed the patch to match recent updates to Core and updated to remove unnecessary unset()s.

In addition, the code will now just sanitize and prefix the array (or single string) and pass the array directly to has_term() (which already accepted arrays to begin with.

#6 @aaronholbrook
13 years ago

  • Keywords commit added; dev-feedback removed

Looks good, tested

#7 @nacin
13 years ago

  • Owner set to nacin
  • Resolutionfixed
  • Status newclosed

In 24817:

Allow has_post_format() to accept an array of formats to check. props ericmann. fixes #17320.

#8 @DrewAPicture
13 years ago

  • Keywords needs-codex added

#9 @aaronholbrook
13 years ago

  • Keywords needs-codex removed

Updated codex

@obenland
13 years ago

#10 @nacin
13 years ago

  • Milestone Awaiting Review3.6

At the request of Twenty Thirteen, see #24905.

#11 @nacin
13 years ago

In 24933:

Allow has_post_format() to accept an array of formats to check. props ericmann. fixes #17320.

Merges [24817] to the 3.6 branch.

Note: See TracTickets for help on using tickets.