equal
deleted
inserted
replaced
38 class WP_User { |
38 class WP_User { |
39 /** |
39 /** |
40 * User data container. |
40 * User data container. |
41 * |
41 * |
42 * @since 2.0.0 |
42 * @since 2.0.0 |
43 * @var object |
43 * @var stdClass |
44 */ |
44 */ |
45 public $data; |
45 public $data; |
46 |
46 |
47 /** |
47 /** |
48 * The user's ID. |
48 * The user's ID. |
165 * |
165 * |
166 * @param object $data User DB row object. |
166 * @param object $data User DB row object. |
167 * @param int $site_id Optional. The site ID to initialize for. |
167 * @param int $site_id Optional. The site ID to initialize for. |
168 */ |
168 */ |
169 public function init( $data, $site_id = '' ) { |
169 public function init( $data, $site_id = '' ) { |
|
170 if ( ! isset( $data->ID ) ) { |
|
171 $data->ID = 0; |
|
172 } |
170 $this->data = $data; |
173 $this->data = $data; |
171 $this->ID = (int) $data->ID; |
174 $this->ID = (int) $data->ID; |
172 |
175 |
173 $this->for_site( $site_id ); |
176 $this->for_site( $site_id ); |
174 } |
177 } |
197 // Make sure the value is numeric to avoid casting objects, for example, |
200 // Make sure the value is numeric to avoid casting objects, for example, |
198 // to int 1. |
201 // to int 1. |
199 if ( ! is_numeric( $value ) ) { |
202 if ( ! is_numeric( $value ) ) { |
200 return false; |
203 return false; |
201 } |
204 } |
202 $value = intval( $value ); |
205 $value = (int) $value; |
203 if ( $value < 1 ) { |
206 if ( $value < 1 ) { |
204 return false; |
207 return false; |
205 } |
208 } |
206 } else { |
209 } else { |
207 $value = trim( $value ); |
210 $value = trim( $value ); |
643 * @param string $item Level capability name. |
646 * @param string $item Level capability name. |
644 * @return int Max Level. |
647 * @return int Max Level. |
645 */ |
648 */ |
646 public function level_reduction( $max, $item ) { |
649 public function level_reduction( $max, $item ) { |
647 if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) { |
650 if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) { |
648 $level = intval( $matches[1] ); |
651 $level = (int) $matches[1]; |
649 return max( $max, $level ); |
652 return max( $max, $level ); |
650 } else { |
653 } else { |
651 return $max; |
654 return $max; |
652 } |
655 } |
653 } |
656 } |