Completed
Push — master ( 63ebd4...be4f05 )
by Sudar
02:34
created

DashboardWidget::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 17
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
1
<?php namespace EmailLog\Core\UI\Component;
2
3
use EmailLog\Core\Loadie;
4
5
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
6
7
/*
8
 * Widget that displays email log information in dashboard.
9
 *
10
 * @since 2.2.0
11
 */
12
class DashboardWidget implements Loadie {
13
14
	/**
15
	 * Setup hooks.
16
	 *
17
	 * @inheritdoc
18
	 */
19
	public function load() {
20
		add_action( 'wp_dashboard_setup', array( $this, 'register' ) );
21
	}
22
23
	/**
24
	 * Adds the dashboard widget to display Email Log activity.
25
	 */
26
	public function register() {
27
		wp_add_dashboard_widget(
28
			'email_log_dashboard_widget',
29
			__( 'Email Logs Summary', 'email-log' ),
30
			array( $this, 'render' )
31
		);
32
	}
33
34
	/**
35
	 * Outputs the contents on the Dashboard Widget.
36
	 */
37
	public function render() {
38
		$email_log  = email_log();
39
		$logs_count = $email_log->table_manager->get_logs_count();
40
		?>
41
42
		<p>
43
			<?php _e( 'Total number of emails logged' , 'email-log' ); ?>: <strong><?php echo absint( $logs_count ); ?></strong>
44
		</p>
45
46
		<ul class="subsubsub" style="float: none">
47
			<li><?php printf( __( '<a href="%s">Email Logs</a>', 'email-log' ), 'admin.php?page=email-log' ); ?> <span style="color: #ddd"> | </span></li>
48
			<li><?php printf( __( '<a href="%s">Settings</a>', 'email-log' ), 'admin.php?page=email-log-settings' ); ?> <span style="color: #ddd"> | </span></li>
49
			<li><?php printf( __( '<a href="%s">Addons</a>', 'email-log' ), 'admin.php?page=email-log-addons' ); ?></li>
50
		</ul>
51
52
		<?php
53
	}
54
}
55