| 1 |
<?php |
| 2 |
|
| 3 |
namespace Extendify\PluginNotifications; |
| 4 |
|
| 5 |
defined('ABSPATH') || die('No direct access.'); |
| 6 |
|
| 7 |
class AdminPage |
| 8 |
{ |
| 9 |
public static function handleActions() |
| 10 |
{ |
| 11 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 12 |
if (sanitize_text_field(wp_unslash($_REQUEST['page'] ?? '')) !== 'extendify-notifications') { |
| 13 |
return; |
| 14 |
} |
| 15 |
|
| 16 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 17 |
$action = sanitize_text_field(wp_unslash($_REQUEST['extendify_action'] ?? '')); |
| 18 |
|
| 19 |
if (empty($action)) { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
check_admin_referer('extendify_notifications_action', '_extendify_nonce'); |
| 24 |
|
| 25 |
if ($action === 'dismiss') { |
| 26 |
$id = sanitize_text_field(wp_unslash($_REQUEST['notice_id'] ?? '')); |
| 27 |
if ($id) { |
| 28 |
Admin::dismissNotice($id); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
if ($action === 'dismiss-all') { |
| 33 |
Admin::dismissAll(); |
| 34 |
} |
| 35 |
|
| 36 |
\wp_safe_redirect(\admin_url('index.php?page=extendify-notifications')); |
| 37 |
exit; |
| 38 |
} |
| 39 |
|
| 40 |
public static function render() |
| 41 |
{ |
| 42 |
if (!class_exists('WP_List_Table')) { |
| 43 |
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
| 44 |
} |
| 45 |
|
| 46 |
$table = new NotificationsListTable(); |
| 47 |
$table->prepare_items(); |
| 48 |
|
| 49 |
echo '<div class="wrap">'; |
| 50 |
echo '<h1>' . esc_html__('Plugin Notifications', 'extendify-local') . '</h1>'; |
| 51 |
$table->views(); |
| 52 |
echo '<form method="post">'; |
| 53 |
\wp_nonce_field('extendify_notifications_bulk', '_extendify_nonce'); |
| 54 |
$table->display(); |
| 55 |
echo '</form>'; |
| 56 |
echo '</div>'; |
| 57 |
} |
| 58 |
} |
| 59 |
|