AuthorPostUrl.php
1 day ago
CommentCount.php
1 day ago
FirstPost.php
1 day ago
FullName.php
1 day ago
HasRichEditing.php
1 day ago
LastPost.php
1 day ago
Meta.php
1 day ago
PostCount.php
1 day ago
PostCountOriginal.php
1 day ago
Property.php
1 day ago
Roles.php
1 day ago
ShowToolbar.php
1 day ago
TranslatedRoles.php
1 day ago
UserFilteredPostLink.php
1 day ago
UserLink.php
1 day ago
UserName.php
1 day ago
ShowToolbar.php
26 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Formatter\User; |
| 6 | |
| 7 | use AC\Exception\ValueNotFoundException; |
| 8 | use AC\Formatter; |
| 9 | use AC\Type\Value; |
| 10 | use WP_User; |
| 11 | |
| 12 | class ShowToolbar implements Formatter |
| 13 | { |
| 14 | public function format(Value $value): Value |
| 15 | { |
| 16 | $user = get_userdata($value->get_id()); |
| 17 | |
| 18 | if (! $user instanceof WP_User) { |
| 19 | throw ValueNotFoundException::from_id($value->get_id()); |
| 20 | } |
| 21 | |
| 22 | return new Value('true' === ($user->show_admin_bar_front ?? null)); |
| 23 | } |
| 24 | |
| 25 | } |
| 26 |