Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#34245 closed enhancement (fixed)

Make the $taxonomy parameter in get_term_field() optional

Reported by: drewapicture's profile DrewAPicture Owned by: boonebgorges's profile boonebgorges
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: Cc:

Description (last modified by DrewAPicture)

Following up on making the $taxonomy parameter in get_term() optional, we should also make it optional in get_term_field().

Patch attached with tests.

Attachments (4)

34245.diff (3.2 KB) - added by DrewAPicture 9 years ago.
34245.2.diff (3.7 KB) - added by DrewAPicture 9 years ago.
$term should accept an ID or an object
34245.3.diff (4.4 KB) - added by DrewAPicture 9 years ago.
34245.4.diff (4.3 KB) - added by DrewAPicture 9 years ago.

Download all attachments as: .zip

Change History (12)

#1 @DrewAPicture
9 years ago

  • Description modified (diff)

9 years ago

#2 @DrewAPicture
9 years ago

  • Milestone changed from Awaiting Review to 4.4

9 years ago

$term should accept an ID or an object

#3 @DrewAPicture
9 years ago

34245.2.diff also makes $term accept both a term ID and WP_Term object, and adds tests. (I really dig being able to use get_term_field() in "shorthand" without having to supply a taxonomy, btw).

#4 @DrewAPicture
9 years ago

  • Owner set to boonebgorges
  • Status changed from new to reviewing

@boonebgorges Might giving this a once over?

Obviously there's a lot of missing tests for get_term_field() just generally, but is there anything I didn't cover for this particular set of changes?

#5 @boonebgorges
9 years ago

DrewAPicture - This change looks mostly good. Two small suggestions:

  1. Since you're modifying the final line of the function anyway, may as well fix the spacing inside the parens :)
  2. I'd add a test to show what happens when the value of $taxonomy doesn't match the actual taxonomy of $term. This should be the same before and after the patch - an invalid_term WP_Error object - but the code path is a bit different, in a way that's relevant to the change you're making here.

9 years ago

#6 @DrewAPicture
9 years ago

@boonebgorges: Addressed your feedback in 34245.3.diff and added two tests, one each for the two WP_Error codes that might be returned via get_term().

9 years ago

#7 @boonebgorges
9 years ago

In 35028:

Don't require a $taxonomy to be specified in get_term_field().

After [34997], the $taxonomy parameter of get_term() is optional. This
changeset brings get_term_field() in line with the new usage.

Adds unit tests for get_term_field().

Props DrewAPicture.
See #34245.

#8 @boonebgorges
9 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 35029:

After [35028], normalize get_term_field() doc formatting.

Fixes #34245.

Note: See TracTickets for help on using tickets.