51 |
51 |
52 /** |
52 /** |
53 * Gets a URL list for a post type sitemap. |
53 * Gets a URL list for a post type sitemap. |
54 * |
54 * |
55 * @since 5.5.0 |
55 * @since 5.5.0 |
56 * |
56 * @since 5.9.0 Renamed `$post_type` to `$object_subtype` to match parent class |
57 * @param int $page_num Page of results. |
57 * for PHP 8 named parameter support. |
58 * @param string $post_type Optional. Post type name. Default empty. |
58 * |
59 * @return array Array of URLs for a sitemap. |
59 * @param int $page_num Page of results. |
60 */ |
60 * @param string $object_subtype Optional. Post type name. Default empty. |
61 public function get_url_list( $page_num, $post_type = '' ) { |
61 * |
|
62 * @return array[] Array of URL information for a sitemap. |
|
63 */ |
|
64 public function get_url_list( $page_num, $object_subtype = '' ) { |
|
65 // Restores the more descriptive, specific name for use within this method. |
|
66 $post_type = $object_subtype; |
|
67 |
62 // Bail early if the queried post type is not supported. |
68 // Bail early if the queried post type is not supported. |
63 $supported_types = $this->get_object_subtypes(); |
69 $supported_types = $this->get_object_subtypes(); |
64 |
70 |
65 if ( ! isset( $supported_types[ $post_type ] ) ) { |
71 if ( ! isset( $supported_types[ $post_type ] ) ) { |
66 return array(); |
72 return array(); |
67 } |
73 } |
68 |
74 |
69 /** |
75 /** |
70 * Filters the posts URL list before it is generated. |
76 * Filters the posts URL list before it is generated. |
71 * |
77 * |
72 * Passing a non-null value will effectively short-circuit the generation, |
78 * Returning a non-null value will effectively short-circuit the generation, |
73 * returning that value instead. |
79 * returning that value instead. |
74 * |
80 * |
75 * @since 5.5.0 |
81 * @since 5.5.0 |
76 * |
82 * |
77 * @param array $url_list The URL list. Default null. |
83 * @param array[]|null $url_list The URL list. Default null. |
78 * @param string $post_type Post type name. |
84 * @param string $post_type Post type name. |
79 * @param int $page_num Page of results. |
85 * @param int $page_num Page of results. |
80 */ |
86 */ |
81 $url_list = apply_filters( |
87 $url_list = apply_filters( |
82 'wp_sitemaps_posts_pre_url_list', |
88 'wp_sitemaps_posts_pre_url_list', |
83 null, |
89 null, |
84 $post_type, |
90 $post_type, |
140 |
146 |
141 /** |
147 /** |
142 * Gets the max number of pages available for the object type. |
148 * Gets the max number of pages available for the object type. |
143 * |
149 * |
144 * @since 5.5.0 |
150 * @since 5.5.0 |
145 * |
151 * @since 5.9.0 Renamed `$post_type` to `$object_subtype` to match parent class |
146 * @param string $post_type Optional. Post type name. Default empty. |
152 * for PHP 8 named parameter support. |
|
153 * |
|
154 * @param string $object_subtype Optional. Post type name. Default empty. |
147 * @return int Total number of pages. |
155 * @return int Total number of pages. |
148 */ |
156 */ |
149 public function get_max_num_pages( $post_type = '' ) { |
157 public function get_max_num_pages( $object_subtype = '' ) { |
150 if ( empty( $post_type ) ) { |
158 if ( empty( $object_subtype ) ) { |
151 return 0; |
159 return 0; |
152 } |
160 } |
|
161 |
|
162 // Restores the more descriptive, specific name for use within this method. |
|
163 $post_type = $object_subtype; |
153 |
164 |
154 /** |
165 /** |
155 * Filters the max number of pages before it is generated. |
166 * Filters the max number of pages before it is generated. |
156 * |
167 * |
157 * Passing a non-null value will short-circuit the generation, |
168 * Passing a non-null value will short-circuit the generation, |