Make WordPress Core

Changeset 52255

Timestamp:
11/26/2021 11:41:24 AM (3 years ago)
Author:
audrasjb
Message:

Taxonomy: Use WP_Term object to retrieve the taxonomy in get_term_feed_link().

This change fixes a backward compatibility issue introduced in [52180] where get_term_feed_link() did not honor the $taxonomy parameter anymore. Rather than using the default category taxonomy when passing a term ID in get_term_feed_link(), use the WP_Term object to get the taxonomy.

Follow-up to [52180].

Props hugod.
Fixes #50225.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r52215 r52255  
    931931function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) {
    932932    if ( ! is_object( $term ) ) {
    933         $term     = (int) $term;
    934         $taxonomy = 'category';
    935     } elseif ( ! $term instanceof WP_Term ) {
    936         $taxonomy = $term->taxonomy;
     933        $term = (int) $term;
    937934    }
    938935
    939936    $term = get_term( $term, $taxonomy );
     937
     938
    940939
    941940    if ( empty( $term ) || is_wp_error( $term ) ) {
  • trunk/tests/phpunit/tests/term/getTermLink.php

    r52180 r52255  
    267267
    268268    /**
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
    269291     * Data provider.
    270292     *
Note: See TracChangeset for help on using the changeset viewer.