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
AdminBarEditColumns.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Service; |
| 6 | |
| 7 | use AC\Capabilities; |
| 8 | use AC\ListScreen; |
| 9 | use AC\Registerable; |
| 10 | use AC\Storage\Repository\EditButton; |
| 11 | use AC\TableScreen; |
| 12 | use AC\Type\EditorUrlFactory; |
| 13 | |
| 14 | class AdminBarEditColumns implements Registerable |
| 15 | { |
| 16 | private EditButton $setting; |
| 17 | |
| 18 | public function __construct(EditButton $setting) |
| 19 | { |
| 20 | $this->setting = $setting; |
| 21 | } |
| 22 | |
| 23 | public function register(): void |
| 24 | { |
| 25 | add_action('ac/table/screen', [$this, 'init'], 10, 2); |
| 26 | } |
| 27 | |
| 28 | public function init(TableScreen $table, ?ListScreen $listscreen = null): void |
| 29 | { |
| 30 | if (! current_user_can(Capabilities::MANAGE)) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | if (! $this->setting->is_active()) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | $admin_bar = new AdminBar( |
| 39 | EditorUrlFactory::create( |
| 40 | $table->get_id(), |
| 41 | $table->is_network(), |
| 42 | $listscreen |
| 43 | ? $listscreen->get_id() |
| 44 | : null |
| 45 | ), |
| 46 | __('Edit Columns', 'codepress-admin-columns'), |
| 47 | 'ac-edit-columns' |
| 48 | ); |
| 49 | $admin_bar->register(); |
| 50 | } |
| 51 | |
| 52 | } |
| 53 |