PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 4.0.0
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v4.0.0
4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / admin / controllers / class-license-resolve-controller.php
superb-blocks / src / admin / controllers Last commit date
wizard 1 month ago class-dashboard-controller.php 1 month ago class-license-resolve-controller.php 1 month ago class-newsletter-signup-controller.php 1 month ago class-notice-controller.php 1 month ago class-plugin-reset-controller.php 1 month ago class-rewrite-check-controller.php 1 month ago class-settings-controller.php 1 month ago class-troubleshooting-controller.php 1 month ago
class-license-resolve-controller.php
76 lines
1 <?php
2
3 namespace SuperbAddons\Admin\Controllers;
4
5 defined('ABSPATH') || exit();
6
7 use Exception;
8 use SuperbAddons\Data\Controllers\KeyController;
9 use SuperbAddons\Data\Controllers\LogController;
10
11 class LicenseResolveController
12 {
13 const COOLDOWN_TRANSIENT = 'spbaddons_license_resolve_cooldown';
14 const COOLDOWN_DURATION = DAY_IN_SECONDS;
15
16 private static $attempted = false;
17
18 /**
19 * Hook into admin_init. Called once during plugin bootstrap.
20 */
21 public static function Initialize()
22 {
23 add_action('admin_init', array(__CLASS__, 'MaybeAutoResolve'));
24 }
25
26 /**
27 * Attempt automatic license resolution if a registered key has an issue
28 * and the cooldown period has elapsed.
29 */
30 public static function MaybeAutoResolve()
31 {
32 if (self::$attempted) {
33 return;
34 }
35 self::$attempted = true;
36
37 if (defined('DOING_AJAX') && DOING_AJAX) {
38 return;
39 }
40 if (defined('DOING_CRON') && DOING_CRON) {
41 return;
42 }
43
44 if (!KeyController::HasRegisteredKey()) {
45 return;
46 }
47 if (KeyController::HasValidKey()) {
48 return;
49 }
50
51 if (get_transient(self::COOLDOWN_TRANSIENT)) {
52 return;
53 }
54
55 set_transient(self::COOLDOWN_TRANSIENT, 1, self::COOLDOWN_DURATION);
56
57 try {
58 KeyController::GetUpdatedLicenseKeyInformation();
59 if (KeyController::HasValidKey()) {
60 LogController::LogInfo('License issue resolved automatically');
61 }
62 } catch (Exception $ex) {
63 LogController::HandleException($ex);
64 }
65 }
66
67 /**
68 * Clear the cooldown transient.
69 * Called when a key is manually registered or removed.
70 */
71 public static function ClearCooldown()
72 {
73 delete_transient(self::COOLDOWN_TRANSIENT);
74 }
75 }
76