WordPress.org

Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 21 months ago

#35922 closed enhancement (fixed)

get_edit_term_link should not require $taxonomy

Reported by: nicdford Owned by: boonebgorges
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.4
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Both get_term() and get_term_link() no longer require $taxonomy to work anymore and get_edit_term_link() should follow suit. It would be best to utilize the $term->taxonomy if one isn’t set.

Special thanks to @sc0ttkclark for helping me with my first ticket! :)

Attachments (1)

enhancement.35922.diff (1.5 KB) - added by nicdford 22 months ago.

Download all attachments as: .zip

Change History (10)

#1 @welcher
22 months ago

Welcome and thanks for the patch!

#2 @sc0ttkclark
22 months ago

Patch incoming :)

#3 @boonebgorges
22 months ago

  • Milestone changed from Awaiting Review to 4.5
  • Owner set to boonebgorges
  • Status changed from new to assigned

Thanks! Let's sneak this in.

Side note: when generating your patches, please set your editor config to use tabs rather than spaces :)

#4 @nicdford
22 months ago

Will do! Thanks @boonebgorges

#5 @boonebgorges
22 months ago

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

In 36646:

Make $taxonomy parameter optional in get_edit_term_link().

Props nicdford, sc0ttkclark.
Fixes #35922.

#6 @johnbillion
22 months ago

  • Version set to 4.4

#7 @swissspidy
21 months ago

@boonebgorges While working on #36224 I noticed that test_cap_check_should_use_correct_taxonomy_when_taxonomy_is_not_specified is not 100% correct / incomplete.

First, manage_terms is not a direct taxonomy property, but can only be passed as part of the capabilities array.
Second, get_edit_term_link() checks against edit_terms capability, not manage_terms.
Third, the wptests_tax_subscriber taxonomy isn't even used in the test.

I'd add a new test to check that the custom capabilities get respected when using get_edit_term_link().

#8 @boonebgorges
21 months ago

Yikes, you are right. Not sure what I was thinking.

#9 @boonebgorges
21 months ago

In 36986:

Fix test related to cap check in get_edit_term_link().

The test was introduced in [36646] was intended to demonstrate that the cap
check in get_edit_term_link() uses the custom capability from the correct
taxonomy when $taxonomy is not specified but must be inferred from the
provided term. However, the test was wrongly written in pretty much every way.
Antiprops boonebgorges.

Props swissspidy.
See #35922.

Note: See TracTickets for help on using tickets.