Skip to content

Commit e434ecf

Browse files
committed
Display token creation time in list
1 parent da87b93 commit e434ecf

File tree

1 file changed

+43
-11
lines changed

1 file changed

+43
-11
lines changed

inc/admin/profile/namespace.php

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,11 @@ function render_profile_section( WP_User $user ) {
4040
</tr>
4141
</thead>
4242
<tbody>
43-
<?php foreach ( $tokens as $token ): ?>
44-
<?php
45-
/** @var Access_Token $token */
46-
$client = $token->get_client();
47-
?>
48-
<tr>
49-
<td><?php echo $client->get_name() ?></td>
50-
<td><button class="button" name="oauth2_revoke" value="<?php echo esc_attr( $token->get_key() ) ?>"><?php esc_html_e( 'Revoke', 'oauth2' ) ?></button>
51-
</tr>
52-
53-
<?php endforeach ?>
43+
<?php
44+
foreach ( $tokens as $token ) {
45+
render_token_row( $token );
46+
}
47+
?>
5448
</tbody>
5549
</table>
5650
<?php else: ?>
@@ -63,6 +57,44 @@ function render_profile_section( WP_User $user ) {
6357
<?php
6458
}
6559

60+
/**
61+
* Render a single row.
62+
*/
63+
function render_token_row( Access_Token $token ) {
64+
$client = $token->get_client();
65+
66+
$details = [
67+
sprintf(
68+
/* translators: %s: formatted date */
69+
esc_html__( 'Authorized %s', 'oauth2' ),
70+
date( get_option( 'date_format' ), $token->get_creation_time() )
71+
),
72+
];
73+
$button_title = sprintf(
74+
/* translators: %s: app name */
75+
__( 'Revoke access for "%s"', 'oauth2' ),
76+
$client->get_name()
77+
);
78+
?>
79+
<tr>
80+
<td>
81+
<p><strong><?php echo $client->get_name() ?></strong></p>
82+
<p><?php echo implode( ' | ', $details ) ?></p>
83+
</td>
84+
<td style="vertical-align: middle">
85+
<button
86+
class="button"
87+
name="oauth2_revoke"
88+
value="<?php echo esc_attr( $token->get_key() ) ?>"
89+
title="<?php echo esc_attr( $button_title ) ?>"
90+
>
91+
<?php esc_html_e( 'Revoke', 'oauth2' ) ?>
92+
</button>
93+
</td>
94+
</tr>
95+
<?php
96+
}
97+
6698
/**
6799
* Output messages based on previous actions.
68100
*/

0 commit comments

Comments
 (0)