| 1 |
<?php |
| 2 |
/** |
| 3 |
* Docket Cache. |
| 4 |
* |
| 5 |
* @author Nawawi Jamili |
| 6 |
* @license MIT |
| 7 |
* |
| 8 |
* @see https://github.com/nawawi/docket-cache |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace Nawawi\DocketCache; |
| 12 |
|
| 13 |
\defined('ABSPATH') || exit; |
| 14 |
|
| 15 |
$log = $this->parse_log_query(); |
| 16 |
?> |
| 17 |
|
| 18 |
<div class="section<?php echo !$log->output_empty ? ' log' : ''; ?>"> |
| 19 |
<div class="flex-container"> |
| 20 |
<div class="row"> |
| 21 |
<?php $this->tab_title(!$this->has_vcache() ? esc_html__('Cache Log', 'docket-cache') : esc_html__('Cache View', 'docket-cache')); ?> |
| 22 |
<table class="form-table form-table-selection noborder-b"> |
| 23 |
<?php if (!$this->has_vcache()) : ?> |
| 24 |
<tr> |
| 25 |
<th><?php esc_html_e('Timestamp', 'docket-cache'); ?></th> |
| 26 |
<td> |
| 27 |
<?php |
| 28 |
echo $this->config_select_set( |
| 29 |
'log_time', |
| 30 |
[ |
| 31 |
'default' => __('Default', 'docket-cache'), |
| 32 |
'utc' => __('UTC', 'docket-cache'), |
| 33 |
/* translators: %s = utc offset */ |
| 34 |
'local' => sprintf(__('Local time (%s)', 'docket-cache'), $this->pt->get_utc_offset()), |
| 35 |
'wp' => __('Site Format', 'docket-cache'), |
| 36 |
], |
| 37 |
'dcdefault', |
| 38 |
[ |
| 39 |
'idx' => 'log', |
| 40 |
'quiet' => 1, |
| 41 |
] |
| 42 |
); |
| 43 |
?> |
| 44 |
</td> |
| 45 |
</tr> |
| 46 |
<tr> |
| 47 |
<th><?php esc_html_e('Log All', 'docket-cache'); ?></th> |
| 48 |
<td><?php echo $this->config_select_bool('log_all', 'dcdefault', 'log'); ?></td> |
| 49 |
</tr> |
| 50 |
<tr> |
| 51 |
<th><?php esc_html_e('Log File', 'docket-cache'); ?></th> |
| 52 |
<td> |
| 53 |
<?php if ($log->output_empty) : ?> |
| 54 |
<?php echo $this->info->log_file; ?> |
| 55 |
<?php else : ?> |
| 56 |
<a class="btxo" title="<?php esc_html_e('Download', 'docket-cache'); ?>" href="<?php echo $this->tab_query('log', ['dl' => '0'.time()]); ?>" rel="noopener" target="new"><?php echo $this->info->log_file; ?><span class="dashicons dashicons-external"></span></a> |
| 57 |
<?php endif; ?> |
| 58 |
</td> |
| 59 |
</tr> |
| 60 |
<?php else : ?> |
| 61 |
<tr> |
| 62 |
<th><?php esc_html_e('Cache Index', 'docket-cache'); ?></th> |
| 63 |
<td><?php echo $this->idx_vcache(); ?></td> |
| 64 |
</tr> |
| 65 |
<?php endif; ?> |
| 66 |
<?php if ($log->output_empty) : ?> |
| 67 |
<tr> |
| 68 |
<td colspan="2"><?php esc_html_e('Data Not available', 'docket-cache'); ?></td> |
| 69 |
</tr> |
| 70 |
<?php else : ?> |
| 71 |
<tr> |
| 72 |
<th class="border-b"><?php echo $this->has_vcache() ? esc_html__('Cache Size', 'docket-cache') : esc_html__('Log Size', 'docket-cache'); ?></th> |
| 73 |
<td> |
| 74 |
<?php |
| 75 |
echo $log->log_size.' / '.($this->has_vcache() ? $this->cache_max_size : $this->log_max_size); |
| 76 |
?> |
| 77 |
</td> |
| 78 |
</tr> |
| 79 |
<tr> |
| 80 |
<td colspan="2"> |
| 81 |
<?php if ($this->has_vcache()) : ?> |
| 82 |
<a href=" |
| 83 |
<?php |
| 84 |
echo $this->pt->action_query( |
| 85 |
'flush-ocfile', |
| 86 |
[ |
| 87 |
'idx' => 'log', |
| 88 |
'idxv' => $this->idx_vcache(), |
| 89 |
] |
| 90 |
); |
| 91 |
?> |
| 92 |
" class="button button-primary button-small bt-fx"><?php esc_html_e('Flush', 'docket-cache'); ?></a> |
| 93 |
<a href="<?php echo $this->tab_query('log'); ?>" class="button button-primary button-small bt-fx"><?php esc_html_e('Close', 'docket-cache'); ?></a> |
| 94 |
<?php else : ?> |
| 95 |
<span class="vcache">Select row to view cache content.</span> |
| 96 |
<a href="<?php echo $this->tab_query('log'); ?>" class="button button-primary button-small bt-fx button-vcache hide"><?php esc_html_e('View', 'docket-cache'); ?></a> |
| 97 |
<a href="<?php echo $this->tab_query('log'); ?>" class="button button-primary button-small bt-fx button-vcache-c hide"><?php esc_html_e('Close', 'docket-cache'); ?></a> |
| 98 |
<?php endif; ?> |
| 99 |
<textarea id="log" class="code" readonly="readonly" rows="<?php echo $log->row_size; ?>" wrap="off"><?php echo $log->output; ?></textarea> |
| 100 |
</td> |
| 101 |
</tr> |
| 102 |
<?php endif; ?> |
| 103 |
</table> |
| 104 |
|
| 105 |
<p class="submit"> |
| 106 |
<?php if (!$log->output_empty && !$this->has_vcache()) : ?> |
| 107 |
<select id="order" data-id="logopt"> |
| 108 |
<?php |
| 109 |
foreach ([ |
| 110 |
'first' => __('FIRST', 'docket-cache'), |
| 111 |
'last' => __('LAST', 'docket-cache'), |
| 112 |
] as $order => $text) { |
| 113 |
$selected = ($order === $log->default_order ? ' selected' : ''); |
| 114 |
echo '<option value="'.$order.'"'.$selected.'>'.esc_html($text).'</option>'; |
| 115 |
} |
| 116 |
?> |
| 117 |
</select> |
| 118 |
<select id="line" data-id="logopt"> |
| 119 |
<?php |
| 120 |
foreach (['10', '50', '100', '300', '500'] as $line) { |
| 121 |
$selected = ((int) $line === $log->default_line ? ' selected' : ''); |
| 122 |
echo '<option value="'.$line.'"'.$selected.'>'.$line.'</option>'; |
| 123 |
} |
| 124 |
?> |
| 125 |
</select> |
| 126 |
<select id="sort" data-id="logopt"> |
| 127 |
<?php |
| 128 |
foreach ([ |
| 129 |
'asc' => __('ASCENDING', 'docket-cache'), |
| 130 |
'desc' => __('DESCENDING', 'docket-cache'), |
| 131 |
] as $sort => $text) { |
| 132 |
$selected = ($sort === $log->default_sort ? ' selected' : ''); |
| 133 |
$text = esc_html($text); |
| 134 |
if (\in_array($text, ['ASCENDING', 'DESCENDING'])) { |
| 135 |
$text = 'desc' === $sort ? substr($text, 0, 4) : substr($text, 0, 3); |
| 136 |
} |
| 137 |
echo '<option value="'.$sort.'"'.$selected.'>'.$text.'</option>'; |
| 138 |
} |
| 139 |
?> |
| 140 |
</select> |
| 141 |
<br> |
| 142 |
<a href="<?php echo $this->pt->action_query('flush-oclog', ['idx' => 'log']); ?>" class="button button-primary button-large"><?php esc_html_e('Flush Log', 'docket-cache'); ?></a> |
| 143 |
<?php endif; ?> |
| 144 |
|
| 145 |
<?php if (($this->info->log_enable || !$log->output_empty) && !$this->has_vcache()) : ?> |
| 146 |
<a href="<?php echo $this->tab_query('log'); ?>" class="button button-secondary button-large" id="refresh"><?php esc_html_e('Refresh', 'docket-cache'); ?></a> |
| 147 |
<?php endif; ?> |
| 148 |
|
| 149 |
<?php if ($this->info->log_enable && $this->has_vcache() && $log->output_empty) : ?> |
| 150 |
<a href="<?php echo $this->tab_query('log'); ?>" class="button button-secondary button-large" id="refresh"><?php esc_html_e('Refresh', 'docket-cache'); ?></a> |
| 151 |
<?php endif; ?> |
| 152 |
</p> |
| 153 |
</div> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
|