Completed
Push — dev/2.2.0 ( 462e0b...6ae4e4 )
by Sudar
01:38
created

DashboardWidget   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 3 1
A register() 0 7 1
A render() 0 15 1
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
		<p>
47
			<?php printf( __( '<a href="%s">Click here</a> to view Email Logs.', 'email-log' ), 'admin.php?page=email-log' ); ?>
48
		</p>
49
50
		<?php
51
	}
52
}
53