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 +22 -9 1.1.5 → 1.1.13 View file →
@@ -855,9 +855,9 @@
855 855 }
856 856 }
857 857 $actor_payload = array(
858 858 'id' => $viewer_can_see ? $actor_id : 0,
859 - 'name' => $viewer_can_see && $actor ? $actor->display_name : '',
859 + 'name' => $viewer_can_see && $actor ? openstation_plain_text_title( $actor->display_name ) : '',
860 860 'avatar' => $viewer_can_see && $actor ? get_avatar_url( $actor->ID, array( 'size' => 32 ) ) : '',
861 861 );
862 862
863 863 return new WP_Error(
@@ -901,9 +901,9 @@
901 901 );
902 902 if ( 'user' === $row['principal_type'] ) {
903 903 $uid = (int) $row['principal_ref'];
904 904 $user = $uid > 0 ? get_userdata( $uid ) : null;
905 - $shape['displayName'] = $user ? $user->display_name : '';
905 + $shape['displayName'] = $user ? openstation_plain_text_title( $user->display_name ) : '';
906 906 $shape['avatarUrl'] = $user ? get_avatar_url( $uid, array( 'size' => 48 ) ) : '';
907 907 } else {
908 908 $roles = wp_roles();
909 909 $info = $roles && isset( $roles->roles[ $row['principal_ref'] ] ) ? $roles->roles[ $row['principal_ref'] ] : null;
@@ -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
@@ -1221,9 +1234,9 @@
1221 1234 // broader than needed for a share picker. Matches the
1222 1235 // `slug` field WP's own `/wp/v2/users` endpoint surfaces.
1223 1236 $out[] = array(
1224 1237 'id' => (int) $user->ID,
1225 - 'name' => (string) $user->display_name,
1238 + 'name' => openstation_plain_text_title( $user->display_name ),
1226 1239 'slug' => (string) $user->user_nicename,
1227 1240 'avatarUrl' => get_avatar_url( $user->ID, array( 'size' => 48 ) ),
1228 1241 );
1229 1242 }