Make WordPress Core


Ignore:
Timestamp:
10/13/2020 03:02:23 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Sitemaps: Check the result of get_term_link() when collecting the URLs in WP_Sitemaps_Taxonomies::get_url_list().

This avoids a PHP warning during sitemap generation if get_term_link() returns an error, e.g. due to term ID being shared between multiple taxonomies.

Additionally, pass the $taxonomy argument to get_term_link() to properly disambiguate the call.

Props dd32.
Fixes #51416.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php

    r48840 r49137  
    100100        if ( ! empty( $taxonomy_terms->terms ) ) {
    101101            foreach ( $taxonomy_terms->terms as $term ) {
     102                $term_link = get_term_link( $term, $taxonomy );
     103
     104                if ( is_wp_error( $term_link ) ) {
     105                    continue;
     106                }
     107
    102108                $sitemap_entry = array(
    103                     'loc' => get_term_link( $term ),
     109                    'loc' => $term_link,
    104110                );
    105111
Note: See TracChangeset for help on using the changeset viewer.