|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EmailLog\Core\UI\Component; |
|
4
|
|
|
|
|
5
|
|
|
use EmailLog\Core\DB\TableManager; |
|
6
|
|
|
use EmailLog\Core\EmailLog; |
|
7
|
|
|
use Sudar\WPSystemInfo\SystemInfo; |
|
8
|
|
|
|
|
9
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Email Log System Info. |
|
13
|
|
|
* |
|
14
|
|
|
* Uses the WPSystemInfo library. |
|
15
|
|
|
* |
|
16
|
|
|
* @since 2.3.0 |
|
17
|
|
|
* @link https://github.com/sudar/wp-system-info |
|
18
|
|
|
*/ |
|
19
|
|
|
class EmailLogSystemInfo extends SystemInfo { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Setup hooks and filters. |
|
23
|
|
|
*/ |
|
24
|
|
|
public function load() { |
|
25
|
|
|
add_action( 'before_system_info_for_email-log', array( $this, 'print_email_log_details' ) ); |
|
26
|
|
|
add_action( 'before_system_info_for_email-log', array( $this, 'print_email_log_license_details' ) ); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Print details about Email Log. |
|
31
|
|
|
* |
|
32
|
|
|
* PHPCS is disabled for this function since alignment will mess up the system info output. |
|
33
|
|
|
* phpcs:disable |
|
34
|
|
|
*/ |
|
35
|
|
|
public function print_email_log_details() { |
|
36
|
|
|
$email_log = email_log(); |
|
37
|
|
|
|
|
38
|
|
|
$email_log_core = get_option( 'email-log-core' ); |
|
39
|
|
|
?> |
|
40
|
|
|
-- Email Log Configuration -- |
|
41
|
|
|
|
|
42
|
|
|
Email Log Version: <?php echo EmailLog::VERSION . "\n"; ?> |
|
43
|
|
|
Number of Logs: <?php echo $email_log->table_manager->get_logs_count() . "\n"; ?> |
|
44
|
|
|
Email Log DB Version: <?php echo get_option( TableManager::DB_OPTION_NAME ) . "\n"; ?> |
|
|
|
|
|
|
45
|
|
|
<?php if ( is_array( $email_log_core ) ) : ?> |
|
46
|
|
|
Additional allowed user roles: <?php echo implode( ', ', $email_log_core['allowed_user_roles'] ) . "\n"; ?> |
|
47
|
|
|
Remove All Data on Uninstallation: <?php echo $email_log_core['remove_on_uninstall'] !== '' ? 'Yes' : 'No' . "\n"; ?> |
|
48
|
|
|
Disable DashBoard Widget: <?php echo $email_log_core['hide_dashboard_widget'] === 'true' ? 'Yes' : 'No' . "\n"; ?> |
|
49
|
|
|
<?php endif; ?> |
|
50
|
|
|
|
|
51
|
|
|
<?php |
|
52
|
|
|
} |
|
53
|
|
|
// phpcs:enable |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Print details about Email Log Licenses. |
|
57
|
|
|
*/ |
|
58
|
|
|
public function print_email_log_license_details() { |
|
59
|
|
|
$bundle_license = $this->get_bundle_license(); |
|
60
|
|
|
|
|
61
|
|
|
if ( ! is_null( $bundle_license ) ) { |
|
62
|
|
|
$this->print_bundle_license_details( $bundle_license ); |
|
63
|
|
|
} else { |
|
64
|
|
|
$this->print_individual_addon_license(); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Get Bundle license. |
|
70
|
|
|
* |
|
71
|
|
|
* @return \EmailLog\Addon\License\BundleLicense|null Bundle license or null if no bundle license. |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function get_bundle_license() { |
|
74
|
|
|
$email_log = email_log(); |
|
75
|
|
|
|
|
76
|
|
|
$licenser = $email_log->get_licenser(); |
|
77
|
|
|
$bundle_license = $licenser->get_bundle_license(); |
|
78
|
|
|
|
|
79
|
|
|
$bundle_license_key = $bundle_license->get_license_key(); |
|
80
|
|
|
if ( ! empty( $bundle_license_key ) ) { |
|
81
|
|
|
return $bundle_license; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return null; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Print bundle license details. |
|
89
|
|
|
* |
|
90
|
|
|
* @param \EmailLog\Addon\License\BundleLicense $bundle_license Bundle license. |
|
91
|
|
|
* |
|
92
|
|
|
* PHPCS is disabled for this function since alignment will mess up the system info output. |
|
93
|
|
|
* phpcs:disable |
|
94
|
|
|
*/ |
|
95
|
|
|
protected function print_bundle_license_details( $bundle_license ) { |
|
96
|
|
|
?> |
|
97
|
|
|
-- Email Log Bundle License -- |
|
98
|
|
|
|
|
99
|
|
|
License Key: <?php echo $bundle_license->get_license_key(), "\n"; ?> |
|
100
|
|
|
License Expiry Date: <?php echo $bundle_license->get_expiry_date(), "\n"; ?> |
|
|
|
|
|
|
101
|
|
|
<?php if ( $bundle_license->is_valid() ) : ?> |
|
102
|
|
|
License Valid: <?php echo 'Yes', "\n"; ?> |
|
103
|
|
|
<?php else : ?> |
|
104
|
|
|
License Valid: <?php echo 'No', "\n"; ?> |
|
105
|
|
|
<?php endif; ?> |
|
106
|
|
|
|
|
107
|
|
|
<?php |
|
108
|
|
|
} |
|
109
|
|
|
// phpcs:enable |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Print license details of individual add-ons. |
|
113
|
|
|
* |
|
114
|
|
|
* PHPCS is disabled for this function since alignment will mess up the system info output. |
|
115
|
|
|
* phpcs:disable |
|
116
|
|
|
*/ |
|
117
|
|
|
protected function print_individual_addon_license() { |
|
118
|
|
|
$email_log = email_log(); |
|
119
|
|
|
|
|
120
|
|
|
$licenser = $email_log->get_licenser(); |
|
121
|
|
|
$addons = $licenser->get_addon_list()->get_addons(); |
|
122
|
|
|
?> |
|
123
|
|
|
-- Email Log Addon License -- |
|
124
|
|
|
|
|
125
|
|
|
<?php |
|
126
|
|
|
foreach ( $addons as $addon ) { |
|
127
|
|
|
echo '- ', $addon->name; |
|
128
|
|
|
|
|
129
|
|
|
$license_key = $addon->get_addon_license_key(); |
|
130
|
|
|
|
|
131
|
|
|
if ( ! empty( $license_key ) ) { |
|
132
|
|
|
$addon_license = $addon->get_license(); |
|
133
|
|
|
echo ' (', $license_key, ' - ', $addon_license->get_expiry_date(), ')'; |
|
|
|
|
|
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
echo "\n"; |
|
137
|
|
|
} |
|
138
|
|
|
echo "\n"; |
|
139
|
|
|
} |
|
140
|
|
|
// phpcs:enable |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Change the default config. |
|
144
|
|
|
* |
|
145
|
|
|
* @return array Modified config. |
|
146
|
|
|
*/ |
|
147
|
|
|
protected function get_default_config() { |
|
148
|
|
|
$config = parent::get_default_config(); |
|
149
|
|
|
|
|
150
|
|
|
$config['show_posts'] = false; |
|
151
|
|
|
$config['show_taxonomies'] = false; |
|
152
|
|
|
$config['show_users'] = false; |
|
153
|
|
|
|
|
154
|
|
|
return $config; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|