PluginProbe
Boxzilla – WordPress Popup Builder / 3.2.21
Boxzilla – WordPress Popup Builder v3.2.21
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
← All changes | src/licensing/class-poller.php +54 -56 3.4.3 → 3.2.21 View file →
@@ -1,69 +1,67 @@
1 1 <?php
2 2
3 3 namespace Boxzilla\Licensing;
4 4
5 -class Poller
6 -{
7 - /**
8 - * @var API
9 - */
10 - protected $api;
5 +class Poller {
11 6
12 - /**
13 - * @var License
14 - */
15 - protected $license;
16 7
17 - /**
18 - * Poller constructor.
19 - *
20 - * @param API $api
21 - * @param License $license
22 - */
23 - public function __construct(API $api, License $license)
24 - {
25 - $this->api = $api;
26 - $this->license = $license;
27 - }
8 + /**
9 + * @var API
10 + */
11 + protected $api;
28 12
29 - /**
30 - * Add hooks.
31 - */
32 - public function init()
33 - {
34 - if (! wp_next_scheduled('boxzilla_check_license_status')) {
35 - wp_schedule_event(time(), 'daily', 'boxzilla_check_license_status');
36 - }
13 + /**
14 + * @var License
15 + */
16 + protected $license;
37 17
38 - add_action('boxzilla_check_license_status', [ $this, 'run' ]);
39 - }
18 + /**
19 + * Poller constructor.
20 + *
21 + * @param API $api
22 + * @param License $license
23 + */
24 + public function __construct( API $api, License $license ) {
25 + $this->api = $api;
26 + $this->license = $license;
27 + }
40 28
41 - /**
42 - * Run!
43 - */
44 - public function run()
45 - {
46 - // don't run if license not active
47 - if (! $this->license->activated) {
48 - return;
49 - }
29 + /**
30 + * Add hooks.
31 + */
32 + public function init() {
33 + if ( ! wp_next_scheduled( 'boxzilla_check_license_status' ) ) {
34 + wp_schedule_event( time(), 'daily', 'boxzilla_check_license_status' );
35 + }
50 36
51 - // assume valid by default, in case of server errors on our side.
52 - $license_still_valid = true;
37 + add_action( 'boxzilla_check_license_status', array( $this, 'run' ) );
38 + }
53 39
54 - try {
55 - $remote_license = $this->api->get_license();
56 - $license_still_valid = $remote_license->valid;
57 - } catch (API_Exception $e) {
58 - // license key wasn't found or expired
59 - if (in_array($e->getApiCode(), [ 'license_invalid', 'license_expired' ], true)) {
60 - $license_still_valid = false;
61 - }
62 - }
40 + /**
41 + * Run!
42 + */
43 + public function run() {
44 + // don't run if license not active
45 + if ( ! $this->license->activated ) {
46 + return;
47 + }
63 48
64 - if (! $license_still_valid) {
65 - $this->license->activated = false;
66 - $this->license->save();
67 - }
68 - }
49 + // assume valid by default, in case of server errors on our side.
50 + $license_still_valid = true;
51 +
52 + try {
53 + $remote_license = $this->api->get_license();
54 + $license_still_valid = $remote_license->valid;
55 + } catch ( API_Exception $e ) {
56 + // license key wasn't found or expired
57 + if ( in_array( $e->getApiCode(), array( 'license_invalid', 'license_expired' ), true ) ) {
58 + $license_still_valid = false;
59 + }
60 + }
61 +
62 + if ( ! $license_still_valid ) {
63 + $this->license->activated = false;
64 + $this->license->save();
65 + }
66 + }
69 67 }