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.


Built from https://develop.svn.wordpress.org/trunk@52834


git-svn-id: http://core.svn.wordpress.org/trunk@52423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-03-10 04:01:05 +00:00
parent a1d974a2e1
commit 8752a2392a
2 changed files with 6 additions and 4 deletions

View File

@ -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 ),

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-52833';
$wp_version = '6.0-alpha-52834';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.