← All changes
|
freemius/includes/entities/class-fs-plugin-license.php
+66
-1
2.0
→
8.0.2
View file →
| @@ -29,10 +29,38 @@ | ||
| 29 | 29 | * @var number |
| 30 | 30 | */ |
| 31 | 31 | public $plan_id; |
| 32 | 32 | /** |
| 33 | + * @author Leo Fajardo (@leorw) | |
| 34 | + * @since 2.3.0 | |
| 35 | + * | |
| 36 | + * @var string | |
| 37 | + */ | |
| 38 | + public $parent_plan_name; | |
| 39 | + /** | |
| 40 | + * @author Leo Fajardo (@leorw) | |
| 41 | + * @since 2.3.0 | |
| 42 | + * | |
| 43 | + * @var string | |
| 44 | + */ | |
| 45 | + public $parent_plan_title; | |
| 46 | + /** | |
| 47 | + * @author Leo Fajardo (@leorw) | |
| 48 | + * @since 2.3.0 | |
| 49 | + * | |
| 33 | 50 | * @var number |
| 34 | 51 | */ |
| 52 | + public $parent_license_id; | |
| 53 | + /** | |
| 54 | + * @author Leo Fajardo (@leorw) | |
| 55 | + * @since 2.4.0 | |
| 56 | + * | |
| 57 | + * @var array | |
| 58 | + */ | |
| 59 | + public $products; | |
| 60 | + /** | |
| 61 | + * @var number | |
| 62 | + */ | |
| 35 | 63 | public $pricing_id; |
| 36 | 64 | /** |
| 37 | 65 | * @var int|null |
| 38 | 66 | */ |
| @@ -53,8 +81,12 @@ | ||
| 53 | 81 | * @var string |
| 54 | 82 | */ |
| 55 | 83 | public $secret_key; |
| 56 | 84 | /** |
| 85 | + * @var bool | |
| 86 | + */ | |
| 87 | + public $is_whitelabeled; | |
| 88 | + /** | |
| 57 | 89 | * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same |
| 58 | 90 | * license. |
| 59 | 91 | */ |
| 60 | 92 | public $is_free_localhost; |
| @@ -94,9 +126,9 @@ | ||
| 94 | 126 | * |
| 95 | 127 | * @return int |
| 96 | 128 | */ |
| 97 | 129 | function left() { |
| 98 | - if ( ! $this->is_active() || $this->is_expired() ) { | |
| 130 | + if ( ! $this->is_features_enabled() ) { | |
| 99 | 131 | return 0; |
| 100 | 132 | } |
| 101 | 133 | |
| 102 | 134 | if ( $this->is_unlimited() ) { |
| @@ -256,8 +288,12 @@ | ||
| 256 | 288 | * |
| 257 | 289 | * @return bool |
| 258 | 290 | */ |
| 259 | 291 | function is_first_payment_pending() { |
| 292 | + if ( $this->is_lifetime() ) { | |
| 293 | + return false; | |
| 294 | + } | |
| 295 | + | |
| 260 | 296 | return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) ); |
| 261 | 297 | } |
| 262 | 298 | |
| 263 | 299 | /** |
| @@ -264,6 +300,35 @@ | ||
| 264 | 300 | * @return int |
| 265 | 301 | */ |
| 266 | 302 | function total_activations() { |
| 267 | 303 | return ( $this->activated + $this->activated_local ); |
| 304 | + } | |
| 305 | + | |
| 306 | + /** | |
| 307 | + * @author Vova Feldman (@svovaf) | |
| 308 | + * @since 2.3.1 | |
| 309 | + * | |
| 310 | + * @return string | |
| 311 | + */ | |
| 312 | + function get_html_escaped_masked_secret_key() { | |
| 313 | + return self::mask_secret_key_for_html( $this->secret_key ); | |
| 314 | + } | |
| 315 | + | |
| 316 | + /** | |
| 317 | + * @author Vova Feldman (@svovaf) | |
| 318 | + * @since 2.3.1 | |
| 319 | + * | |
| 320 | + * @param string $secret_key | |
| 321 | + * | |
| 322 | + * @return string | |
| 323 | + */ | |
| 324 | + static function mask_secret_key_for_html( $secret_key ) { | |
| 325 | + return ( | |
| 326 | + // Initial 6 chars - sk_ABC | |
| 327 | + htmlspecialchars( substr( $secret_key, 0, 6 ) ) . | |
| 328 | + // Masking | |
| 329 | + str_pad( '', ( strlen( $secret_key ) - 9 ) * 6, '•' ) . | |
| 330 | + // Last 3 chars. | |
| 331 | + htmlspecialchars( substr( $secret_key, - 3 ) ) | |
| 332 | + ); | |
| 268 | 333 | } |
| 269 | 334 | } |