Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#47806 closed defect (bug) (fixed)

The get_term_link returns a URL but it's @return and name lead you to believe it's returning an HTML link

Reported by: garrett-eclipse's profile garrett-eclipse Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 2.5
Component: Taxonomy Keywords: has-patch
Focuses: Cc:



I went to use the get_term_link function after reading the documentation and was confused by it returning a URL and not an HTML link as it was indicated. The function name also leads you to believe it'll be a link returned and not a URL.

 * Generate a permalink for a taxonomy term archive.
 * @since 2.5.0
 * @global WP_Rewrite $wp_rewrite
 * @param object|int|string $term     The term object, ID, or slug whose link will be retrieved.
 * @param string            $taxonomy Optional. Taxonomy. Default empty.
 * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist.
function get_term_link( $term, $taxonomy = '' ) {

I doubt renaming the function is viable due to back-compat but it would be nice at least to correct the php docblock to indicate the return is a URL and not an HTML Link.


Attachments (1)

47806.diff (692 bytes) - added by garrett-eclipse 4 years ago.
Updated phpdocblock to replace HTML Link verbiage with URL

Download all attachments as: .zip

Change History (4)

4 years ago

Updated phpdocblock to replace HTML Link verbiage with URL

#1 @garrett-eclipse
4 years ago

  • Keywords has-patch added

Added minor patch to tweak the verbiage and indicate it's a URL and not an HTML Link

#2 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @SergeyBiryukov
4 years ago

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

In 45702:

Docs: Correct @return value description for get_term_link().

Props garrett-eclipse.
Fixes #47806.

Note: See TracTickets for help on using tickets.