Make WordPress Core


Ignore:
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTermLink.php

    r52180 r52255  
    267267
    268268    /**
     269     * @dataProvider data_get_term_link
     270     *
     271     * @ticket 50225
     272     *
     273     * @param string $taxonomy Taxonomy been tested (used for index of term keys).
     274     * @param bool   $use_id   When true, pass term ID. Else, skip the test.
     275     */
     276    public function test_get_term_feed_link_backward_compatibility( $taxonomy, $use_id ) {
     277        if ( $use_id ) {
     278            $term = $this->get_term( $taxonomy, $use_id );
     279
     280            $term_feed_link = get_term_feed_link( $term, $taxonomy );
     281            $this->assertIsString( $term_feed_link );
     282
     283            $term_feed_link = get_term_feed_link( $term, '' );
     284            $this->assertIsString( $term_feed_link );
     285        } else {
     286            $this->markTestSkipped( 'This test requires to pass an id to get_term_feed_link()' );
     287        }
     288    }
     289
     290    /**
    269291     * Data provider.
    270292     *
Note: See TracChangeset for help on using the changeset viewer.