--- a/wp/wp-includes/class-wp-user.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/class-wp-user.php Fri Sep 05 18:40:08 2025 +0200
@@ -36,6 +36,7 @@
* @property string $syntax_highlighting
* @property string $use_ssl
*/
+#[AllowDynamicProperties]
class WP_User {
/**
* User data container.
@@ -116,13 +117,18 @@
*
* @since 2.0.0
*
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
* @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB.
* @param string $name Optional. User's username
* @param int $site_id Optional Site ID, defaults to current site.
*/
public function __construct( $id = 0, $name = '', $site_id = '' ) {
+ global $wpdb;
+
if ( ! isset( self::$back_compat_keys ) ) {
- $prefix = $GLOBALS['wpdb']->prefix;
+ $prefix = $wpdb->prefix;
+
self::$back_compat_keys = array(
'user_firstname' => 'first_name',
'user_lastname' => 'last_name',
@@ -155,7 +161,7 @@
if ( $data ) {
$this->init( $data, $site_id );
} else {
- $this->data = new stdClass;
+ $this->data = new stdClass();
}
}
@@ -185,7 +191,7 @@
*
* @global wpdb $wpdb WordPress database abstraction object.
*
- * @param string $field The field to query against: 'id', 'ID', 'slug', 'email' or 'login'.
+ * @param string $field The field to query against: Accepts 'id', 'ID', 'slug', 'email' or 'login'.
* @param string|int $value The field value.
* @return object|false Raw user object.
*/
@@ -198,8 +204,7 @@
}
if ( 'id' === $field ) {
- // Make sure the value is numeric to avoid casting objects, for example,
- // to int 1.
+ // Make sure the value is numeric to avoid casting objects, for example, to int 1.
if ( ! is_numeric( $value ) ) {
return false;
}
@@ -500,7 +505,7 @@
*/
public function get_role_caps() {
$switch_site = false;
- if ( is_multisite() && get_current_blog_id() != $this->site_id ) {
+ if ( is_multisite() && get_current_blog_id() !== $this->site_id ) {
$switch_site = true;
switch_to_blog( $this->site_id );
@@ -602,7 +607,7 @@
* @param string $role Role name.
*/
public function set_role( $role ) {
- if ( 1 === count( $this->roles ) && current( $this->roles ) == $role ) {
+ if ( 1 === count( $this->roles ) && current( $this->roles ) === $role ) {
return;
}
@@ -893,7 +898,7 @@
* @since 4.9.0
*
* @return bool[] List of capabilities keyed by the capability name,
- * e.g. array( 'edit_posts' => true, 'delete_posts' => false ).
+ * e.g. `array( 'edit_posts' => true, 'delete_posts' => false )`.
*/
private function get_caps_data() {
$caps = get_user_meta( $this->ID, $this->cap_key, true );