PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.13
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.13
1.1.13 1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 All 37 releases
← All changes | includes/desktop-files/rest.php +19 -6 1.1.12 → 1.1.13 View file →
@@ -1183,18 +1183,31 @@
1183 1183 // in the dropdown on it.
1184 1184 $exclude[] = (int) get_current_user_id();
1185 1185 $exclude = array_values( array_unique( array_filter( $exclude ) ) );
1186 1186
1187 + // Eligibility lives in the query, not only in the loop below:
1188 + // with `number` applied first, a page of 20 Subscribers (or
1189 + // agents) sorting ahead of the editors came back empty after
1190 + // the per-row check, and the picker showed nobody at all. The
1191 + // loop still re-checks every row, because the filter below can
1192 + // rewrite these args.
1187 1193 $args = array(
1188 - 'number' => 20,
1189 - 'orderby' => 'display_name',
1190 - 'order' => 'ASC',
1191 - 'exclude' => $exclude,
1194 + 'number' => 20,
1195 + 'orderby' => 'display_name',
1196 + 'order' => 'ASC',
1197 + 'exclude' => $exclude,
1198 + 'capability' => 'edit_posts',
1199 + 'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- agents are excluded in SQL so they cannot use up the page.
1200 + array(
1201 + 'key' => OPENSTATION_AGENT_USER_MARKER_META,
1202 + 'compare' => 'NOT EXISTS',
1203 + ),
1204 + ),
1192 1205 // `fields => 'all'` returns full WP_User objects so the
1193 1206 // capability check below resolves role caps correctly. A
1194 1207 // stdClass with stripped fields breaks `user_can()` on
1195 1208 // some WordPress versions and silently drops every row.
1196 - 'fields' => 'all',
1209 + 'fields' => 'all',
1197 1210 );
1198 1211 if ( '' !== $q ) {
1199 1212 $args['search'] = '*' . $q . '*';
1200 1213 $args['search_columns'] = array( 'user_login', 'user_email', 'display_name', 'user_nicename' );
@@ -1211,9 +1224,9 @@
1211 1224 $query = new WP_User_Query( $args );
1212 1225 $users = $query->get_results();
1213 1226 $out = array();
1214 1227 foreach ( (array) $users as $user ) {
1215 - if ( ! user_can( $user, 'edit_posts' ) ) {
1228 + if ( ! openstation_files_share_user_is_eligible( $user ) ) {
1216 1229 continue;
1217 1230 }
1218 1231 // Disambiguation handle uses `user_nicename` (the public
1219 1232 // URL slug) instead of `user_login` — the login is the auth