PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/traits/user.php +6 -17 5.6.1 → 6.3.0 View file →
@@ -262,12 +262,13 @@
262 262 /**
263 263 * Check if the user has a role selected by the admin.
264 264 *
265 265 * @param WP_User|\stdClass $user User object.
266 + * @param object $model Model object.
266 267 *
267 268 * @return bool True if the user has a selected role, false otherwise.
268 269 */
269 - private function should_enforce_for_user( $user ): bool {
270 + private function should_enforce_for_user( $user, $model ): bool {
270 271 $roles = array();
271 272 if ( ! is_multisite() ) {
272 273 if ( $user instanceof WP_User ) {
273 274 $roles = $this->get_roles( $user );
@@ -288,26 +289,14 @@
288 289 $roles = array_merge( $u->roles, $roles );
289 290 }
290 291 }
291 292
292 - $user_roles = $this->get_user_roles_property();
293 + $user_roles = array();
294 + if ( is_object( $model ) && property_exists( $model, 'user_roles' ) ) {
295 + $user_roles = $model->user_roles;
296 + }
293 297
294 298 $array_intersect = array_intersect( $user_roles, $roles );
295 299
296 300 return array() !== $array_intersect;
297 - }
298 -
299 - /**
300 - * Retrieve the user roles property dynamically.
301 - *
302 - * @return array The user roles from the appropriate property.
303 - */
304 - private function get_user_roles_property(): array {
305 - if ( isset( $this->model ) && property_exists( $this->model, 'user_roles' ) ) {
306 - return $this->model->user_roles;
307 - } elseif ( isset( $this->settings ) && property_exists( $this->settings, 'user_roles' ) ) {
308 - return $this->settings->user_roles;
309 - }
310 -
311 - return array();
312 301 }
313 302 }