Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
evokelektrique committed Nov 2, 2021
1 parent 905fab1 commit bc0e51d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/views/dashboard.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php global $replicant; ?>

<div class="wrap">
<h3><?= __( "Replicant", "replicant" ); ?></h3>
<h3><?php esc_html_e( "Replicant", "replicant" ); ?></h3>
<hr>
<p>There will be something here soon.</p>
</div>
10 changes: 5 additions & 5 deletions src/views/nodes/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<label for="name"><?php _e( 'Node Name', 'replicant' ); ?></label>
</th>
<td>
<input type="text" name="name" id="name" class="regular-text" placeholder="<?= esc_attr( '', 'replicant' ); ?>" value="<?= esc_attr( $item->name ); ?>" required="required" />
<input type="text" name="name" id="name" class="regular-text" placeholder="<?php echo esc_attr( '', 'replicant' ); ?>" value="<?php echo esc_attr( $item->name ); ?>" required="required" />
<span class="description"><?php _e('i.e: Shopping Website', 'replicant' ); ?></span>
</td>
</tr>
Expand All @@ -21,7 +21,7 @@
<label for="host"><?php _e( 'Address', 'replicant' ); ?></label>
</th>
<td>
<input type="text" name="host" id="host" class="regular-text" placeholder="<?= esc_attr( '', 'replicant' ); ?>" value="<?= esc_attr( $item->host ); ?>" required="required" />
<input type="text" name="host" id="host" class="regular-text" placeholder="<?php echo esc_attr( '', 'replicant' ); ?>" value="<?php echo esc_attr( $item->host ); ?>" required="required" />
<span class="description"><?php _e('i.e: wordpress.org', 'replicant' ); ?></span>
</td>
</tr>
Expand All @@ -30,22 +30,22 @@
<label for="ssl"><?php _e( 'SSL', 'replicant' ); ?></label>
</th>
<td>
<input type="checkbox" name="ssl" id="ssl" <?= $item->ssl ? "checked" : "" ?> />
<input type="checkbox" name="ssl" id="ssl" <?php echo $item->ssl ? "checked" : "" ?> />
</td>
</tr>
<tr class="row-port">
<th scope="row">
<label for="port"><?php _e( 'Port', 'replicant' ); ?></label>
</th>
<td>
<input type="number" name="port" id="port" class="regular-text" placeholder="<?= esc_attr( '', 'replicant' ); ?>" value="<?= esc_attr( intval($item->port) ) ?>" required="required" />
<input type="number" name="port" id="port" class="regular-text" placeholder="<?php echo esc_attr( '', 'replicant' ); ?>" value="<?php echo esc_attr( intval($item->port) ) ?>" required="required" />
<span class="description"><?php _e('i.e: 80', 'replicant' ); ?></span>
</td>
</tr>
</tbody>
</table>

<input type="hidden" name="field_id" value="<?= $item->id; ?>">
<input type="hidden" name="field_id" value="<?php echo $item->id; ?>">

<?php wp_nonce_field( '' ); ?>
<?php submit_button( __( 'Update node', 'replicant' ), 'primary', 'submit_node' ); ?>
Expand Down
13 changes: 2 additions & 11 deletions src/views/nodes/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@

<table class="form-table">
<tbody>
<!-- <tr class="row-name">
<th scope="row">
<label for="name"><?php _e( 'Node Name', 'replicant' ); ?></label>
</th>
<td>
<input type="text" name="name" id="name" class="regular-text" placeholder="<?php echo esc_attr( '', 'replicant' ); ?>" value="" required="required" />
<span class="description"><?php _e('i.e: Shopping Website', 'replicant' ); ?></span>
</td>
</tr>
--> <tr class="row-host">
<tr class="row-host">
<th scope="row">
<label for="host"><?php _e( 'Address', 'replicant' ); ?></label>
</th>
Expand Down Expand Up @@ -49,4 +40,4 @@
<?php submit_button( __( 'Submit new node', 'replicant' ), 'primary', 'submit_node' ); ?>

</form>
</div>
</div>
34 changes: 17 additions & 17 deletions src/views/nodes/single.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
<div class="wrap">

