PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.6 28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 All 130 releases
← All changes | inc/sitemaps/class-author-sitemap-provider.php +29 -20 27.7 → trunk View file →
@@ -87,43 +87,51 @@
87 87 * @return array
88 88 */
89 89 protected function get_users( $arguments = [] ) {
90 90
91 - global $wpdb;
92 -
93 91 $defaults = [
94 - 'capability' => [ 'edit_posts' ],
95 92 'meta_key' => '_yoast_wpseo_profile_updated',
96 93 'orderby' => 'meta_value_num',
97 94 'order' => 'DESC',
98 95 'meta_query' => [
99 - 'relation' => 'AND',
96 + 'relation' => 'OR',
100 97 [
101 - 'key' => $wpdb->get_blog_prefix() . 'user_level',
102 - 'value' => '0',
98 + 'key' => 'wpseo_noindex_author',
99 + 'value' => 'on',
103 100 'compare' => '!=',
104 101 ],
105 102 [
106 - 'relation' => 'OR',
107 - [
108 - 'key' => 'wpseo_noindex_author',
109 - 'value' => 'on',
110 - 'compare' => '!=',
111 - ],
112 - [
113 - 'key' => 'wpseo_noindex_author',
114 - 'compare' => 'NOT EXISTS',
115 - ],
103 + 'key' => 'wpseo_noindex_author',
104 + 'compare' => 'NOT EXISTS',
116 105 ],
117 106 ],
118 107 ];
119 108
109 + $defaults = $this->apply_author_eligibility_filter( $defaults );
110 +
111 + return get_users( array_merge( $defaults, $arguments ) );
112 + }
113 +
114 + /**
115 + * Applies the author-eligibility clause (capability or has_published_posts) to a get_users() criteria array.
116 + *
117 + * Centralises the `noindex-author-noposts-wpseo` branching so the sitemap query and its
118 + * backfill counterpart always agree on which users are considered eligible.
119 + *
120 + * @param array<string, array<array<string, string>>> $criteria The get_users() criteria array to extend.
121 + *
122 + * @return array<string, array<array<string, string>>> The criteria array with the eligibility clause applied.
123 + */
124 + protected function apply_author_eligibility_filter( array $criteria ) {
120 125 if ( WPSEO_Options::get( 'noindex-author-noposts-wpseo', true ) ) {
121 - unset( $defaults['capability'] ); // Otherwise it cancels out next argument.
122 - $defaults['has_published_posts'] = YoastSEO()->helpers->author_archive->get_author_archive_post_types();
126 + $criteria['has_published_posts'] = YoastSEO()->helpers->author_archive->get_author_archive_post_types();
127 +
128 + return $criteria;
123 129 }
124 130
125 - return get_users( array_merge( $defaults, $arguments ) );
131 + $criteria['capability'] = [ 'edit_posts' ];
132 +
133 + return $criteria;
126 134 }
127 135
128 136 /**
129 137 * Get set of sitemap link data.
@@ -204,9 +212,8 @@
204 212 */
205 213 protected function update_user_meta() {
206 214
207 215 $user_criteria = [
208 - 'capability' => [ 'edit_posts' ],
209 216 'meta_query' => [
210 217 [
211 218 'key' => '_yoast_wpseo_profile_updated',
212 219 'compare' => 'NOT EXISTS',
@@ -212,8 +219,10 @@
212 219 'compare' => 'NOT EXISTS',
213 220 ],
214 221 ],
215 222 ];
223 +
224 + $user_criteria = $this->apply_author_eligibility_filter( $user_criteria );
216 225
217 226 $users = get_users( $user_criteria );
218 227
219 228 $time = time();