PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.0.13
WindPress – Tailwind CSS integration for WordPress v3.0.13
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.13, at src/Admin/AdminPage.php

57 lines 2.3 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 WIND_PRESS;
15 use WindPress\WindPress\Utils\AssetVite;
16 use WindPress\WindPress\Utils\Common;
17 class AdminPage
18 {
19 public function __construct()
20 {
21 \add_action('admin_menu', fn() => $this->add_admin_menu(), 1000001);
22 }
23 public static function get_page_url() : string
24 {
25 return \add_query_arg(['page' => WIND_PRESS::WP_OPTION], \admin_url('admin.php'));
26 }
27 public function add_admin_menu()
28 {
29 $hook = \add_menu_page(
30 \__('WindPress', 'windpress'),
31 \__('WindPress', 'windpress'),
32 'manage_options',
33 WIND_PRESS::WP_OPTION,
34 fn() => $this->render(),
35 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local file
36 'data:image/svg+xml;base64,' . \base64_encode(\file_get_contents(\dirname(WIND_PRESS::FILE) . '/windpress.svg')),
37 1000001
38 );
39 \add_action('load-' . $hook, fn() => $this->init_hooks());
40 }
41 private function render()
42 {
43 echo '<div id="windpress-app" class=""></div>';
44 }
45 private function init_hooks()
46 {
47 \add_action('admin_enqueue_scripts', fn() => $this->enqueue_scripts(), 1000001);
48 }
49 private function enqueue_scripts()
50 {
51 $handle = WIND_PRESS::WP_OPTION . ':admin';
52 AssetVite::get_instance()->enqueue_asset('assets/apps/dashboard/main.js', ['handle' => $handle, 'in_footer' => \true, 'dependencies' => ['wp-i18n', 'wp-hooks']]);
53 \wp_set_script_translations($handle, 'windpress');
54 \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()]]);
55 }
56 }
57