PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 2.0.0
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v2.0.0
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / freemius / includes / entities / class-fs-plugin-license.php
embedpress / freemius / includes / entities Last commit date
class-fs-billing.php 9 years ago class-fs-entity.php 9 years ago class-fs-payment.php 9 years ago class-fs-plugin-info.php 9 years ago class-fs-plugin-license.php 9 years ago class-fs-plugin-plan.php 9 years ago class-fs-plugin-tag.php 9 years ago class-fs-plugin.php 9 years ago class-fs-pricing.php 9 years ago class-fs-scope-entity.php 9 years ago class-fs-site.php 9 years ago class-fs-subscription.php 9 years ago class-fs-user.php 9 years ago index.php 9 years ago
class-fs-plugin-license.php
225 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6 * @since 1.0.5
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Class FS_Plugin_License
15 */
16 class FS_Plugin_License extends FS_Entity {
17
18 #region Properties
19
20 /**
21 * @var number
22 */
23 public $plugin_id;
24 /**
25 * @var number
26 */
27 public $user_id;
28 /**
29 * @var number
30 */
31 public $plan_id;
32 /**
33 * @var number
34 */
35 public $pricing_id;
36 /**
37 * @var int|null
38 */
39 public $quota;
40 /**
41 * @var int
42 */
43 public $activated;
44 /**
45 * @var int
46 */
47 public $activated_local;
48 /**
49 * @var string
50 */
51 public $expiration;
52 /**
53 * @var string
54 */
55 public $secret_key;
56 /**
57 * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
58 * license.
59 */
60 public $is_free_localhost;
61 /**
62 * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
63 * block updates and support.
64 */
65 public $is_block_features;
66 /**
67 * @var bool
68 */
69 public $is_cancelled;
70
71 #endregion Properties
72
73 /**
74 * @param stdClass|bool $license
75 */
76 function __construct( $license = false ) {
77 parent::__construct( $license );
78 }
79
80 /**
81 * Get entity type.
82 *
83 * @return string
84 */
85 static function get_type() {
86 return 'license';
87 }
88
89 /**
90 * Check how many site activations left.
91 *
92 * @author Vova Feldman (@svovaf)
93 * @since 1.0.5
94 *
95 * @return int
96 */
97 function left() {
98 if ( ! $this->is_active() || $this->is_expired() ) {
99 return 0;
100 }
101
102 if ( $this->is_unlimited() ) {
103 return 999;
104 }
105
106 return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
107 }
108
109 /**
110 * Check if single site license.
111 *
112 * @author Vova Feldman (@svovaf)
113 * @since 1.1.8.1
114 *
115 * @return bool
116 */
117 function is_single_site() {
118 return ( is_numeric( $this->quota ) && 1 == $this->quota );
119 }
120
121 /**
122 * @author Vova Feldman (@svovaf)
123 * @since 1.0.5
124 *
125 * @return bool
126 */
127 function is_expired() {
128 return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME );
129 }
130
131 /**
132 * Check if license is not expired.
133 *
134 * @author Vova Feldman (@svovaf)
135 * @since 1.2.1
136 *
137 * @return bool
138 */
139 function is_valid() {
140 return ! $this->is_expired();
141 }
142
143 /**
144 * @author Vova Feldman (@svovaf)
145 * @since 1.0.6
146 *
147 * @return bool
148 */
149 function is_lifetime() {
150 return is_null( $this->expiration );
151 }
152
153 /**
154 * @author Vova Feldman (@svovaf)
155 * @since 1.2.0
156 *
157 * @return bool
158 */
159 function is_unlimited() {
160 return is_null( $this->quota );
161 }
162
163 /**
164 * Check if license is fully utilized.
165 *
166 * @author Vova Feldman (@svovaf)
167 * @since 1.0.6
168 *
169 * @param bool $is_localhost
170 *
171 * @return bool
172 */
173 function is_utilized( $is_localhost = null ) {
174 if ( is_null( $is_localhost ) ) {
175 $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER;
176 }
177
178 if ( $this->is_unlimited() ) {
179 return false;
180 }
181
182 return ! ( $this->is_free_localhost && $is_localhost ) &&
183 ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
184 }
185
186 /**
187 * @author Vova Feldman (@svovaf)
188 * @since 1.2.1
189 *
190 * @return bool
191 */
192 function is_active() {
193 return ( ! $this->is_cancelled );
194 }
195
196 /**
197 * Check if license's plan features are enabled.
198 *
199 * - Either if plan not expired
200 * - If expired, based on the configuration to block features or not.
201 *
202 * @author Vova Feldman (@svovaf)
203 * @since 1.0.6
204 *
205 * @return bool
206 */
207 function is_features_enabled() {
208 return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() );
209 }
210
211 /**
212 * Subscription considered to be new without any payments
213 * if the license expires in less than 24 hours
214 * from the license creation.
215 *
216 * @author Vova Feldman (@svovaf)
217 * @since 1.0.9
218 *
219 * @return bool
220 */
221 function is_first_payment_pending() {
222 return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );
223 }
224 }
225