PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
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 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/agents/identity.php +22 -17 1.0.01.1.10 View file →
@@ -149,9 +149,25 @@
149 149 if ( ! function_exists( 'wp_delete_user' ) ) {
150 150 require_once ABSPATH . 'wp-admin/includes/user.php';
151 151 }
152 152
153 - $deleted = wp_delete_user( (int) $user_id, $reassign );
153 + // On multisite `wp_delete_user()` only removes the user from the
154 + // CURRENT site — the network account (and the agent's meta with
155 + // it) lives on. The agent's whole identity is its wp user, so
156 + // deleting the agent means the network-wide delete.
157 + if ( is_multisite() ) {
158 + if ( ! function_exists( 'wpmu_delete_user' ) ) {
159 + require_once ABSPATH . 'wp-admin/includes/ms.php';
160 + }
161 + if ( null !== $reassign ) {
162 + // `wpmu_delete_user()` has no reassign parameter; hand the
163 + // current site's content over before the user goes.
164 + wp_delete_user( (int) $user_id, $reassign );
165 + }
166 + $deleted = wpmu_delete_user( (int) $user_id );
167 + } else {
168 + $deleted = wp_delete_user( (int) $user_id, $reassign );
169 + }
154 170 if ( ! $deleted ) {
155 171 return new WP_Error(
156 172 'openstation_agent_delete_failed',
157 173 __( 'Could not delete the agent user.', 'desktop-mode' )
@@ -170,26 +186,15 @@
170 186 }
171 187
172 188 // ---------------------------------------------------------------------------
173 189 // Identity surface
190 +//
191 +// `openstation_agent_avatar_url()` lives in bootstrap.php: the WP
192 +// Explorer integration needs it for the entity icon and loads while the
193 +// feature flag is off, when this file does not.
174 194 // ---------------------------------------------------------------------------
175 195
176 196 /**
177 - * URL of the bot avatar as a real static file.
178 - *
179 - * The avatar MUST be a file URL, not the data URI: consumers routinely
180 - * run avatar URLs through `esc_url()` (wp-admin's `get_avatar()`, the
181 - * desktop user-tile renderer), and `data` is not in
182 - * `wp_allowed_protocols()` — the data URI silently becomes an empty
183 - * string and the avatar renders broken.
184 - *
185 - * @return string
186 - */
187 -function openstation_agent_avatar_url() {
188 - return OPENSTATION_URL . 'assets/images/agent-avatar.svg';
189 -}
190 -
191 -/**
192 197 * Substitute the bot glyph for agent avatars across the WP admin.
193 198 *
194 199 * @param array $args Args being assembled by `get_avatar_data()`.
195 200 * @param int|string|WP_User|WP_Comment $id_or_email Identifier the caller passed.
@@ -210,9 +215,9 @@
210 215 }
211 216 }
212 217
213 218 if ( $user_id > 0 && openstation_agent_is_agent( $user_id ) ) {
214 - $args['url'] = openstation_agent_avatar_url();
219 + $args['url'] = openstation_agent_avatar_url( $user_id );
215 220 $args['found_avatar'] = true;
216 221 }
217 222 return $args;
218 223 }