license.php
2.61 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Block Lab settings form for the License tab.
*
* @package Block_Lab
* @copyright Copyright(c) 2020, Block Lab
* @license http://opensource.org/licenses/GPL-2.0 GNU General Public License, version 2 (GPL-2.0)
*/
?>
<form method="post" action="options.php">
<?php
settings_fields( 'block-lab-license-key' );
do_settings_sections( 'block-lab-license-key' );
?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<label><?php esc_html_e( 'License', 'block-lab' ); ?></label>
</th>
<td>
<?php
if ( block_lab()->is_pro() ) {
$license = block_lab()->admin->license->get_license();
$limit = __( 'unlimited', 'block-lab' );
if ( isset( $license['license_limit'] ) && intval( $license['license_limit'] ) > 0 ) {
$limit = $license['license_limit'];
}
$count = '0';
if ( isset( $license['site_count'] ) ) {
$count = $license['site_count'];
}
$expiry = gmdate( get_option( 'date_format' ) );
if ( isset( $license['expires'] ) ) {
$expiry = gmdate( get_option( 'date_format' ), strtotime( $license['expires'] ) );
}
echo wp_kses_post(
sprintf(
'<p>%1$s %2$s</p>',
sprintf(
// translators: A number, wrapped in <strong> tags.
__( 'Your license includes %1$s site installs.', 'block-lab' ),
'<strong>' . $limit . '</strong>'
),
sprintf(
// translators: A number, wrapped in <strong> tags.
__( '%1$s of them are in use.', 'block-lab' ),
'<strong>' . $count . '</strong>'
)
)
);
echo wp_kses_post(
sprintf(
'<p>%1$s %2$s</p>',
sprintf(
// translators: A date.
__( 'Your license expires on %1$s.', 'block-lab' ),
'<strong>' . $expiry . '</strong>'
),
sprintf(
// translators: An opening and closing anchor tag.
__( '%1$sManage Licenses%2$s', 'block-lab' ),
'<a href="https://getblocklab.com/checkout/purchase-history/" target="_blank">',
'</a>'
)
)
);
} else {
echo wp_kses_post(
sprintf(
'<p>%1$s</p>',
__( 'No license was found for this installation.', 'block-lab' )
)
);
}
?>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="block_lab_license_key"><?php esc_html_e( 'License key', 'block-lab' ); ?></label>
</th>
<td>
<input type="password" name="block_lab_license_key" id="block_lab_license_key" class="regular-text" value="<?php echo esc_attr( get_option( 'block_lab_license_key' ) ); ?>" />
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>