AdminBar.php
1 day ago
AdminBarEditColumns.php
1 day ago
Colors.php
1 day ago
CommonAssets.php
1 day ago
CurrentTable.php
1 day ago
ManageHeadings.php
1 day ago
ManageValue.php
1 day ago
NoticeChecks.php
1 day ago
PluginUpdate.php
1 day ago
PromoChecks.php
1 day ago
QuickEdit.php
1 day ago
SaveHeadings.php
1 day ago
Setup.php
1 day ago
TableRows.php
1 day ago
Tooltips.php
1 day ago
View.php
1 day ago
AdminBar.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Service; |
| 6 | |
| 7 | use AC\Registerable; |
| 8 | use AC\Type\Uri; |
| 9 | use WP_Admin_Bar; |
| 10 | |
| 11 | class AdminBar implements Registerable |
| 12 | { |
| 13 | private Uri $url; |
| 14 | |
| 15 | private string $title; |
| 16 | |
| 17 | private string $id; |
| 18 | |
| 19 | public function __construct(Uri $url, string $title, string $id) |
| 20 | { |
| 21 | $this->url = $url; |
| 22 | $this->title = $title; |
| 23 | $this->id = $id; |
| 24 | } |
| 25 | |
| 26 | public function register(): void |
| 27 | { |
| 28 | add_action('admin_bar_menu', [$this, 'add_edit_columns'], 900); |
| 29 | } |
| 30 | |
| 31 | public function add_edit_columns(WP_Admin_Bar $wp_admin_bar): void |
| 32 | { |
| 33 | $wp_admin_bar->add_node([ |
| 34 | 'id' => $this->id, |
| 35 | 'title' => $this->title, |
| 36 | 'href' => $this->url->get_url(), |
| 37 | ]); |
| 38 | } |
| 39 | |
| 40 | } |
| 41 |