PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.5
Pods – Custom Content Types and Fields v2.8.23.5
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 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.3.8 3.3.9
pods / tribe-common / src / Tribe / Promoter / PUE.php
pods / tribe-common / src / Tribe / Promoter Last commit date
Auth.php 1 week ago Connector.php 1 week ago PUE.php 1 week ago View.php 1 week ago
PUE.php
97 lines
1 <?php
2
3 /**
4 * Class Tribe__Promoter__PUE
5 *
6 * @since 4.9
7 */
8 class Tribe__Promoter__PUE {
9
10 /**
11 * @var string
12 */
13 private $slug = 'promoter';
14
15 /**
16 * @var Tribe__PUE__Checker
17 */
18 private $pue_checker;
19
20 /**
21 * Setup the PUE Checker.
22 *
23 * @since 4.9
24 */
25 public function load() {
26 $this->pue_checker = new Tribe__PUE__Checker( 'http://tri.be/', $this->slug, [
27 'context' => 'service',
28 'plugin_name' => __( 'Promoter', 'tribe-common' ),
29 ] );
30 }
31
32 /**
33 * Get whether service has a license and if the license is activated on network.
34 *
35 * @return array|false License information or false if not set.
36 *
37 * @since 4.9
38 */
39 public function get_license_info() {
40 $option_name = 'pue_install_key_' . $this->slug;
41
42 $key = get_option( $option_name );
43
44 $is_network_key = false;
45
46 if ( is_multisite() ) {
47 $network_key = get_network_option( null, $option_name );
48
49 if ( empty( $key ) ) {
50 $key = $network_key;
51
52 $is_network_key = true;
53 }
54 }
55
56 if ( empty( $key ) ) {
57 return false;
58 }
59
60 return [
61 'key' => $key,
62 'is_network_key' => $is_network_key,
63 ];
64 }
65
66 /**
67 * Check whether service has a license key set or not.
68 *
69 * @return bool Whether service has a license key set.
70 *
71 * @since 4.9
72 */
73 public function has_license_key() {
74 return ! empty( $this->get_license_info() );
75 }
76
77 /**
78 * Check whether service has a valid license key or not.
79 *
80 * @return bool Whether service has a valid license key.
81 *
82 * @since 4.9
83 */
84 public function has_valid_license() {
85 $license_info = $this->get_license_info();
86
87 if ( ! $license_info ) {
88 return false;
89 }
90
91 $response = $this->pue_checker->validate_key( $license_info['key'], $license_info['is_network_key'] );
92
93 return isset( $response['status'] ) && 1 === (int) $response['status'];
94 }
95
96 }
97