Completed
Push — master ( af9dd6...3b08d7 )
by Sudar
02:01
created

BasePage::render_page_footer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 3
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php namespace EmailLog\Core\UI\Page;
2
3
use EmailLog\Core\Loadie;
4
5
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
6
7
/**
8
 * Base class for all Email Log admin pages.
9
 *
10
 * @since 2.0.0
11
 */
12
abstract class BasePage implements Loadie {
13
14
	/**
15
	 * Current page.
16
	 *
17
	 * @var string
18
	 */
19
	protected $page;
20
21
	/**
22
	 * Current screen.
23
	 *
24
	 * @var \WP_Screen
25
	 */
26
	protected $screen;
27
28
	/**
29
	 * Register page.
30
	 *
31
	 * @return void
32
	 */
33
	abstract public function register_page();
34
35
	/**
36
	 * Setup hooks related to pages.
37
	 *
38
	 * @inheritdoc
39
	 */
40 1
	public function load() {
41 1
		add_action( 'admin_menu', array( $this, 'register_page' ) );
42 1
	}
43
44
	/**
45
	 * Render help tab.
46
	 *
47
	 * TODO: Change links used in this function.
48
	 */
49
	public function render_help_tab() {
50
		$content = '<p>' .
51
					__( 'Email Log is a WordPress plugin that allows you to easily log and view all emails sent from WordPress.', 'email-log' ) .
52
				'</p>' .
53
				'<p>' .
54
					__( 'You can view the logged emails from the View Logs screen.', 'email-log' ) .
55
					sprintf( __( 'Check the <a href="%s">documentation about the View Logs screen</a> for more details.', 'email-log' ), 'https://wpemaillog.com/docs/view-logged-email/' ) .
56
				'</p>' .
57
				'<p>' .
58
					sprintf( __( 'You can perform advanced actions like re-sending email, automatically forwarding emails or export logs with our <a href="%s">premium plugins</a>.', 'email-log' ), 'https://wpemaillog.com/store/' ) .
59
				'</p>';
60
61
		$this->get_screen()->add_help_tab(
62
			array(
63
				'title'    => __( 'About Plugin', 'email-log' ),
64
				'id'       => 'about_tab',
65
				'content'  => $content,
66
				'callback' => false,
67
			)
68
		);
69
70
		$this->get_screen()->set_help_sidebar(
71
			'<p><strong>' . __( 'More information', 'email-log' ) . '</strong></p>' .
72
			'<p><a href = "https://wpemaillog.com/docs/">' . __( 'Documentation', 'email-log' ) . '</a></p>' .
73
			'<p><a href = "https://wpemaillog.com/support/">' . __( 'Support', 'email-log' ) . '</a></p>' .
74
			'<p><a href = "https://wpemaillog.com/store/">' . __( 'Add-ons', 'email-log' ) . '</a></p>'
75
		);
76
	}
77
78
	/**
79
	 * Render admin page footer.
80
	 */
81
	protected function render_page_footer() {
82
		/**
83
		 * Action to add additional content to email log admin footer.
84
		 *
85
		 * @since 1.8
86
		 */
87
		do_action( 'el_admin_footer' );
88
	}
89
90
	/**
91
	 * Return the WP_Screen object for the current page's handle.
92
	 *
93
	 * @return \WP_Screen Screen object.
94
	 */
95
	public function get_screen() {
96
		if ( ! isset( $this->screen ) ) {
97
			$this->screen = \WP_Screen::get( $this->page );
98
		}
99
100
		return $this->screen;
101
	}
102
}
103