wp/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php	Tue Sep 27 16:37:53 2022 +0200
@@ -51,12 +51,16 @@
 	 * Gets a URL list for a taxonomy sitemap.
 	 *
 	 * @since 5.5.0
+	 * @since 5.9.0 Renamed `$taxonomy` to `$object_subtype` to match parent class
+	 *              for PHP 8 named parameter support.
 	 *
-	 * @param int    $page_num Page of results.
-	 * @param string $taxonomy Optional. Taxonomy name. Default empty.
-	 * @return array Array of URLs for a sitemap.
+	 * @param int    $page_num       Page of results.
+	 * @param string $object_subtype Optional. Taxonomy name. Default empty.
+	 * @return array[] Array of URL information for a sitemap.
 	 */
-	public function get_url_list( $page_num, $taxonomy = '' ) {
+	public function get_url_list( $page_num, $object_subtype = '' ) {
+		// Restores the more descriptive, specific name for use within this method.
+		$taxonomy        = $object_subtype;
 		$supported_types = $this->get_object_subtypes();
 
 		// Bail early if the queried taxonomy is not supported.
@@ -67,14 +71,14 @@
 		/**
 		 * Filters the taxonomies URL list before it is generated.
 		 *
-		 * Passing a non-null value will effectively short-circuit the generation,
+		 * Returning a non-null value will effectively short-circuit the generation,
 		 * returning that value instead.
 		 *
 		 * @since 5.5.0
 		 *
-		 * @param array  $url_list The URL list. Default null.
-		 * @param string $taxonomy Taxonomy name.
-		 * @param int    $page_num Page of results.
+		 * @param array[]|null $url_list The URL list. Default null.
+		 * @param string       $taxonomy Taxonomy name.
+		 * @param int          $page_num Page of results.
 		 */
 		$url_list = apply_filters(
 			'wp_sitemaps_taxonomies_pre_url_list',
@@ -93,6 +97,7 @@
 		$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 );
@@ -113,12 +118,14 @@
 				 * Filters the sitemap entry for an individual term.
 				 *
 				 * @since 5.5.0
+				 * @since 6.0.0 Added `$term` argument containing 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;
 			}
 		}
@@ -130,25 +137,30 @@
 	 * Gets the max number of pages available for the object type.
 	 *
 	 * @since 5.5.0
+	 * @since 5.9.0 Renamed `$taxonomy` to `$object_subtype` to match parent class
+	 *              for PHP 8 named parameter support.
 	 *
-	 * @param string $taxonomy Taxonomy name.
+	 * @param string $object_subtype Optional. Taxonomy name. Default empty.
 	 * @return int Total number of pages.
 	 */
-	public function get_max_num_pages( $taxonomy = '' ) {
-		if ( empty( $taxonomy ) ) {
+	public function get_max_num_pages( $object_subtype = '' ) {
+		if ( empty( $object_subtype ) ) {
 			return 0;
 		}
 
+		// Restores the more descriptive, specific name for use within this method.
+		$taxonomy = $object_subtype;
+
 		/**
-		 * Filters the max number of pages before it is generated.
+		 * Filters the max number of pages for a taxonomy sitemap before it is generated.
 		 *
 		 * Passing a non-null value will short-circuit the generation,
 		 * returning that value instead.
 		 *
 		 * @since 5.5.0
 		 *
-		 * @param int    $max_num_pages The maximum number of pages. Default null.
-		 * @param string $taxonomy      Taxonomy name.
+		 * @param int|null $max_num_pages The maximum number of pages. Default null.
+		 * @param string   $taxonomy      Taxonomy name.
 		 */
 		$max_num_pages = apply_filters( 'wp_sitemaps_taxonomies_pre_max_num_pages', null, $taxonomy );
 
@@ -185,7 +197,6 @@
 		$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 ),