five-for-the-future/plugins/wporg-5ftf/views/log.php
Corey McKrill 5c5ae83287
Plugin: Add a system for logging events related to pledges and contributors (#54)
Uses action hooks to capture relevant events as log entries on a per-pledge basis. This provides a running history of a pledge and can be used as an audit log if questions arise about changes to a pledge or there are weird bugs.

Fixes #39
2019-10-29 12:46:13 -07:00

56 lines
1.1 KiB
PHP

<?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 H:i:s', $entry['timestamp'] ) ); ?>
</td>
<td>
<?php if ( ! empty( $entry['data'] ) ) : ?>
<details>
<summary>
<?php echo wp_kses_data( $entry['message'] ); ?>
</summary>
<pre><?php echo esc_html( print_r( $entry['data'], true ) ); ?></pre>
</details>
<?php else : ?>
<?php echo wp_kses_data( $entry['message'] ); ?>
<?php endif; ?>
</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>