class-strong-testimonials-logger.php
2 months ago
html-strong-testimonials-logs-viewer.php
1 year ago
html-strong-testimonials-logs-viewer.php
85 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | if ( $logs ) : ?> |
| 6 | <div class="wrap wpmtst"> |
| 7 | |
| 8 | <h1><?php esc_html_e( 'Strong Testimonials Debug Logs', 'strong-testimonials' ); ?></h1> |
| 9 | <div id="log-viewer-select"> |
| 10 | <div class="alignleft"> |
| 11 | <h2> |
| 12 | <?php echo esc_html( $viewed_log ); ?> |
| 13 | <?php |
| 14 | $subfolder = ''; |
| 15 | if ( strpos( $viewed_log, '/' ) ) { |
| 16 | $subfolder = explode( '/', $viewed_log )[0]; |
| 17 | $log_name = explode( '/', $viewed_log )[1]; |
| 18 | } else { |
| 19 | $log_name = $viewed_log; |
| 20 | } |
| 21 | ?> |
| 22 | <?php if ( ! empty( $viewed_log ) ) : ?> |
| 23 | <a class="page-title-action" href=" |
| 24 | <?php |
| 25 | echo esc_url( |
| 26 | wp_nonce_url( |
| 27 | add_query_arg( |
| 28 | array( |
| 29 | 'st_log_remove' => sanitize_title( $log_name ), |
| 30 | 'subdir' => sanitize_title( $subfolder ), |
| 31 | ), |
| 32 | admin_url( 'edit.php?post_type=wpm-testimonial&page=strong-testimonials-logs' ) |
| 33 | ), |
| 34 | 'remove_log' |
| 35 | ) |
| 36 | ); |
| 37 | ?> |
| 38 | " class="button"><?php esc_html_e( 'Delete log', 'strong-testimonials' ); ?></a> |
| 39 | <a class="page-title-action" href=" |
| 40 | <?php |
| 41 | echo esc_url( |
| 42 | wp_nonce_url( |
| 43 | add_query_arg( |
| 44 | array( |
| 45 | 'st_log_download' => sanitize_title( $log_name ), |
| 46 | 'subdir' => sanitize_title( $subfolder ), |
| 47 | ), |
| 48 | admin_url( 'edit.php?post_type=wpm-testimonial&page=strong-testimonials-logs' ) |
| 49 | ), |
| 50 | 'download_log' |
| 51 | ) |
| 52 | ); |
| 53 | ?> |
| 54 | " class="button"><?php esc_html_e( 'Download log', 'strong-testimonials' ); ?></a> |
| 55 | <?php endif; ?> |
| 56 | </h2> |
| 57 | </div> |
| 58 | <div class="alignright"> |
| 59 | <form action="<?php echo esc_url( admin_url( 'edit.php?post_type=wpm-testimonial&page=strong-testimonials-logs' ) ); ?>" method="post"> |
| 60 | <select name="log_file"> |
| 61 | <?php foreach ( $logs as $log_key => $log_file ) : ?> |
| 62 | <?php |
| 63 | $timestamp = filemtime( WPMTST_LOGS . $log_file ); |
| 64 | $date = sprintf( |
| 65 | __( '%1$s at %2$s', 'strong-testimonials' ), |
| 66 | wp_date( 'd-M-y', $timestamp ), |
| 67 | wp_date( 'h:i:s', $timestamp ) |
| 68 | ); |
| 69 | ?> |
| 70 | <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> |
| 71 | <?php endforeach; ?> |
| 72 | </select> |
| 73 | <button type="submit" class="button" value="<?php esc_attr_e( 'View', 'strong-testimonials' ); ?>"><?php esc_html_e( 'View', 'strong-testimonials' ); ?></button> |
| 74 | </form> |
| 75 | </div> |
| 76 | <div class="clear"></div> |
| 77 | </div> |
| 78 | <div id="log-viewer"> |
| 79 | <pre><?php echo esc_html( file_get_contents( WPMTST_LOGS . $viewed_log ) ); ?></pre> |
| 80 | </div> |
| 81 | <?php else : ?> |
| 82 | <div class="updated inline"><p><?php esc_html_e( 'There are currently no logs to view.', 'strong-testimonials' ); ?></p></div> |
| 83 | <?php endif; ?> |
| 84 | </div> |
| 85 |