Completed
Pull Request — master (#83)
by Maria Daniel Deepak
01:41
created

BasePage::get_screen()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 6
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
		/**
51
		 * Content specified inline
52
		 */
53
		$this->get_screen()->add_help_tab(
54
			array(
55
				'title'    => __( 'About Plugin', 'email-log' ),
56
				'id'       => 'about_tab',
57
				'content'  => '<p>' . __( 'Email Log WordPress Plugin, allows you to log all emails that are sent through WordPress.', 'email-log' ) . '</p>',
58
				'callback' => false,
59
			)
60
		);
61
62
		// Add help sidebar.
63
		// TODO: Change the links.
64
		$this->get_screen()->set_help_sidebar(
65
			'<p><strong>' . __( 'More information', 'email-log' ) . '</strong></p>' .
66
			'<p><a href = "https://wpemaillog.com">' . __( 'Plugin Homepage', 'email-log' ) . '</a></p>' .
67
			'<p><a href = "https://wpemaillog.com/support">' . __( 'Plugin support', 'email-log' ) . '</a></p>' .
68
			'<p><a href = "http://sudarmuthu.com/blog">' . __( "Plugin author's blog", 'email-log' ) . '</a></p>' .
69
			'<p><a href = "http://sudarmuthu.com/wordpress/">' . __( "Other Plugin's by Author", 'email-log' ) . '</a></p>'
70
		);
71
	}
72
73
	/**
74
	 * Render admin page footer.
75
	 */
76
	protected function render_page_footer() {
77
		/**
78
		 * Action to add additional content to email log admin footer.
79
		 *
80
		 * @since 1.8
81
		 */
82
		do_action( 'el_admin_footer' );
83
	}
84
85
	/**
86
	 * Return the WP_Screen object for the current page's handle.
87
	 *
88
	 * @return \WP_Screen Screen object.
89
	 */
90
	public function get_screen() {
91
		if ( ! isset( $this->screen ) ) {
92
			$this->screen = \WP_Screen::get( $this->page );
93
		}
94
95
		return $this->screen;
96
	}
97
}
98