PluginProbe
Boxzilla – WordPress Popup Builder / 3.1.3
Boxzilla – WordPress Popup Builder v3.1.3
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 +17 -19 3.4.33.1.3 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2
3 3 namespace Boxzilla\Licensing;
4 4
5 -class Poller
6 -{
5 +class Poller {
6 +
7 7 /**
8 8 * @var API
9 9 */
10 10 protected $api;
@@ -19,11 +19,10 @@
19 19 *
20 20 * @param API $api
21 21 * @param License $license
22 22 */
23 - public function __construct(API $api, License $license)
24 - {
25 - $this->api = $api;
23 + public function __construct( API $api, License $license ) {
24 + $this->api = $api;
26 25 $this->license = $license;
27 26 }
28 27
29 28 /**
@@ -28,24 +27,22 @@
28 27
29 28 /**
30 29 * Add hooks.
31 30 */
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 - }
31 + public function hook() {
32 + if( ! wp_next_scheduled( 'boxzilla_check_license_status' ) ) {
33 + wp_schedule_event( time(), 'daily', 'boxzilla_check_license_status' );
34 + };
37 35
38 - add_action('boxzilla_check_license_status', [ $this, 'run' ]);
36 + add_action( 'boxzilla_check_license_status', array( $this, 'run' ) );
39 37 }
40 38
41 39 /**
42 40 * Run!
43 41 */
44 - public function run()
45 - {
42 + public function run() {
46 43 // don't run if license not active
47 - if (! $this->license->activated) {
44 + if( ! $this->license->activated ) {
48 45 return;
49 46 }
50 47
51 48 // assume valid by default, in case of server errors on our side.
@@ -51,19 +48,20 @@
51 48 // assume valid by default, in case of server errors on our side.
52 49 $license_still_valid = true;
53 50
54 51 try {
55 - $remote_license = $this->api->get_license();
52 + $remote_license = $this->api->get_license();
56 53 $license_still_valid = $remote_license->valid;
57 - } catch (API_Exception $e) {
54 + } catch( API_Exception $e ) {
58 55 // license key wasn't found or expired
59 - if (in_array($e->getApiCode(), [ 'license_invalid', 'license_expired' ], true)) {
56 + if( in_array( $e->getApiCode(), array( 'license_invalid', 'license_expired' ) ) ) {
60 57 $license_still_valid = false;
61 58 }
62 59 }
63 60
64 - if (! $license_still_valid) {
61 + if( ! $license_still_valid ) {
65 62 $this->license->activated = false;
66 63 $this->license->save();
67 64 }
65 +
68 66 }
69 -}
67 +}