Make WordPress Core

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#17320 closed enhancement (fixed)

has_post_format() should accept an array

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

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 12 years ago.
Catch arrays, check for non-string values, add prefix & send to has_term()
17320.1.diff (1.0 KB) - added by ericmann 10 years ago.
Refreshed patch
17320.2.diff (1.2 KB) - added by obenland 10 years ago.

Download all attachments as: .zip

Change History (14)

@elky
12 years ago

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

#1 @elky
12 years ago

  • Keywords has-patch added

#2 @F J Kaiser
11 years ago

  • Component changed from General to Taxonomy
  • Keywords dev-feedback added

#3 @toscho
10 years ago

  • Cc info@… added

#4 @DrewAPicture
10 years ago

  • Cc xoodrew@… added

@ericmann
10 years ago

Refreshed patch

#5 @ericmann
10 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
10 years ago

  • Keywords commit added; dev-feedback removed

Looks good, tested

#7 @nacin
10 years ago

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

In 24817:

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

#8 @DrewAPicture
10 years ago

  • Keywords needs-codex added

#9 @aaronholbrook
10 years ago

  • Keywords needs-codex removed

Updated codex

@obenland
10 years ago

#10 @nacin
10 years ago

  • Milestone changed from Awaiting Review to 3.6

At the request of Twenty Thirteen, see #24905.

#11 @nacin
10 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.