@@ -40,17 +40,11 @@ function render_profile_section( WP_User $user ) {
40
40
</tr>
41
41
</thead>
42
42
<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
+ ?>
54
48
</tbody>
55
49
</table>
56
50
<?php else : ?>
@@ -63,6 +57,44 @@ function render_profile_section( WP_User $user ) {
63
57
<?php
64
58
}
65
59
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
+
66
98
/**
67
99
* Output messages based on previous actions.
68
100
*/
0 commit comments