| 1 |
<?php |
| 2 |
/** |
| 3 |
* Settings Page View |
| 4 |
* |
| 5 |
* @package AtomicEdge |
| 6 |
*/ |
| 7 |
|
| 8 |
// Prevent direct access. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
$atomicedge_is_connected = $this->api->is_connected(); |
| 14 |
$atomicedge_api_url = get_option( 'atomicedge_api_url', 'https://dashboard.atomicedge.io/api/v1' ); |
| 15 |
$atomicedge_site_data = get_option( 'atomicedge_site_data', array() ); |
| 16 |
$atomicedge_masked_key = $this->get_masked_api_key(); |
| 17 |
?> |
| 18 |
<div class="wrap atomicedge-wrap"> |
| 19 |
<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> |
| 20 |
|
| 21 |
<div class="atomicedge-settings"> |
| 22 |
<!-- Connection Status --> |
| 23 |
<div class="atomicedge-settings-section"> |
| 24 |
<h2><?php esc_html_e( 'Connection Status', 'atomic-edge-security' ); ?></h2> |
| 25 |
|
| 26 |
<?php if ( $atomicedge_is_connected ) : ?> |
| 27 |
<div class="atomicedge-connection-status atomicedge-connected"> |
| 28 |
<span class="dashicons dashicons-yes-alt"></span> |
| 29 |
<div class="atomicedge-connection-info"> |
| 30 |
<strong><?php esc_html_e( 'Connected', 'atomic-edge-security' ); ?></strong> |
| 31 |
<?php if ( ! empty( $atomicedge_site_data['domain'] ) ) : ?> |
| 32 |
<span class="atomicedge-connection-domain"> |
| 33 |
<?php echo esc_html( $atomicedge_site_data['domain'] ); ?> |
| 34 |
</span> |
| 35 |
<?php endif; ?> |
| 36 |
<?php if ( ! empty( $atomicedge_masked_key ) ) : ?> |
| 37 |
<span class="atomicedge-connection-key"> |
| 38 |
<?php |
| 39 |
printf( |
| 40 |
/* translators: %s: masked API key */ |
| 41 |
esc_html__( 'API Key: %s', 'atomic-edge-security' ), |
| 42 |
'<code>' . esc_html( $atomicedge_masked_key ) . '</code>' |
| 43 |
); |
| 44 |
?> |
| 45 |
</span> |
| 46 |
<?php endif; ?> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
|
| 50 |
<form method="post" action="" style="margin-top: 15px;"> |
| 51 |
<?php wp_nonce_field( 'atomicedge_disconnect' ); ?> |
| 52 |
<button type="submit" |
| 53 |
name="atomicedge_disconnect" |
| 54 |
class="button button-secondary" |
| 55 |
onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to disconnect from Atomic Edge?', 'atomic-edge-security' ); ?>');"> |
| 56 |
<?php esc_html_e( 'Disconnect', 'atomic-edge-security' ); ?> |
| 57 |
</button> |
| 58 |
</form> |
| 59 |
|
| 60 |
<?php else : ?> |
| 61 |
<div class="atomicedge-connection-status atomicedge-disconnected"> |
| 62 |
<span class="dashicons dashicons-warning"></span> |
| 63 |
<div class="atomicedge-connection-info"> |
| 64 |
<strong><?php esc_html_e( 'Not Connected', 'atomic-edge-security' ); ?></strong> |
| 65 |
<span><?php esc_html_e( 'Enter your API key to connect to Atomic Edge.', 'atomic-edge-security' ); ?></span> |
| 66 |
</div> |
| 67 |
</div> |
| 68 |
|
| 69 |
<form method="post" action="" style="margin-top: 15px;"> |
| 70 |
<?php wp_nonce_field( 'atomicedge_connect' ); ?> |
| 71 |
<table class="form-table"> |
| 72 |
<tr> |
| 73 |
<th scope="row"> |
| 74 |
<label for="atomicedge_api_key"><?php esc_html_e( 'API Key', 'atomic-edge-security' ); ?></label> |
| 75 |
</th> |
| 76 |
<td> |
| 77 |
<input type="text" |
| 78 |
id="atomicedge_api_key" |
| 79 |
name="atomicedge_api_key" |
| 80 |
class="regular-text" |
| 81 |
placeholder="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 82 |
required /> |
| 83 |
<p class="description"> |
| 84 |
<?php esc_html_e( 'Paste the API key exactly as shown in the Atomic Edge dashboard (32–64 letters/numbers, no prefix).', 'atomic-edge-security' ); ?> |
| 85 |
<br /> |
| 86 |
<?php |
| 87 |
printf( |
| 88 |
/* translators: %s: AtomicEdge dashboard URL */ |
| 89 |
esc_html__( 'Get your API key from your %s.', 'atomic-edge-security' ), |
| 90 |
'<a href="https://dashboard.atomicedge.io" target="_blank">' . esc_html__( 'Atomic Edge dashboard', 'atomic-edge-security' ) . '</a>' |
| 91 |
); |
| 92 |
?> |
| 93 |
</p> |
| 94 |
</td> |
| 95 |
</tr> |
| 96 |
</table> |
| 97 |
<p class="submit"> |
| 98 |
<button type="submit" name="atomicedge_connect" class="button button-primary"> |
| 99 |
<?php esc_html_e( 'Connect', 'atomic-edge-security' ); ?> |
| 100 |
</button> |
| 101 |
</p> |
| 102 |
</form> |
| 103 |
<?php endif; ?> |
| 104 |
</div> |
| 105 |
|
| 106 |
<!-- Advanced Settings --> |
| 107 |
<div class="atomicedge-settings-section"> |
| 108 |
<h2><?php esc_html_e( 'Advanced Settings', 'atomic-edge-security' ); ?></h2> |
| 109 |
|
| 110 |
<form method="post" action=""> |
| 111 |
<?php wp_nonce_field( 'atomicedge_settings' ); ?> |
| 112 |
<table class="form-table"> |
| 113 |
<tr> |
| 114 |
<th scope="row"> |
| 115 |
<label for="atomicedge_api_url"><?php esc_html_e( 'API URL', 'atomic-edge-security' ); ?></label> |
| 116 |
</th> |
| 117 |
<td> |
| 118 |
<input type="url" |
| 119 |
id="atomicedge_api_url" |
| 120 |
name="atomicedge_api_url" |
| 121 |
class="regular-text" |
| 122 |
value="<?php echo esc_attr( $atomicedge_api_url ); ?>" /> |
| 123 |
<p class="description"> |
| 124 |
<?php esc_html_e( 'Only change this if instructed by Atomic Edge support.', 'atomic-edge-security' ); ?> |
| 125 |
</p> |
| 126 |
</td> |
| 127 |
</tr> |
| 128 |
</table> |
| 129 |
<p class="submit"> |
| 130 |
<button type="submit" name="atomicedge_save_settings" class="button button-primary"> |
| 131 |
<?php esc_html_e( 'Save Settings', 'atomic-edge-security' ); ?> |
| 132 |
</button> |
| 133 |
</p> |
| 134 |
</form> |
| 135 |
</div> |
| 136 |
|
| 137 |
<!-- Plugin Info --> |
| 138 |
<div class="atomicedge-settings-section"> |
| 139 |
<h2><?php esc_html_e( 'Plugin Information', 'atomic-edge-security' ); ?></h2> |
| 140 |
<table class="form-table atomicedge-info-table"> |
| 141 |
<tr> |
| 142 |
<th><?php esc_html_e( 'Plugin Version', 'atomic-edge-security' ); ?></th> |
| 143 |
<td><?php echo esc_html( ATOMICEDGE_VERSION ); ?></td> |
| 144 |
</tr> |
| 145 |
<tr> |
| 146 |
<th><?php esc_html_e( 'WordPress Version', 'atomic-edge-security' ); ?></th> |
| 147 |
<td><?php echo esc_html( get_bloginfo( 'version' ) ); ?></td> |
| 148 |
</tr> |
| 149 |
<tr> |
| 150 |
<th><?php esc_html_e( 'PHP Version', 'atomic-edge-security' ); ?></th> |
| 151 |
<td><?php echo esc_html( PHP_VERSION ); ?></td> |
| 152 |
</tr> |
| 153 |
<tr> |
| 154 |
<th><?php esc_html_e( 'Site URL', 'atomic-edge-security' ); ?></th> |
| 155 |
<td><?php echo esc_html( home_url() ); ?></td> |
| 156 |
</tr> |
| 157 |
</table> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
|