Completed
Push — dev/2.3.0 ( 7ef92d...92929a )
by Sudar
30:39 queued 27:56
created

EmailLogSystemInfo::print_email_log_config()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 18
nc 4
nop 0
dl 0
loc 16
ccs 0
cts 2
cp 0
crap 30
rs 9.3554
c 0
b 0
f 0
1
<?php
2
3
namespace EmailLog\Core\UI\Component;
4
5
use EmailLog\Core\DB\TableManager;
6
7
/**
8
 * Email Log System Info.
9
 *
10
 * @see \EmailLog\Core\UI\Component\SystemInfo
11
 * @since 2.3.0
12
 */
13
class EmailLogSystemInfo extends SystemInfo {
14
15
	/**
16
	 * Setup hooks and filters.
17
	 */
18
	public function load() {
19
		add_action( 'system_info_before', array( $this, 'print_email_log_config' ), 10, 2 );
20
	}
21
22
	/**
23
	 * ##RefactorMe
24
	 * Dummy method which should return license key or keys based on license type.
25
	 *
26
	 * @return string
27
	 */
28
	public function get_license_key(){
29
		return '';
30
	}
31
32
	public function print_email_log_config() {
33
		$email_log = email_log();
34
		?>
35
-- Email Log Configuration
36
37
Email Log Version:                  <?php echo $this->get_plugin_version() . "\n"; ?>
38
Number of Logs:                     <?php echo $email_log->table_manager->get_logs_count() . "\n"; ?>
39
Email Log DB Version:               <?php echo get_option( TableManager::DB_OPTION_NAME ) . "\n"; ?>
0 ignored issues
show
Bug introduced by
Are you sure get_option(EmailLog\Core...anager::DB_OPTION_NAME) of type mixed|false can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
Email Log DB Version:               <?php echo /** @scrutinizer ignore-type */ get_option( TableManager::DB_OPTION_NAME ) . "\n"; ?>
Loading history...
40
<?php if ( $this->get_license_key() === '' ) : ?>
41
License Key:                        <?php echo $this->get_license_key() . "\n"; ?>
42
<?php endif; ?>
43
<?php $email_log_core = get_option('email-log-core'); ?>
44
<?php if ( $email_log_core ) : ?>
45
Allowed Roles for Email Log View:   <?php echo implode( ', ', $email_log_core['allowed_user_roles'] ) . "\n"; ?>
46
Remove All Data on Uninstallation:  <?php echo $email_log_core['remove_on_uninstall'] !== '' ? 'Yes' : 'No' . "\n"; ?>
47
Disable Dash Board Widget:          <?php echo $email_log_core['hide_dashboard_widget'] === 'true' ? 'Yes' : 'No' . "\n"; ?>
48
<?php endif; ?>
49
<?php
50
	}
51
52
	protected function get_default_config() {
53
		$config = parent::get_default_config();
54
55
		$config['show_posts']      = false;
56
		$config['show_taxonomies'] = false;
57
58
		return $config;
59
	}
60
61
	protected function get_plugin_version() {
62
		$plugin_path = WP_PLUGIN_DIR . '/email-log/email-log.php';
63
		$plugin_data = get_plugin_data( $plugin_path );
64
65
		return $plugin_data['Version'];
66
	}
67
}
68