From dcb118ef8f2ba1405f18bd52e431963fe30f3f57 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 10 Mar 2022 03:59:35 +0000 Subject: [PATCH] Sitemaps: Pass term object to `wp_sitemaps_taxonomies_entry` filter. Add a forth parameter to the `wp_sitemaps_taxonomies_entry` filter to pass the entire `WP_Term` object. Correct the documentation for the second parameter of the `wp_sitemaps_taxonomies_entry` filter to indicate it is a term ID rather than term object. Props RavanH, swissspidy, audrasjb. Fixes #55239. git-svn-id: https://develop.svn.wordpress.org/trunk@52834 602fd350-edb4-49c9-b593-d223f7449a82 --- .../sitemaps/providers/class-wp-sitemaps-taxonomies.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php index a7a752a080..6d9b6c7838 100644 --- a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php +++ b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php @@ -97,6 +97,7 @@ class WP_Sitemaps_Taxonomies extends WP_Sitemaps_Provider { $offset = ( $page_num - 1 ) * wp_sitemaps_get_max_urls( $this->object_type ); $args = $this->get_taxonomies_query_args( $taxonomy ); + $args['fields'] = 'all'; $args['offset'] = $offset; $taxonomy_terms = new WP_Term_Query( $args ); @@ -117,12 +118,14 @@ class WP_Sitemaps_Taxonomies extends WP_Sitemaps_Provider { * Filters the sitemap entry for an individual term. * * @since 5.5.0 + * @since 6.0.0 Added fourth argument for the term object. * * @param array $sitemap_entry Sitemap entry for the term. - * @param WP_Term $term Term object. + * @param int $term_id Term ID. * @param string $taxonomy Taxonomy name. + * @param WP_Term $term Term object. */ - $sitemap_entry = apply_filters( 'wp_sitemaps_taxonomies_entry', $sitemap_entry, $term, $taxonomy ); + $sitemap_entry = apply_filters( 'wp_sitemaps_taxonomies_entry', $sitemap_entry, $term->term_id, $taxonomy, $term ); $url_list[] = $sitemap_entry; } } @@ -194,7 +197,6 @@ class WP_Sitemaps_Taxonomies extends WP_Sitemaps_Provider { $args = apply_filters( 'wp_sitemaps_taxonomies_query_args', array( - 'fields' => 'ids', 'taxonomy' => $taxonomy, 'orderby' => 'term_order', 'number' => wp_sitemaps_get_max_urls( $this->object_type ),