| 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 |
public function load() { |
| 41 |
add_action( 'admin_menu', array( $this, 'register_page' ) ); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Render help tab. |
| 46 |
*/ |
| 47 |
public function render_help_tab() { |
| 48 |
$content = '<p>' . |
| 49 |
__( 'Email Log is a WordPress plugin that allows you to easily log and view all emails sent from WordPress.', 'email-log' ) . |
| 50 |
'</p>' . |
| 51 |
'<p>' . |
| 52 |
__( 'You can view the logged emails from the View Logs screen. ', 'email-log' ) . |
| 53 |
sprintf( |
| 54 |
__( 'Check the <a href="%s">documentation about the View Logs screen</a> for more details.', 'email-log' ), |
| 55 |
'https://wpemaillog.com/docs/view-logged-email/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=help&utm_content=docs-content' |
| 56 |
) . |
| 57 |
'</p>' . |
| 58 |
'<p>' . |
| 59 |
sprintf( |
| 60 |
__( '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' ), |
| 61 |
'https://wpemaillog.com/store/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=help&utm_content=store-content' |
| 62 |
) . |
| 63 |
'</p>'; |
| 64 |
|
| 65 |
$this->get_screen()->add_help_tab( |
| 66 |
array( |
| 67 |
'title' => __( 'About Plugin', 'email-log' ), |
| 68 |
'id' => 'about_tab', |
| 69 |
'content' => $content, |
| 70 |
'callback' => false, |
| 71 |
) |
| 72 |
); |
| 73 |
|
| 74 |
$this->get_screen()->set_help_sidebar( |
| 75 |
'<p><strong>' . __( 'More information', 'email-log' ) . '</strong></p>' . |
| 76 |
'<p><a href = "https://wpemaillog.com/docs/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=help&utm_content=docs">' . __( 'Documentation', 'email-log' ) . '</a></p>' . |
| 77 |
'<p><a href = "https://wpemaillog.com/support/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=help&utm_content=support">' . __( 'Support', 'email-log' ) . '</a></p>' . |
| 78 |
'<p><a href = "https://wpemaillog.com/store/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=help&utm_content=store">' . __( 'Add-ons', 'email-log' ) . '</a></p>' |
| 79 |
); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Render admin page footer. |
| 84 |
*/ |
| 85 |
protected function render_page_footer() { |
| 86 |
/** |
| 87 |
* Action to add additional content to email log admin footer. |
| 88 |
* |
| 89 |
* @since 1.8 |
| 90 |
*/ |
| 91 |
do_action( 'el_admin_footer' ); |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Return the WP_Screen object for the current page's handle. |
| 96 |
* |
| 97 |
* @return \WP_Screen Screen object. |
| 98 |
*/ |
| 99 |
public function get_screen() { |
| 100 |
if ( ! isset( $this->screen ) ) { |
| 101 |
$this->screen = \WP_Screen::get( $this->page ); |
| 102 |
} |
| 103 |
|
| 104 |
return $this->screen; |
| 105 |
} |
| 106 |
} |
| 107 |
|