diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/class-wp-roles.php --- a/wp/wp-includes/class-wp-roles.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/class-wp-roles.php Fri Sep 05 18:40:08 2025 +0200 @@ -23,6 +23,7 @@ * * @since 2.0.0 */ +#[AllowDynamicProperties] class WP_Roles { /** * List of roles and capabilities. @@ -73,7 +74,7 @@ protected $site_id = 0; /** - * Constructor + * Constructor. * * @since 2.0.0 * @since 4.9.0 The `$site_id` argument was added. @@ -91,7 +92,7 @@ } /** - * Make private/protected methods readable for backward compatibility. + * Makes private/protected methods readable for backward compatibility. * * @since 4.0.0 * @@ -107,7 +108,7 @@ } /** - * Set up the object properties. + * Sets up the object properties. * * The role key is set to the current prefix for the $wpdb object with * 'user_roles' appended. If the $wp_user_roles global is set, then it will @@ -123,7 +124,7 @@ } /** - * Reinitialize the object + * Reinitializes the object. * * Recreates the role objects. This is typically called only by switch_to_blog() * after switching wpdb to a new site ID. @@ -138,20 +139,21 @@ } /** - * Add role name with capabilities to list. + * Adds a role name with capabilities to the list. * * Updates the list of roles, if the role doesn't already exist. * - * The capabilities are defined in the following format `array( 'read' => true );` - * To explicitly deny a role a capability you set the value for that capability to false. + * The capabilities are defined in the following format: `array( 'read' => true )`. + * To explicitly deny the role a capability, set the value for that capability to false. * * @since 2.0.0 * * @param string $role Role name. * @param string $display_name Role display name. - * @param bool[] $capabilities List of capabilities keyed by the capability name, - * e.g. array( 'edit_posts' => true, 'delete_posts' => false ). - * @return WP_Role|void WP_Role object, if role is added. + * @param bool[] $capabilities Optional. List of capabilities keyed by the capability name, + * e.g. `array( 'edit_posts' => true, 'delete_posts' => false )`. + * Default empty array. + * @return WP_Role|void WP_Role object, if the role is added. */ public function add_role( $role, $display_name, $capabilities = array() ) { if ( empty( $role ) || isset( $this->roles[ $role ] ) ) { @@ -171,7 +173,7 @@ } /** - * Remove role by name. + * Removes a role by name. * * @since 2.0.0 * @@ -190,13 +192,13 @@ update_option( $this->role_key, $this->roles ); } - if ( get_option( 'default_role' ) == $role ) { + if ( get_option( 'default_role' ) === $role ) { update_option( 'default_role', 'subscriber' ); } } /** - * Add capability to role. + * Adds a capability to role. * * @since 2.0.0 * @@ -217,7 +219,7 @@ } /** - * Remove capability from role. + * Removes a capability from role. * * @since 2.0.0 * @@ -236,7 +238,7 @@ } /** - * Retrieve role object by name. + * Retrieves a role object by name. * * @since 2.0.0 * @@ -252,7 +254,7 @@ } /** - * Retrieve list of role names. + * Retrieves a list of role names. * * @since 2.0.0 * @@ -263,7 +265,7 @@ } /** - * Whether role name is currently in the list of available roles. + * Determines whether a role name is currently in the list of available roles. * * @since 2.0.0 * @@ -292,7 +294,7 @@ } /** - * After the roles have been initialized, allow plugins to add their own roles. + * Fires after the roles have been initialized, allowing plugins to add their own roles. * * @since 4.7.0 * @@ -357,7 +359,7 @@ return $wp_user_roles; } - if ( is_multisite() && get_current_blog_id() != $this->site_id ) { + if ( is_multisite() && get_current_blog_id() !== $this->site_id ) { remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 ); $roles = get_blog_option( $this->site_id, $this->role_key, array() );