PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.0.6
WindPress – Tailwind CSS integration for WordPress v3.0.6
3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 All 142 releases
windpress / src / Admin / AdminPage.php

AdminPage.php in WindPress – Tailwind CSS integration for WordPress 3.0.6, at src/Admin/AdminPage.php

58 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the WindPress package.
5 *
6 * (c) Joshua Gugun Siagian <suabahasa@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 declare (strict_types=1);
12 namespace WindPress\WindPress\Admin;
13
14 use WindPressPackages\EDD_SL\PluginUpdater;
15 use WIND_PRESS;
16 use WindPress\WindPress\Utils\AssetVite;
17 use WindPress\WindPress\Utils\Common;
18 class AdminPage
19 {
20 public function __construct()
21 {
22 \add_action('admin_menu', fn() => $this->add_admin_menu(), 1000001);
23 }
24 public static function get_page_url() : string
25 {
26 return \add_query_arg(['page' => WIND_PRESS::WP_OPTION], \admin_url('admin.php'));
27 }
28 public function add_admin_menu()
29 {
30 $hook = \add_menu_page(
31 \__('WindPress', 'windpress'),
32 \__('WindPress', 'windpress'),
33 'manage_options',
34 WIND_PRESS::WP_OPTION,
35 fn() => $this->render(),
36 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local file
37 'data:image/svg+xml;base64,' . \base64_encode(\file_get_contents(\dirname(WIND_PRESS::FILE) . '/windpress.svg')),
38 1000001
39 );
40 \add_action('load-' . $hook, fn() => $this->init_hooks());
41 }
42 private function render()
43 {
44 echo '<div id="windpress-app" class=""></div>';
45 }
46 private function init_hooks()
47 {
48 \add_action('admin_enqueue_scripts', fn() => $this->enqueue_scripts(), 1000001);
49 }
50 private function enqueue_scripts()
51 {
52 $handle = WIND_PRESS::WP_OPTION . ':admin';
53 AssetVite::get_instance()->enqueue_asset('assets/apps/dashboard/main.js', ['handle' => $handle, 'in_footer' => \true, 'dependencies' => ['wp-i18n', 'wp-hooks']]);
54 \wp_set_script_translations($handle, 'windpress');
55 \wp_localize_script($handle, 'windpress', ['_version' => WIND_PRESS::VERSION, '_via_wp_org' => !Common::is_updater_library_available(), '_wpnonce' => \wp_create_nonce(WIND_PRESS::WP_OPTION), 'rest_api' => ['nonce' => \wp_create_nonce('wp_rest'), 'root' => \esc_url_raw(\rest_url()), 'namespace' => WIND_PRESS::REST_NAMESPACE, 'url' => \esc_url_raw(\rest_url(WIND_PRESS::REST_NAMESPACE))], 'assets' => ['url' => AssetVite::asset_base_url()], 'site_meta' => ['name' => \get_bloginfo('name'), 'site_url' => \get_site_url()]]);
56 }
57 }
58