DebugEvents
6 days ago
EmailSendingErrors
6 days ago
Pages
6 days ago
Recommendations
6 days ago
AdminBarMenu.php
6 days ago
Area.php
6 days ago
ConnectionSettings.php
6 days ago
DashboardWidget.php
6 days ago
DomainChecker.php
6 days ago
Education.php
6 days ago
FlyoutMenu.php
6 days ago
Notifications.php
6 days ago
PageAbstract.php
6 days ago
PageInterface.php
6 days ago
ParentPageAbstract.php
6 days ago
PluginsInstallSkin.php
6 days ago
Review.php
6 days ago
SetupWizard.php
6 days ago
WooCommerceActiveLayerEducation.php
6 days ago
PageAbstract.php
209 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPMailSMTP\Admin; |
| 4 | |
| 5 | use WPMailSMTP\WP; |
| 6 | |
| 7 | /** |
| 8 | * Class PageAbstract. |
| 9 | * |
| 10 | * @since 1.0.0 |
| 11 | */ |
| 12 | abstract class PageAbstract implements PageInterface { |
| 13 | |
| 14 | /** |
| 15 | * @var string Slug of a tab. |
| 16 | */ |
| 17 | protected $slug; |
| 18 | |
| 19 | /** |
| 20 | * Tab priority. |
| 21 | * |
| 22 | * @since 2.8.0 |
| 23 | * |
| 24 | * @var int |
| 25 | */ |
| 26 | protected $priority = 999; |
| 27 | |
| 28 | /** |
| 29 | * Tab parent page. |
| 30 | * |
| 31 | * @since 2.8.0 |
| 32 | * |
| 33 | * @var ParentPageAbstract |
| 34 | */ |
| 35 | protected $parent_page = null; |
| 36 | |
| 37 | /** |
| 38 | * Constructor. |
| 39 | * |
| 40 | * @since 2.8.0 |
| 41 | * |
| 42 | * @param ParentPageAbstract $parent_page Tab parent page. |
| 43 | */ |
| 44 | public function __construct( $parent_page = null ) { |
| 45 | |
| 46 | $this->parent_page = $parent_page; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @inheritdoc |
| 51 | */ |
| 52 | public function get_link() { |
| 53 | |
| 54 | $page = Area::SLUG; |
| 55 | |
| 56 | if ( $this->parent_page !== null ) { |
| 57 | $page .= '-' . $this->parent_page->get_slug(); |
| 58 | } |
| 59 | |
| 60 | return add_query_arg( |
| 61 | 'tab', |
| 62 | $this->slug, |
| 63 | WP::admin_url( 'admin.php?page=' . $page ) |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Title of a tab. |
| 69 | * |
| 70 | * @since 3.7.0 |
| 71 | * |
| 72 | * @return string |
| 73 | */ |
| 74 | public function get_title() { |
| 75 | |
| 76 | return $this->get_label(); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Get tab slug. |
| 81 | * |
| 82 | * @since 2.8.0 |
| 83 | * |
| 84 | * @return string |
| 85 | */ |
| 86 | public function get_slug() { |
| 87 | |
| 88 | return $this->slug; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Get tab priority. |
| 93 | * |
| 94 | * @since 2.8.0 |
| 95 | * |
| 96 | * @return int |
| 97 | */ |
| 98 | public function get_priority() { |
| 99 | |
| 100 | return $this->priority; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Get parent page. |
| 105 | * |
| 106 | * @since 2.8.0 |
| 107 | * |
| 108 | * @return ParentPageAbstract |
| 109 | */ |
| 110 | public function get_parent_page() { |
| 111 | |
| 112 | return $this->parent_page; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Get parent page slug. |
| 117 | * |
| 118 | * @since 3.0.0 |
| 119 | * |
| 120 | * @return string |
| 121 | */ |
| 122 | public function get_parent_slug() { |
| 123 | |
| 124 | if ( is_null( $this->parent_page ) ) { |
| 125 | return ''; |
| 126 | } |
| 127 | |
| 128 | return $this->parent_page->get_slug(); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Register tab related hooks. |
| 133 | * |
| 134 | * @since 2.8.0 |
| 135 | */ |
| 136 | public function hooks() {} |
| 137 | |
| 138 | /** |
| 139 | * Register tab related ajax hooks. |
| 140 | * |
| 141 | * @since 3.0.0 |
| 142 | */ |
| 143 | public function ajax() {} |
| 144 | |
| 145 | /** |
| 146 | * Process tab form submission ($_POST ). |
| 147 | * |
| 148 | * @since 1.0.0 |
| 149 | * |
| 150 | * @param array $data $_POST data specific for the plugin. |
| 151 | */ |
| 152 | public function process_post( $data ) {} |
| 153 | |
| 154 | /** |
| 155 | * Process tab & mailer specific Auth actions. |
| 156 | * |
| 157 | * @since 1.0.0 |
| 158 | */ |
| 159 | public function process_auth() {} |
| 160 | |
| 161 | /** |
| 162 | * Print the nonce field for a specific tab. |
| 163 | * |
| 164 | * @since 1.0.0 |
| 165 | */ |
| 166 | public function wp_nonce_field() { |
| 167 | |
| 168 | wp_nonce_field( Area::SLUG . '-' . $this->slug ); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Make sure that a user was referred from plugin admin page. |
| 173 | * To avoid security problems. |
| 174 | * |
| 175 | * @since 1.0.0 |
| 176 | */ |
| 177 | public function check_admin_referer() { |
| 178 | |
| 179 | check_admin_referer( Area::SLUG . '-' . $this->slug ); |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Save button to be reused on other tabs. |
| 184 | * |
| 185 | * @since 1.5.0 |
| 186 | */ |
| 187 | public function display_save_btn() { |
| 188 | |
| 189 | ?> |
| 190 | <p class="wp-mail-smtp-submit"> |
| 191 | <button type="submit" class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-orange"> |
| 192 | <?php esc_html_e( 'Save Settings', 'wp-mail-smtp' ); ?> |
| 193 | </button> |
| 194 | </p> |
| 195 | <?php |
| 196 | $this->post_form_hidden_field(); |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Form hidden field for identifying plugin POST requests. |
| 201 | * |
| 202 | * @since 2.9.0 |
| 203 | */ |
| 204 | public function post_form_hidden_field() { |
| 205 | |
| 206 | echo '<input type="hidden" name="wp-mail-smtp-post" value="1">'; |
| 207 | } |
| 208 | } |
| 209 |