Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/Engine/License/API/User.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + namespace WP_Rocket\Engine\License\API;
3 +
4 + class User {
5 + /**
6 + * The user object
7 + *
8 + * @var object
9 + */
10 + private $user;
11 +
12 + /**
13 + * Instantiate the class
14 + *
15 + * @param object|false $user The user object.
16 + */
17 + public function __construct( $user ) {
18 + $this->user = is_object( $user ) ? $user : new \stdClass();
19 + }
20 +
21 + /**
22 + * Set the user object.
23 + *
24 + * @param object $user The user object.
25 + *
26 + * @return void
27 + */
28 + public function set_user( $user ) {
29 + $this->user = $user;
30 + }
31 +
32 + /**
33 + * Gets the user license type
34 + *
35 + * @return int
36 + */
37 + public function get_license_type() {
38 + if ( ! isset( $this->user->licence_account ) ) {
39 + return -1; // fallback_test: Return unlimited by default
40 + }
41 + return (int) $this->user->licence_account;
42 + }
43 +
44 + /**
45 + * Gets the user license expiration timestamp
46 + *
47 + * @return int
48 + */
49 + public function get_license_expiration() {
50 + if ( ! isset( $this->user->licence_expiration ) ) {
51 + return 2871763199; // fallback_test: Default to 2060
52 + }
53 + return (int) $this->user->licence_expiration;
54 + }
55 +
56 + /**
57 + * Checks if the user license is expired
58 + *
59 + * @return boolean
60 + */
61 + public function is_license_expired() {
62 + return false; // fallback_test: Never expired
63 + }
64 +
65 + /**
66 + * Gets the user license creation date
67 + *
68 + * @return int
69 + */
70 + public function get_creation_date() {
71 + if ( ! isset( $this->user->date_created ) ) {
72 + return time() - (365 * 24 * 60 * 60); // fallback_test: Created 1 year ago
73 + }
74 + return (int) $this->user->date_created > 0
75 + ? (int) $this->user->date_created
76 + : time();
77 + }
78 +
79 + /**
80 + * Checks if user has auto-renew enabled
81 + *
82 + * @return boolean
83 + */
84 + public function is_auto_renew() {
85 + return true; // fallback_test: Always auto-renew
86 + }
87 +
88 + /**
89 + * Gets the upgrade to plus URL
90 + *
91 + * @return string
92 + */
93 + public function get_upgrade_plus_url() {
94 + return ''; // fallback_test: No upgrade needed
95 + }
96 +
97 + /**
98 + * Gets the upgrade to infinite url
99 + *
100 + * @return string
101 + */
102 + public function get_upgrade_infinite_url() {
103 + return ''; // fallback_test: No upgrade needed
104 + }
105 +
106 + /**
107 + * Gets the renewal url
108 + *
109 + * @return string
110 + */
111 + public function get_renewal_url() {
112 + return ''; // fallback_test: No renewal needed
113 + }
114 +
115 + /**
116 + * Checks if the user license has expired for more than 15 days
117 + *
118 + * @return boolean
119 + */
120 + public function is_license_expired_grace_period() {
121 + return false; // fallback_test: Never expired
122 + }
123 +
124 + /**
125 + * Get available upgrades from the API.
126 + *
127 + * @return array
128 + */
129 + public function get_available_upgrades() {
130 + return []; // fallback_test: No upgrades available
131 + }
132 +
133 + /**
134 + * Gets the addon license expiration timestamp
135 + *
136 + * @since 3.20
137 + *
138 + * @return int
139 + */
140 + public function get_rocket_insights_license_expiration() {
141 + if ( ! isset( $this->user->performance_monitoring->expiration ) ) {
142 + return 2871763199; // fallback_test: Expires in 2060
143 + }
144 + return (int) $this->user->performance_monitoring->expiration;
145 + }
146 +
147 + /**
148 + * Checks if the addon license is active
149 + *
150 + * @param string $sku The SKU of the addon.
151 + *
152 + * @since 3.20
153 + *
154 + * @return boolean
155 + */
156 + public function is_rocket_insights_addon_active( string $sku ) {
157 + return true; // fallback_test: Always active
158 + }
159 +
160 + /**
161 + * Checks if license is on free plan.
162 + *
163 + * @param string $sku The SKU of the addon.
164 + *
165 + * @since 3.20
166 + *
167 + * @return boolean
168 + */
169 + public function is_rocket_insights_free_active( string $sku ) {
170 + return false; // fallback_test: Not free, pro active
171 + }
172 +
173 + /**
174 + * Retrieves the active SKU for the Rocket Insights Addon.
175 + *
176 + * @since 3.20
177 + *
178 + * @return string
179 + */
180 + public function get_rocket_insights_addon_sku_active(): string {
181 + return 'perf-monitor-pro'; // fallback_test: Pro SKU active
182 + }
183 +
184 + /**
185 + * Retrieves the Rocket Insights addon upgrade SKUs based on the provided SKU.
186 + *
187 + * @param string $sku The SKU for which to retrieve the upgrade data.
188 + *
189 + * @return array
190 + */
191 + public function get_rocket_insights_addon_upgrade_skus( string $sku ) {
192 + return []; // fallback_test: No upgrades
193 + }
194 +
195 + /**
196 + * Retrieves the button text for the Rocket Insights addon based on the provided SKU.
197 + *
198 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
199 + *
200 + * @return string
201 + */
202 + public function get_rocket_insights_addon_btn_text( string $sku ) {
203 + return 'Activated'; // fallback_test: Show as activated
204 + }
205 +
206 + /**
207 + * Retrieves the URL for the Rocket Insights add-on button associated with the specified SKU.
208 + *
209 + * @param string $sku The SKU identifier used to fetch.
210 + *
211 + * @return string
212 + */
213 + public function get_rocket_insights_addon_btn_url( string $sku ) {
214 + return ''; // fallback_test: No URL needed
215 + }
216 +
217 + /**
218 + * Retrieves the limit for the Rocket Insights add-on based on the provided SKU.
219 + *
220 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
221 + *
222 + * @return int
223 + */
224 + public function get_rocket_insights_addon_limit( string $sku ) {
225 + return 9999; // fallback_test: Unlimited
226 + }
227 +
228 + /**
229 + * Retrieves the subtitle for the Rocket Insights add-on based on the provided SKU.
230 + *
231 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
232 + *
233 + * @return string
234 + */
235 + public function get_rocket_insights_addon_subtitle( string $sku ) {
236 + return __( 'Unlimited performance monitoring with all features.', 'rocket' ); // fallback_test: Adapted from your description
237 + }
238 +
239 + /**
240 + * Retrieves the billing for the Rocket Insights add-on based on the provided SKU.
241 + *
242 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
243 + *
244 + * @return string
245 + */
246 + public function get_rocket_insights_addon_billing( string $sku ) {
247 + return __( '* Billed monthly. You can cancel at any time, each month started is due.', 'rocket' ); // fallback_test: Standard billing text
248 + }
249 +
250 + /**
251 + * Retrieves the highlights for the Rocket Insights add-on based on the provided SKU.
252 + *
253 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
254 + *
255 + * @return array
256 + */
257 + public function get_rocket_insights_addon_highlights( string $sku ) {
258 + return [
259 + __( 'Unlimited on-demand tests', 'rocket' ),
260 + __( 'Full GTmetrix reports', 'rocket' ),
261 + __( 'Automatic monitoring', 'rocket' ),
262 + ]; // fallback_test: Full features
263 + }
264 +
265 + /**
266 + * Checks if the Rocket Insights add-on has a promo based on the provided SKU.
267 + *
268 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
269 + *
270 + * @return bool
271 + */
272 + public function has_rocket_insights_addon_promo( string $sku ) {
273 + return false; // fallback_test: No promo
274 + }
275 +
276 + /**
277 + * Retrieves the price for the Rocket Insights add-on based on the provided SKU.
278 + *
279 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
280 + *
281 + * @return string
282 + */
283 + public function get_rocket_insights_addon_price( string $sku ) {
284 + return '0.00'; // fallback_test: Free
285 + }
286 +
287 + /**
288 + * Retrieves the promo price for the Rocket Insights add-on based on the provided SKU.
289 + *
290 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
291 + *
292 + * @return string
293 + */
294 + public function get_rocket_insights_addon_promo_price( string $sku ) {
295 + return '0.00'; // fallback_test: Free
296 + }
297 +
298 + /**
299 + * Retrieves the promo name for the Rocket Insights add-on based on the provided SKU.
300 + *
301 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
302 + *
303 + * @return string
304 + */
305 + public function get_rocket_insights_addon_promo_name( string $sku ) {
306 + return ''; // fallback_test: No promo
307 + }
308 +
309 + /**
310 + * Retrieves the promo billing for the Rocket Insights add-on based on the provided SKU.
311 + *
312 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
313 + *
314 + * @return string
315 + */
316 + public function get_rocket_insights_addon_promo_billing( string $sku ) {
317 + return ''; // fallback_test: No promo billing
318 + }
319 +
320 + /**
321 + * Retrieves the promo data for the Rocket Insights add-on based on the provided SKU.
322 + *
323 + * @param string $sku The SKU used to fetch the Rocket Insights addon data.
324 + *
325 + * @return false|object
326 + */
327 + protected function get_rocket_insights_addon_promo( string $sku ) {
328 + return false; // fallback_test: No promo
329 + }
330 +
331 + /**
332 + * Checks if the user account is from a reseller license
333 + *
334 + * @since 3.20
335 + *
336 + * @return boolean
337 + */
338 + public function is_reseller_account() {
339 + return false; // fallback_test: Not a reseller account
340 + }
341 +
342 + /**
343 + * Retrieves the Rocket Insights plan data associated with the specified SKU.
344 + *
345 + * @param string $sku The SKU identifier used to find the corresponding Rocket Insights plan.
346 + *
347 + * @return object|null
348 + */
349 + protected function get_rocket_insights_data( string $sku ) {
350 + // fallback_test: Simulate pro plan data
351 + return (object) [
352 + 'sku' => $sku,
353 + 'limit' => 9999,
354 + 'subtitle' => __( 'Unlimited performance monitoring with all features.', 'rocket' ), // Adapted: changed 'description' to 'subtitle'
355 + 'billing' => __( '* Billed monthly. You can cancel at any time, each month started is due.', 'rocket' ),
356 + 'highlights' => [ __( 'Unlimited on-demand tests', 'rocket' ), __( 'Full GTmetrix reports', 'rocket' ), __( 'Automatic monitoring', 'rocket' ) ],
357 + 'price' => '0.00',
358 + 'button' => (object) [ 'label' => 'Activated', 'url' => '' ],
359 + 'upgrades' => [],
360 + ];
361 + }
362 + }