PluginProbe
The Innovative Form Builder – IvyForms / 0.1.2
The Innovative Form Builder – IvyForms v0.1.2
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Menu / MenuService.php

MenuService.php in The Innovative Form Builder – IvyForms 0.1.2, at backend/src/Services/Menu/MenuService.php

148 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Menu;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Services\Settings\SettingsService;
11 use IvyForms\Services\Translations\BackendStrings;
12
13 /**
14 * Renders menu pages
15 */
16 class MenuService
17 {
18 /**
19 * Submenu page render function
20 * @param string $page
21 */
22 public function render(string $page): void
23 {
24 $page = trim($page);
25 $scriptId = IVYFORMS_DEV ? 'ivyforms_scripts_dev_vite' : 'ivyforms_script_index'; // @phpstan-ignore-line
26 $scriptSrc = IVYFORMS_DEV ? // @phpstan-ignore-line
27 'http://localhost:5173/src/assets/js/admin/admin.ts' :
28 IVYFORMS_URL . 'frontend/dist/admin.js';
29 $styleSrc = IVYFORMS_DEV ? '' : IVYFORMS_URL . 'frontend/dist/index.css';// @phpstan-ignore-line
30 $scriptVersion = IVYFORMS_DEV ? null : IVYFORMS_VERSION;// @phpstan-ignore-line
31
32 wp_enqueue_script(
33 $scriptId,
34 $scriptSrc,
35 [],
36 $scriptVersion,
37 true
38 );
39
40 // TODO: Check including fonts on build
41 // @phpstan-ignore-next-line
42 if ($styleSrc) {
43 wp_enqueue_style(
44 'ivyforms_style_admin',
45 IVYFORMS_URL . 'frontend/dist/admin.css',
46 [],
47 $scriptVersion
48 );
49 wp_enqueue_style(
50 'ivyforms_style_index',
51 $styleSrc,
52 [],
53 $scriptVersion
54 );
55 // wp_enqueue_style(
56 // 'ivyforms_font_roboto_regular_woff2',
57 // IVYFORMS_URL . 'frontend/dist/Roboto-Regular.woff2',
58 // [],
59 // $scriptVersion
60 // );
61 // wp_enqueue_style(
62 // 'ivyforms_font_roboto_regular_woff',
63 // IVYFORMS_URL . 'frontend/dist/Roboto-Regular.woff',
64 // [],
65 // $scriptVersion
66 // );
67 // wp_enqueue_style(
68 // 'ivyforms_font_roboto_medium_woff2',
69 // IVYFORMS_URL . 'frontend/dist/Roboto-Medium.woff2',
70 // [],
71 // $scriptVersion
72 // );
73 // wp_enqueue_style(
74 // 'ivyforms_font_roboto_medium_woff',
75 // IVYFORMS_URL . 'frontend/dist/Roboto-Medium.woff',
76 // [],
77 // $scriptVersion
78 // );
79 // wp_enqueue_style(
80 // 'ivyforms_font_roboto_bold_woff2',
81 // IVYFORMS_URL . 'frontend/dist/Roboto-Bold.woff2',
82 // [],
83 // $scriptVersion
84 // );
85 // wp_enqueue_style(
86 // 'ivyforms_font_roboto_bold_woff',
87 // IVYFORMS_URL . 'frontend/dist/Roboto-Bold.woff',
88 // [],
89 // $scriptVersion
90 // );
91 }
92
93 // Localize scripts
94 wp_localize_script($scriptId, 'wpIvyPluginURL', [
95 'wpIvyPluginURL' => IVYFORMS_URL,
96 ]);
97
98 wp_localize_script($scriptId, 'wpIvyApiSettings', [
99 'root' => esc_url_raw(rest_url()),
100 'nonce' => wp_create_nonce('wp_rest'),
101 ]);
102
103 $settingsStorage = new SettingsService();
104 wp_localize_script($scriptId, 'wpIvySettings', $settingsStorage->getAllSettings());
105
106 wp_localize_script(
107 $scriptId,
108 'wpIvySettings',
109 $settingsStorage->getAllSettings()
110 );
111
112 wp_localize_script(
113 $scriptId,
114 'wpIvyLabels',
115 array_merge(
116 BackendStrings::getNewFormStrings(),
117 BackendStrings::getSettingsFormBuilderStrings(),
118 BackendStrings::getEmptyStatesStrings(),
119 BackendStrings::getEntityFormStrings(),
120 BackendStrings::getAllFormsStrings(),
121 BackendStrings::getDashboardStrings(),
122 BackendStrings::getCommonStrings(),
123 BackendStrings::getComponentsStrings(),
124 BackendStrings::getEntriesStrings(),
125 BackendStrings::getIntegrationsStrings(),
126 )
127 );
128
129 wp_localize_script(
130 $scriptId,
131 'wpIvyUrls',
132 [
133 'wpIvyPluginURL' => IVYFORMS_URL,
134 ]
135 );
136 wp_localize_script(
137 $scriptId,
138 'wpIvyApiSettings',
139 [
140 'root' => esc_url_raw(rest_url()),
141 'nonce' => wp_create_nonce('wp_rest')
142 ]
143 );
144
145 include IVYFORMS_PATH . '/view/backend/view.php';
146 }
147 }
148