| 1 |
<?php |
| 2 |
/** |
| 3 |
* 2FA Settings - Unified Admin View with Tabs |
| 4 |
* |
| 5 |
* Consolidates Policy, User Management, and Audit Log into tabbed sections. |
| 6 |
* |
| 7 |
* @package AtomicEdge |
| 8 |
* @since 1.9.1 |
| 9 |
*/ |
| 10 |
|
| 11 |
// Prevent direct access. |
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
// Get current tab. |
| 17 |
$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'policy'; |
| 18 |
$valid_tabs = array( 'policy', 'users', 'audit' ); |
| 19 |
if ( ! in_array( $current_tab, $valid_tabs, true ) ) { |
| 20 |
$current_tab = 'policy'; |
| 21 |
} |
| 22 |
|
| 23 |
// Tab definitions. |
| 24 |
$tabs = array( |
| 25 |
'policy' => array( |
| 26 |
'label' => __( 'Policy', 'atomicedge' ), |
| 27 |
'icon' => 'dashicons-shield', |
| 28 |
), |
| 29 |
'users' => array( |
| 30 |
'label' => __( 'Users', 'atomicedge' ), |
| 31 |
'icon' => 'dashicons-groups', |
| 32 |
), |
| 33 |
'audit' => array( |
| 34 |
'label' => __( 'Audit Log', 'atomicedge' ), |
| 35 |
'icon' => 'dashicons-list-view', |
| 36 |
), |
| 37 |
); |
| 38 |
?> |
| 39 |
<div class="wrap atomicedge-wrap"> |
| 40 |
<h1><img src="<?php echo esc_url( ATOMICEDGE_PLUGIN_URL . 'admin/images/logo.svg' ); ?>" alt="<?php esc_attr_e( 'Atomic Edge', 'atomic-edge-security' ); ?>" class="atomicedge-logo" /></h1> |
| 41 |
|
| 42 |
<div class="atomicedge-2fa"> |
| 43 |
<h2> |
| 44 |
<span class="dashicons dashicons-lock" style="font-size: 24px; width: 24px; height: 24px; margin-right: 8px; vertical-align: middle;"></span> |
| 45 |
<?php echo esc_html__( 'Two-Factor Authentication', 'atomicedge' ); ?> |
| 46 |
</h2> |
| 47 |
<p class="atomicedge-page-description"> |
| 48 |
<?php echo esc_html__( 'Manage two-factor authentication settings, user status, and security audit logs.', 'atomicedge' ); ?> |
| 49 |
</p> |
| 50 |
|
| 51 |
<!-- Tab Navigation --> |
| 52 |
<nav class="nav-tab-wrapper wp-clearfix" style="margin-bottom: 20px;"> |
| 53 |
<?php foreach ( $tabs as $tab_id => $tab ) : ?> |
| 54 |
<a href="<?php echo esc_url( add_query_arg( 'tab', $tab_id, admin_url( 'admin.php?page=atomicedge-2fa' ) ) ); ?>" |
| 55 |
class="nav-tab <?php echo $current_tab === $tab_id ? 'nav-tab-active' : ''; ?>"> |
| 56 |
<span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>" style="font-size: 16px; width: 16px; height: 16px; vertical-align: text-bottom; margin-right: 5px;"></span> |
| 57 |
<?php echo esc_html( $tab['label'] ); ?> |
| 58 |
</a> |
| 59 |
<?php endforeach; ?> |
| 60 |
</nav> |
| 61 |
|
| 62 |
<!-- Tab Content --> |
| 63 |
<div class="atomicedge-2fa-tab-content"> |
| 64 |
<?php |
| 65 |
switch ( $current_tab ) { |
| 66 |
case 'users': |
| 67 |
include ATOMICEDGE_PLUGIN_DIR . 'admin/views/partials/2fa-users-tab.php'; |
| 68 |
break; |
| 69 |
case 'audit': |
| 70 |
include ATOMICEDGE_PLUGIN_DIR . 'admin/views/partials/2fa-audit-tab.php'; |
| 71 |
break; |
| 72 |
case 'policy': |
| 73 |
default: |
| 74 |
include ATOMICEDGE_PLUGIN_DIR . 'admin/views/partials/2fa-policy-tab.php'; |
| 75 |
break; |
| 76 |
} |
| 77 |
?> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
|
| 82 |
<style> |
| 83 |
.atomicedge-wrap .nav-tab { |
| 84 |
display: inline-flex; |
| 85 |
align-items: center; |
| 86 |
} |
| 87 |
.atomicedge-wrap .nav-tab-active { |
| 88 |
background: #fff; |
| 89 |
border-bottom-color: #fff; |
| 90 |
} |
| 91 |
.atomicedge-2fa-tab-content { |
| 92 |
background: #fff; |
| 93 |
border: 1px solid #c3c4c7; |
| 94 |
border-top: none; |
| 95 |
padding: 20px; |
| 96 |
} |
| 97 |
.atomicedge-stats-grid { |
| 98 |
display: grid; |
| 99 |
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); |
| 100 |
gap: 15px; |
| 101 |
margin: 20px 0; |
| 102 |
} |
| 103 |
.atomicedge-stat-card { |
| 104 |
background: #f9f9f9; |
| 105 |
padding: 20px; |
| 106 |
border-left: 4px solid #0073aa; |
| 107 |
box-shadow: 0 1px 1px rgba(0,0,0,.04); |
| 108 |
} |
| 109 |
.atomicedge-stat-card .stat-value { |
| 110 |
font-size: 28px; |
| 111 |
font-weight: 600; |
| 112 |
color: #23282d; |
| 113 |
} |
| 114 |
.atomicedge-stat-card .stat-label { |
| 115 |
color: #666; |
| 116 |
font-size: 13px; |
| 117 |
} |
| 118 |
</style> |
| 119 |
|