WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months 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 Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 2.5
Component: Taxonomy Keywords: has-patch
Focuses: Cc:
PR Number:

Description

Hello,

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.

<?php
/**
 * 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.

Thanks

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

@garrett-eclipse
3 months ago

Updated phpdocblock to replace HTML Link verbiage with URL

#1 @garrett-eclipse
3 months 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
3 months ago

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

#3 @SergeyBiryukov
3 months 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.