html-admin-page-status-logs.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Admin View: Page - Status Logs
  4. *
  5. * @package WooCommerce/Admin/Logs
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. ?>
  11. <?php if ( $logs ) : ?>
  12. <div id="log-viewer-select">
  13. <div class="alignleft">
  14. <h2>
  15. <?php echo esc_html( $viewed_log ); ?>
  16. <?php if ( ! empty( $viewed_log ) ) : ?>
  17. <a class="page-title-action" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'handle' => $viewed_log ), admin_url( 'admin.php?page=wc-status&tab=logs' ) ), 'remove_log' ) ); ?>" class="button"><?php esc_html_e( 'Delete log', 'woocommerce' ); ?></a>
  18. <?php endif; ?>
  19. </h2>
  20. </div>
  21. <div class="alignright">
  22. <form action="<?php echo esc_url( admin_url( 'admin.php?page=wc-status&tab=logs' ) ); ?>" method="post">
  23. <select name="log_file">
  24. <?php foreach ( $logs as $log_key => $log_file ) : ?>
  25. <?php
  26. $timestamp = filemtime( WC_LOG_DIR . $log_file );
  27. /* translators: 1: last access date 2: last access time */
  28. $date = sprintf( __( '%1$s at %2$s', 'woocommerce' ), date_i18n( wc_date_format(), $timestamp ), date_i18n( wc_time_format(), $timestamp ) );
  29. ?>
  30. <option value="<?php echo esc_attr( $log_key ); ?>" <?php selected( sanitize_title( $viewed_log ), $log_key ); ?>><?php echo esc_html( $log_file ); ?> (<?php echo esc_html( $date ); ?>)</option>
  31. <?php endforeach; ?>
  32. </select>
  33. <button type="submit" class="button" value="<?php esc_attr_e( 'View', 'woocommerce' ); ?>"><?php esc_html_e( 'View', 'woocommerce' ); ?></button>
  34. </form>
  35. </div>
  36. <div class="clear"></div>
  37. </div>
  38. <div id="log-viewer">
  39. <pre><?php echo esc_html( file_get_contents( WC_LOG_DIR . $viewed_log ) ); ?></pre>
  40. </div>
  41. <?php else : ?>
  42. <div class="updated woocommerce-message inline"><p><?php esc_html_e( 'There are currently no logs to view.', 'woocommerce' ); ?></p></div>
  43. <?php endif; ?>