wp/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php	Wed Sep 21 18:19:35 2022 +0200
@@ -38,7 +38,7 @@
 		$taxonomies = array_filter( $taxonomies, 'is_taxonomy_viewable' );
 
 		/**
-		 * Filter the list of taxonomy object subtypes available within the sitemap.
+		 * Filters the list of taxonomy object subtypes available within the sitemap.
 		 *
 		 * @since 5.5.0
 		 *
@@ -99,8 +99,14 @@
 
 		if ( ! empty( $taxonomy_terms->terms ) ) {
 			foreach ( $taxonomy_terms->terms as $term ) {
+				$term_link = get_term_link( $term, $taxonomy );
+
+				if ( is_wp_error( $term_link ) ) {
+					continue;
+				}
+
 				$sitemap_entry = array(
-					'loc' => get_term_link( $term ),
+					'loc' => $term_link,
 				);
 
 				/**
@@ -150,7 +156,7 @@
 			return $max_num_pages;
 		}
 
-		$term_count = wp_count_terms( $taxonomy, $this->get_taxonomies_query_args( $taxonomy ) );
+		$term_count = wp_count_terms( $this->get_taxonomies_query_args( $taxonomy ) );
 
 		return (int) ceil( $term_count / wp_sitemaps_get_max_urls( $this->object_type ) );
 	}