LicenseNetworkMessage.php
1.48 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
<?php
namespace ACP\Admin\Section;
use AC;
use AC\View;
use ACP;
use ACP\LicenseKeyRepository;
use ACP\LicenseRepository;
class LicenseNetworkMessage extends AC\Admin\Section {
const NAME = 'license-network-message';
/**
* @var LicenseKeyRepository
*/
private $license_key_repository;
/**
* @var LicenseRepository
*/
private $license_repository;
public function __construct( LicenseKeyRepository $license_key_repository, LicenseRepository $license_repository ) {
parent::__construct( self::NAME );
$this->license_key_repository = $license_key_repository;
$this->license_repository = $license_repository;
}
/**
* @return string
*/
private function render_network_message() {
return ( new AC\View() )->set_template( 'admin/section-license-network-message' )->render();
}
private function is_license_active() {
$key = $this->license_key_repository->find();
return $key
? $this->license_repository->find( $key )
: null;
}
public function render() {
$view = new View( [
'title' => __( 'Updates', 'codepress-admin-columns' ),
'description' => ! $this->is_license_active() ? sprintf( '%s %s', ac_helper()->icon->dashicon( [ 'icon' => 'info-outline', 'class' => 'orange' ] ), __( 'Enter your license code to receive automatic updates.', 'codepress-admin-columns' ) ) : null,
'content' => $this->render_network_message(),
'class' => 'general',
] );
$view->set_template( 'admin/page/settings-section' );
return $view->render();
}
}