| 1 |
<?php |
| 2 |
/** |
| 3 |
* Logs page view. |
| 4 |
* |
| 5 |
* @package Custom_404_Pro |
| 6 |
*/ |
| 7 |
|
| 8 |
$logs_table = new LogsClass(); |
| 9 |
$logs_table->prepare_items(); |
| 10 |
|
| 11 |
$helpers = Helpers::singleton(); |
| 12 |
$options = $helpers->get_settings(); |
| 13 |
$total_count = $helpers->get_logs_count(); |
| 14 |
$max_count = isset( $options['log_retention_count'] ) ? (int) $options['log_retention_count'] : 0; |
| 15 |
$max_days = isset( $options['log_retention_days'] ) ? (int) $options['log_retention_days'] : 0; |
| 16 |
|
| 17 |
?> |
| 18 |
|
| 19 |
<div class="wrap"> |
| 20 |
<h2><?php esc_html_e( 'Logs', 'custom-404-pro' ); ?></h2> |
| 21 |
|
| 22 |
<p> |
| 23 |
<?php |
| 24 |
echo esc_html( |
| 25 |
sprintf( |
| 26 |
/* translators: %d: number of log rows */ |
| 27 |
__( 'Total log entries: %d', 'custom-404-pro' ), |
| 28 |
(int) $total_count |
| 29 |
) |
| 30 |
); |
| 31 |
if ( $max_count > 0 ) { |
| 32 |
echo ' / ' . (int) $max_count; |
| 33 |
} |
| 34 |
?> |
| 35 |
</p> |
| 36 |
|
| 37 |
<?php if ( $max_count > 0 && $total_count >= $max_count * 0.9 ) : ?> |
| 38 |
<div class="notice notice-warning inline"> |
| 39 |
<p> |
| 40 |
<?php |
| 41 |
echo esc_html( |
| 42 |
sprintf( |
| 43 |
/* translators: 1: current log count, 2: max log count */ |
| 44 |
__( 'Log table is at %1$d of %2$d rows (90%% threshold reached). Consider pruning or raising the Max Log Count setting.', 'custom-404-pro' ), |
| 45 |
(int) $total_count, |
| 46 |
(int) $max_count |
| 47 |
) |
| 48 |
); |
| 49 |
?> |
| 50 |
</p> |
| 51 |
</div> |
| 52 |
<?php endif; ?> |
| 53 |
|
| 54 |
<?php if ( $max_count > 0 || $max_days > 0 ) : ?> |
| 55 |
<p> |
| 56 |
<a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=c4p-main&action=c4p-logs--prune' ), 'c4p-logs--prune' ) ); ?>" class="button"> |
| 57 |
<?php esc_html_e( 'Prune Logs Now', 'custom-404-pro' ); ?> |
| 58 |
</a> |
| 59 |
</p> |
| 60 |
<?php endif; ?> |
| 61 |
|
| 62 |
<form id="form_logs" method="GET"> |
| 63 |
<!-- For plugins, we also need to ensure that the form posts back to our current page --> |
| 64 |
<input type="hidden" name="page" value="<?php echo esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['page'] ?? '' ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>" /> |
| 65 |
<!-- Now we can render the completed list table --> |
| 66 |
<p class="search-box"> |
| 67 |
<label class="screen-reader-text" for="search_id-search-input"><?php esc_html_e( 'Search', 'custom-404-pro' ); ?></label> |
| 68 |
<input id="search_id-search-input" type="text" name="s" value=" |
| 69 |
<?php |
| 70 |
if ( array_key_exists( 's', $_GET ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 71 |
echo esc_attr( sanitize_text_field( wp_unslash( $_GET['s'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 72 |
} |
| 73 |
?> |
| 74 |
" autocomplete="off" /> |
| 75 |
<input id="search-submit" class="button" type="submit" name="" value="<?php echo esc_attr__( 'Search', 'custom-404-pro' ); ?>" /> |
| 76 |
</p> |
| 77 |
<?php $logs_table->display(); ?> |
| 78 |
</form> |
| 79 |
</div> |
| 80 |
|