mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-05 18:35:46 +03:00
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
This commit is contained in:
parent
6209060eb2
commit
5c5ae83287
6 changed files with 424 additions and 18 deletions
55
plugins/wporg-5ftf/views/log.php
Normal file
55
plugins/wporg-5ftf/views/log.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?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>
|
Loading…
Add table
Add a link
Reference in a new issue