← All changes
|
inc/freemius/includes/entities/class-fs-user.php
+85
-72
4.2.14
→
4.3.17
View file →
| @@ -1,73 +1,86 @@ | ||
| 1 | -<?php | |
| 2 | - /** | |
| 3 | - * @package Freemius | |
| 4 | - * @copyright Copyright (c) 2015, Freemius, Inc. | |
| 5 | - * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 | |
| 6 | - * @since 1.0.3 | |
| 7 | - */ | |
| 8 | - | |
| 9 | - if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - exit; | |
| 11 | - } | |
| 12 | - | |
| 13 | - class FS_User extends FS_Scope_Entity { | |
| 14 | - | |
| 15 | - #region Properties | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * @var string | |
| 19 | - */ | |
| 20 | - public $email; | |
| 21 | - /** | |
| 22 | - * @var string | |
| 23 | - */ | |
| 24 | - public $first; | |
| 25 | - /** | |
| 26 | - * @var string | |
| 27 | - */ | |
| 28 | - public $last; | |
| 29 | - /** | |
| 30 | - * @var bool | |
| 31 | - */ | |
| 32 | - public $is_verified; | |
| 33 | - /** | |
| 34 | - * @var string|null | |
| 35 | - */ | |
| 36 | - public $customer_id; | |
| 37 | - /** | |
| 38 | - * @var float | |
| 39 | - */ | |
| 40 | - public $gross; | |
| 41 | - | |
| 42 | - #endregion Properties | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * @param object|bool $user | |
| 46 | - */ | |
| 47 | - function __construct( $user = false ) { | |
| 48 | - parent::__construct( $user ); | |
| 49 | - } | |
| 50 | - | |
| 51 | - function get_name() { | |
| 52 | - return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) ); | |
| 53 | - } | |
| 54 | - | |
| 55 | - function is_verified() { | |
| 56 | - return ( isset( $this->is_verified ) && true === $this->is_verified ); | |
| 57 | - } | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * @author Leo Fajardo (@leorw) | |
| 61 | - * @since 2.4.2 | |
| 62 | - * | |
| 63 | - * @return bool | |
| 64 | - */ | |
| 65 | - function is_beta() { | |
| 66 | - // Return `false` since this is just for backward compatibility. | |
| 67 | - return false; | |
| 68 | - } | |
| 69 | - | |
| 70 | - static function get_type() { | |
| 71 | - return 'user'; | |
| 72 | - } | |
| 1 | +<?php | |
| 2 | + /** | |
| 3 | + * @package Freemius | |
| 4 | + * @copyright Copyright (c) 2015, Freemius, Inc. | |
| 5 | + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 | |
| 6 | + * @since 1.0.3 | |
| 7 | + */ | |
| 8 | + | |
| 9 | + if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit; | |
| 11 | + } | |
| 12 | + | |
| 13 | + class FS_User extends FS_Scope_Entity { | |
| 14 | + | |
| 15 | + #region Properties | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * @var string | |
| 19 | + */ | |
| 20 | + public $email; | |
| 21 | + /** | |
| 22 | + * @var string | |
| 23 | + */ | |
| 24 | + public $first; | |
| 25 | + /** | |
| 26 | + * @var string | |
| 27 | + */ | |
| 28 | + public $last; | |
| 29 | + /** | |
| 30 | + * @var bool | |
| 31 | + */ | |
| 32 | + public $is_verified; | |
| 33 | + /** | |
| 34 | + * @var string|null | |
| 35 | + */ | |
| 36 | + public $customer_id; | |
| 37 | + /** | |
| 38 | + * @var float | |
| 39 | + */ | |
| 40 | + public $gross; | |
| 41 | + | |
| 42 | + #endregion Properties | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * @param object|bool $user | |
| 46 | + */ | |
| 47 | + function __construct( $user = false ) { | |
| 48 | + parent::__construct( $user ); | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * This method removes the deprecated 'is_beta' property from the serialized data. | |
| 53 | + * Should clean up the serialized data to avoid PHP 8.2 warning on next execution. | |
| 54 | + * | |
| 55 | + * @return void | |
| 56 | + */ | |
| 57 | + function __wakeup() { | |
| 58 | + if ( property_exists( $this, 'is_beta' ) ) { | |
| 59 | + // If we enter here, and we are running PHP 8.2, we already had the warning. But we sanitize data for next execution. | |
| 60 | + unset( $this->is_beta ); | |
| 61 | + } | |
| 62 | + } | |
| 63 | + | |
| 64 | + function get_name() { | |
| 65 | + return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) ); | |
| 66 | + } | |
| 67 | + | |
| 68 | + function is_verified() { | |
| 69 | + return ( isset( $this->is_verified ) && true === $this->is_verified ); | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * @author Leo Fajardo (@leorw) | |
| 74 | + * @since 2.4.2 | |
| 75 | + * | |
| 76 | + * @return bool | |
| 77 | + */ | |
| 78 | + function is_beta() { | |
| 79 | + // Return `false` since this is just for backward compatibility. | |
| 80 | + return false; | |
| 81 | + } | |
| 82 | + | |
| 83 | + static function get_type() { | |
| 84 | + return 'user'; | |
| 85 | + } | |
| 73 | 86 | } |