PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.1.4
Admin Columns v7.1.4
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Admin / AdminLoader.php
codepress-admin-columns / classes / Admin Last commit date
Asset 3 days ago Banner 3 days ago Colors 3 days ago MenuGroupFactory 3 days ago MenuPageFactory 3 days ago Notice 3 days ago Page 3 days ago PageFactory 3 days ago Preference 3 days ago Type 3 days ago View 3 days ago Admin.php 3 days ago AdminLoader.php 3 days ago AdminNetwork.php 3 days ago AdminScripts.php 3 days ago HelpTab.php 3 days ago Helpable.php 3 days ago Menu.php 3 days ago MenuFactory.php 3 days ago MenuFactoryInterface.php 3 days ago MenuGroupFactory.php 3 days ago MenuListFactory.php 3 days ago MenuListItems.php 3 days ago MenuPageFactory.php 3 days ago PageFactoryInterface.php 3 days ago PageNetworkRequestHandler.php 3 days ago PageNetworkRequestHandlers.php 3 days ago PageRequestHandler.php 3 days ago PageRequestHandlers.php 3 days ago RenderableHead.php 3 days ago RequestHandlerInterface.php 3 days ago ScreenOption.php 3 days ago ScreenOptions.php 3 days ago Scripts.php 3 days ago Tooltip.php 3 days ago UninitializedScreens.php 3 days ago
AdminLoader.php
116 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\Admin;
6
7 use AC\Asset\Enqueueable;
8 use AC\Asset\Enqueueables;
9 use AC\Registerable;
10 use AC\Renderable;
11 use AC\Request;
12 use AC\View;
13
14 class AdminLoader implements Registerable
15 {
16 protected string $hook;
17
18 protected RequestHandlerInterface $request_handler;
19
20 protected Enqueueables $assets;
21
22 private ?Renderable $page = null;
23
24 public function __construct(string $hook, RequestHandlerInterface $request_handler, Enqueueables $assets)
25 {
26 $this->hook = $hook;
27 $this->request_handler = $request_handler;
28 $this->assets = $assets;
29 }
30
31 public function register(): void
32 {
33 add_action('load-' . $this->hook, [$this, 'set_page']);
34 add_action('load-' . $this->hook, [$this, 'load']);
35 add_action('in_admin_header', [$this, 'head']);
36 add_action($this->hook, [$this, 'body']);
37 }
38
39 public function set_page(): void
40 {
41 $this->page = $this->request_handler->handle(new Request());
42 }
43
44 public function load(): void
45 {
46 if (! $this->page) {
47 return;
48 }
49
50 if ($this->page instanceof Registerable) {
51 $this->page->register();
52 }
53
54 $screen = get_current_screen();
55
56 if ($this->page instanceof Helpable && $screen) {
57 foreach ($this->page->get_help_tabs() as $help) {
58 $screen->add_help_tab([
59 'id' => $help->get_id(),
60 'title' => $help->get_title(),
61 'content' => $help->get_content(),
62 ]);
63 }
64 }
65
66 if ($this->page instanceof Enqueueables) {
67 array_map([$this, 'enqueue'], $this->page->get_assets()->all());
68 }
69
70 foreach ($this->assets->get_assets()->all() as $asset) {
71 $asset->enqueue();
72 }
73
74 do_action('ac/admin_scripts', $this->page);
75
76 add_filter('screen_settings', [$this, 'screen_options']);
77 }
78
79 public function head(): void
80 {
81 if ($this->page instanceof RenderableHead) {
82 echo $this->page->render_head()->render();
83 }
84 }
85
86 public function body(): void
87 {
88 if ($this->page instanceof Renderable) {
89 $view = new View([
90 'content' => $this->page->render(),
91 ]);
92
93 echo $view->set_template('admin/wrap')->render();
94 }
95 }
96
97 protected function enqueue(Enqueueable $asset): void
98 {
99 $asset->enqueue();
100 }
101
102 public function screen_options($settings)
103 {
104 if ($this->page instanceof ScreenOptions) {
105 $settings .= sprintf('<legend>%s</legend>', __('Display', 'codepress-admin-columns'));
106
107 foreach ($this->page->get_screen_options() as $screen_option) {
108 $settings .= $screen_option->render();
109 }
110 }
111
112 return $settings;
113 }
114
115 }
116