| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * Log tab.
- *
- * @package studiou-wc-mail-queue
- * @copyright 2026 QUADARAX
- * @author Dalibor Votruba <dvotruba@quadarax.com>
- * @license GPL-2.0-or-later
- */
- defined( 'ABSPATH' ) || exit;
- // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $wcmq_level = isset( $_GET['level'] ) ? sanitize_key( wp_unslash( $_GET['level'] ) ) : '';
- if ( ! in_array( $wcmq_level, array( 'debug', 'info', 'warning', 'error' ), true ) ) {
- $wcmq_level = '';
- }
- $wcmq_paged = Studiou_WCMQ_Admin::current_page();
- $wcmq_total = Studiou_WCMQ_DB::count_log_rows( $wcmq_level );
- $wcmq_offset = ( $wcmq_paged - 1 ) * Studiou_WCMQ_Admin::PER_PAGE;
- $wcmq_rows = Studiou_WCMQ_DB::get_log_rows( $wcmq_level, Studiou_WCMQ_Admin::PER_PAGE, $wcmq_offset );
- $wcmq_levels = array(
- '' => __( 'All', 'studiou-wc-mail-queue' ),
- 'error' => __( 'Errors', 'studiou-wc-mail-queue' ),
- 'warning' => __( 'Warnings', 'studiou-wc-mail-queue' ),
- 'info' => __( 'Info', 'studiou-wc-mail-queue' ),
- 'debug' => __( 'Debug', 'studiou-wc-mail-queue' ),
- );
- ?>
- <ul class="subsubsub">
- <?php foreach ( $wcmq_levels as $wcmq_slug => $wcmq_label ) : ?>
- <li>
- <a href="<?php echo esc_url( Studiou_WCMQ_Admin::tab_url( 'log', $wcmq_slug ? array( 'level' => $wcmq_slug ) : array() ) ); ?>"
- class="<?php echo $wcmq_level === $wcmq_slug ? 'current' : ''; ?>">
- <?php echo esc_html( $wcmq_label ); ?>
- </a>
- </li>
- <?php endforeach; ?>
- </ul>
- <div class="clear"></div>
- <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="studiou-wcmq-clear-log-form">
- <?php wp_nonce_field( Studiou_WCMQ_Admin::NONCE ); ?>
- <input type="hidden" name="action" value="studiou_wcmq_clear_log" />
- <p>
- <button type="submit" class="button button-secondary" id="studiou-wcmq-clear-log">
- <?php esc_html_e( 'Clear log', 'studiou-wc-mail-queue' ); ?>
- </button>
- </p>
- </form>
- <table class="wp-list-table widefat fixed striped">
- <thead>
- <tr>
- <th style="width:60px"><?php esc_html_e( 'ID', 'studiou-wc-mail-queue' ); ?></th>
- <th style="width:90px"><?php esc_html_e( 'Level', 'studiou-wc-mail-queue' ); ?></th>
- <th style="width:170px"><?php esc_html_e( 'Time', 'studiou-wc-mail-queue' ); ?></th>
- <th style="width:80px"><?php esc_html_e( 'Row', 'studiou-wc-mail-queue' ); ?></th>
- <th><?php esc_html_e( 'Message', 'studiou-wc-mail-queue' ); ?></th>
- </tr>
- </thead>
- <tbody>
- <?php if ( empty( $wcmq_rows ) ) : ?>
- <tr><td colspan="5"><?php esc_html_e( 'The log is empty.', 'studiou-wc-mail-queue' ); ?></td></tr>
- <?php else : ?>
- <?php foreach ( $wcmq_rows as $wcmq_row ) : ?>
- <tr>
- <td><?php echo (int) $wcmq_row->id; ?></td>
- <td>
- <span class="studiou-wcmq-level studiou-wcmq-level-<?php echo esc_attr( $wcmq_row->level ); ?>">
- <?php echo esc_html( $wcmq_row->level ); ?>
- </span>
- </td>
- <td><?php echo wp_kses_post( Studiou_WCMQ_Admin::format_time( $wcmq_row->created_at ) ); ?></td>
- <td><?php echo $wcmq_row->queue_id ? (int) $wcmq_row->queue_id : '—'; ?></td>
- <td><?php echo esc_html( $wcmq_row->message ); ?></td>
- </tr>
- <?php endforeach; ?>
- <?php endif; ?>
- </tbody>
- </table>
- <?php
- Studiou_WCMQ_Admin::render_pagination(
- 'log',
- $wcmq_total,
- $wcmq_paged,
- $wcmq_level ? array( 'level' => $wcmq_level ) : array()
- );
|