license.php
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace LearnDash\Hub\Traits;
trait License {
/**
* The option name for license key
*
* @return string
*/
public function get_license_key_option_name() {
return 'nss_plugin_license_sfwd_lms';
}
/**
* The option name for license email.
* @return string
*/
public function get_hub_email_option_name() {
return 'nss_plugin_license_email_sfwd_lms';
}
/**
* Get the license key
*
* @return false|string
*/
public function get_license_key() {
return get_site_option( $this->get_license_key_option_name() );
}
/**
* Get the register email.
*
* @return false|string
*/
public function get_hub_email() {
return get_site_option( $this->get_hub_email_option_name() );
}
/**
* Return the headers that require for API side.
*
* @return array
*/
public function get_auth_headers(): array {
return array(
'Learndash-Site-Url' => network_site_url(),
'Learndash-Hub-License-Key' => $this->get_license_key(),
'Learndash-Hub-Email' => $this->get_hub_email(),
);
}
/**
* Check if the current site is signed on.
*
* @return bool
*/
public function is_signed_on(): bool {
if ( $this->get_hub_email() && $this->get_license_key() ) {
return true;
}
return false;
}
/**
* Clear signed data.
*/
public function clear_auth() {
delete_site_option( $this->get_license_key_option_name() );
delete_site_option( $this->get_hub_email_option_name() );
delete_site_option( 'learndash_hub_secret' );
}
}