mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-22 11:03:43 +03:00
Pledge Log: Log user of CLI actions.
This commit is contained in:
parent
c524d1b21b
commit
18228d367c
|
@ -117,6 +117,9 @@ function add_log_entry( $pledge_id, $type, $message, array $data = array(), $use
|
||||||
if ( $user_id ) {
|
if ( $user_id ) {
|
||||||
// The template defaults to the current user, so this function parameter shouldn't override unless it's different.
|
// The template defaults to the current user, so this function parameter shouldn't override unless it's different.
|
||||||
$entry['user_id'] = $user_id;
|
$entry['user_id'] = $user_id;
|
||||||
|
|
||||||
|
} elseif ( 'cli' === php_sapi_name() ) {
|
||||||
|
$entry['user_id'] = gethostname();
|
||||||
}
|
}
|
||||||
|
|
||||||
add_post_meta( $pledge_id, LOG_META_KEY, $entry, false );
|
add_post_meta( $pledge_id, LOG_META_KEY, $entry, false );
|
||||||
|
|
|
@ -36,9 +36,14 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
$user = get_user_by( 'id', $entry['user_id'] );
|
$user = get_user_by( 'id', $entry['user_id'] );
|
||||||
if ( $user ) : ?>
|
|
||||||
<?php echo sanitize_user( $user->user_login ); ?>
|
if ( $user ) {
|
||||||
<?php endif; ?>
|
echo sanitize_user( $user->user_login );
|
||||||
|
} elseif ( ! empty( $entry['user_id'] ) ) {
|
||||||
|
echo esc_html( $entry['user_id'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
Loading…
Reference in a new issue