Logging: Initial commit with proof of concept

This commit is contained in:
Corey McKrill 2019-10-25 16:03:45 -07:00
parent 6209060eb2
commit e15522756b
No known key found for this signature in database
GPG key ID: C2C0746F7BF17E38
3 changed files with 219 additions and 0 deletions

View file

@ -0,0 +1,53 @@
<?php
namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var array $log */
?>
<div class="5ftf-activity-log">
<?php if ( ! empty( $log ) ) : ?>
<table class="striped widefat">
<thead>
<tr>
<td>Date</td>
<td>Entry</td>
<td>User</td>
</tr>
</thead>
<tbody>
<?php foreach ( $log as $entry ) : ?>
<tr>
<td>
<?php echo esc_html( date( 'Y-m-d G:i:s', $entry['timestamp'] ) ); ?>
</td>
<td>
<details>
<summary>
<?php echo wp_kses_data( $entry['message'] ); ?>
</summary>
<?php if ( ! empty( $entry['data'] ) ) : ?>
<pre><?php echo esc_html( print_r( $entry['data'] ) ); ?></pre>
<?php endif; ?>
</details>
</td>
<td>
<?php
$user = get_user_by( 'id', $entry['user_id'] );
if ( $user ) : ?>
<?php echo sanitize_user( $user->user_login ); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else : ?>
<p>
There are no log entries.
</p>
<?php endif; ?>
</div>