<div class="replicant-box">
<h2 class="replicant-heading"><?= __("Information", "replicant") ?></h2>
<h2 class="replicant-heading"><?php esc_html_e("Information", "replicant") ?></h2>
<ul class="replicant-node-information">
<li>
<span class="node-information-head"><?= __("id", "replicant") ?></span>
<span class="node-information-value"><?= $item->id ?></span>
<span class="node-information-head"><?php esc_html_e("id", "replicant") ?></span>
<span class="node-information-value"><?php echo $item->id ?></span>
</li>
<li>
<span class="node-information-head"><?= __("name", "replicant") ?></span>
<span class="node-information-value"><?= $item->name ?></span>
<span class="node-information-head"><?php esc_html_e("name", "replicant") ?></span>
<span class="node-information-value"><?php echo $item->name ?></span>
</li>
<li>
<span class="node-information-head"><?= __("host", "replicant") ?></span>
<span class="node-information-value"><?= $item->host ?></span>
<span class="node-information-head"><?php esc_html_e("host", "replicant") ?></span>
<span class="node-information-value"><?php echo $item->host ?></span>
</li>
<li>
<span class="node-information-head"><?= __("port", "replicant") ?></span>
<span class="node-information-value"><?= $item->port ?></span>
<span class="node-information-head"><?php esc_html_e("port", "replicant") ?></span>
<span class="node-information-value"><?php echo $item->port ?></span>
</li>
</ul>
</div>
Expand All @@ -34,22 +34,22 @@
$node_logs = Log::get_all($item->id, ARRAY_A);
?>
<div class="replicant-logs-container replicant-box">
<h2 class="replicant-heading"><?= __("Logs", "replicant") ?></h2>
<h2 class="replicant-heading"><?php esc_html_e("Logs", "replicant") ?></h2>
<?php if(empty($node_logs)): ?>
<p class="replicant-text`-danger"><?= __("No logs found.", "replicant") ?></p>
<p class="replicant-text`-danger"><?php esc_html_e("No logs found.", "replicant") ?></p>
<?php else: ?>
<ul>
<?php foreach($node_logs as $log): ?>
<?php
$timestamp = strtotime($log["created_at"]);
$timestamp = strtotime(esc_html($log["created_at"]));
$human_readable_time = human_time_diff($timestamp, current_time( 'U' ));
$human_readable_level = Log::human_readable_level($log["level"]);
$human_readable_level = Log::human_readable_level();
?>
<li>
<span class="log-id">#<?= $log["id"] ?></span>
<span class="log-level log-level-<?= $log["level"] ?> font-weight-bold"><?= $human_readable_level ?></span>
<span class="log-message"><?= $log["message"] ?></span>
<span class="log-date"><?= $human_readable_time . " " . __("ago", "replicant") ?></span>
<span class="log-id">#<?php echo intval($log["id"]) ?></span>
<span class="log-level log-level-<?php echo esc_html($log["level"]) ?> font-weight-bold"><?php echo esc_html($human_readable_level) ?></span>
<span class="log-message"><?php echo esc_html($log["message"]) ?></span>
<span class="log-date"><?php echo esc_html($human_readable_time) . " " . esc_html__("ago", "replicant") ?></span>
</li>
<?php endforeach; ?>
</ul>
Expand Down
6 changes: 3 additions & 3 deletions src/views/nodes/trust.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="wrap">
<?php
<?php
// Print out notice
if(is_wp_error( $response )) {
$message = $response->get_error_message();
Expand All @@ -12,8 +12,8 @@
\Replicant\Helper::print_notice($status, $message);
?>
<br>
<a href="<?= admin_url( 'admin.php?page=replicant-nodes' ); ?>" class="button">
<?= __("Go back", "replicant") ?>
<a href="<?php echo admin_url( 'admin.php?page=replicant-nodes' ); ?>" class="button">
<?php esc_html_e("Go back", "replicant") ?>
</a>
</div>

18 changes: 9 additions & 9 deletions src/views/settings.php
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
<?php global $replicant; ?>

<div class="wrap">
<h3><?= __( "Settings", "replicant" ); ?></h3>
<h3><?php esc_html_e( "Settings", "replicant" ); ?></h3>
<hr>

<span replicant-tab="settings" class="replicant-nav-tab active">
<?= __( "General", "replicant" ); ?>
<?php esc_html_e( "General", "replicant" ); ?>
</span>

<form id="panel_settings">
<div class="left_side">
<div id="settings" class="replicant-tab active">
<div class="replicant-form-row">
<label for="replicant_authoriazation">
<?= __( "Authorization Key:", "replicant" ); ?>
<?php esc_html_e( "Authorization Key:", "replicant" ); ?>
</label>
<input
type="text"
class="replicant_input"
name="replicant_authoriazation"
id="replicant_authoriazation"
value="<?= $replicant::$default_db::authorization()->value ?>"
placeholder="<?= __( "Authorization Key", "replicant" );?>"
value="<?php echo $replicant::$default_db::authorization()->value ?>"
placeholder="<?php esc_html_e( "Authorization Key", "replicant" );?>"
readonly=""
/>
</div>

<div class="replicant-form-row">
<label for="replicant_acting_as">
<?= __( "Acting as:", "replicant" ); ?>
<?php esc_html_e( "Acting as:", "replicant" ); ?>
</label>
<input
type="text"
class="replicant_input"
name="replicant_acting_as"
id="replicant_acting_as"
value="<?= $replicant::$default_db::acting_as()->value ?>"
placeholder="<?= __( "Authorization Key", "replicant" );?>"
value="<?php echo $replicant::$default_db::acting_as()->value ?>"
placeholder="<?php esc_html_e( "Authorization Key", "replicant" );?>"
readonly=""
/>
</div>
</div>
</div>
<div class="right_side">
<button class="button-primary"><?= __("Submit", "replicant") ?></button>
<button class="button-primary"><?php esc_html_e("Submit", "replicant") ?></button>
</div>
</form>
</div>

0 comments on commit bc0e51d

Please sign in to comment.