PluginProbe
The Innovative Form Builder – IvyForms / 1.0
The Innovative Form Builder – IvyForms v1.0
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 1.0, at backend/src/Services/Menu/MenuService.php

174 lines 5.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 use IvyForms\Routes\Routes;
6 use IvyForms\Services\Settings\SettingsService;
7 use IvyForms\Services\Translations\BackendStrings;
8
9 /**
10 * Renders menu pages
11 */
12 class MenuService
13 {
14 /**
15 * Submenu page render function
16 * @param string $page
17 */
18 public function render(string $page): void
19 {
20 $page = trim($page);
21 $scriptId = IVYFORMS_DEV ? 'ivyforms_scripts_dev_vite' : 'ivyforms_script_index';
22 $scriptSrc = IVYFORMS_DEV ?
23 'http://localhost:5173/src/assets/js/admin/admin.ts' :
24 IVYFORMS_URL . 'frontend/dist/admin.js';
25 $styleSrc = IVYFORMS_DEV ? '' : IVYFORMS_URL . 'frontend/dist/index.css';
26 $scriptVersion = IVYFORMS_DEV ? null : IVYFORMS_VERSION;
27
28 wp_enqueue_script(
29 $scriptId,
30 $scriptSrc,
31 [],
32 $scriptVersion,
33 true
34 );
35
36 // TODO: Check including fonts on build
37 // @phpstan-ignore-next-line
38 if ($styleSrc) {
39 wp_enqueue_style(
40 'ivyforms_style_admin',
41 IVYFORMS_URL . 'frontend/dist/admin.css',
42 [],
43 $scriptVersion
44 );
45 wp_enqueue_style(
46 'ivyforms_style_index',
47 $styleSrc,
48 [],
49 $scriptVersion
50 );
51 // wp_enqueue_style(
52 // 'ivyforms_font_roboto_regular_woff2',
53 // IVYFORMS_URL . 'frontend/dist/Roboto-Regular.woff2',
54 // [],
55 // $scriptVersion
56 // );
57 // wp_enqueue_style(
58 // 'ivyforms_font_roboto_regular_woff',
59 // IVYFORMS_URL . 'frontend/dist/Roboto-Regular.woff',
60 // [],
61 // $scriptVersion
62 // );
63 // wp_enqueue_style(
64 // 'ivyforms_font_roboto_medium_woff2',
65 // IVYFORMS_URL . 'frontend/dist/Roboto-Medium.woff2',
66 // [],
67 // $scriptVersion
68 // );
69 // wp_enqueue_style(
70 // 'ivyforms_font_roboto_medium_woff',
71 // IVYFORMS_URL . 'frontend/dist/Roboto-Medium.woff',
72 // [],
73 // $scriptVersion
74 // );
75 // wp_enqueue_style(
76 // 'ivyforms_font_roboto_bold_woff2',
77 // IVYFORMS_URL . 'frontend/dist/Roboto-Bold.woff2',
78 // [],
79 // $scriptVersion
80 // );
81 // wp_enqueue_style(
82 // 'ivyforms_font_roboto_bold_woff',
83 // IVYFORMS_URL . 'frontend/dist/Roboto-Bold.woff',
84 // [],
85 // $scriptVersion
86 // );
87 }
88
89 // Localize scripts
90 $settingsStorage = new SettingsService();
91
92 wp_localize_script(
93 $scriptId,
94 'wpIvySettings',
95 $settingsStorage->getFrontendSettings()
96 );
97
98 $backendLabels = array_merge(
99 BackendStrings::getNewFormStrings(),
100 BackendStrings::getStylesFormBuilderStrings(),
101 BackendStrings::getSettingsFormBuilderStrings(),
102 BackendStrings::getResultsFormBuilderStrings(),
103 BackendStrings::getEmptyStatesStrings(),
104 BackendStrings::getEntityFormStrings(),
105 BackendStrings::getAllFormsStrings(),
106 BackendStrings::getDashboardStrings(),
107 BackendStrings::getCommonStrings(),
108 BackendStrings::getComponentsStrings(),
109 BackendStrings::getEntriesStrings(),
110 BackendStrings::getIntegrationsStrings(),
111 BackendStrings::getExceptionStrings(),
112 BackendStrings::getTemplateStrings(),
113 BackendStrings::getSettingsStrings(),
114 BackendStrings::getSecurityStrings(),
115 BackendStrings::getProUpgradeDialogStrings(),
116 BackendStrings::getChangelogStrings()
117 );
118
119 /**
120 * Filter backend labels before localizing
121 * Allows Pro version to merge additional strings
122 *
123 * @since 0.1.0
124 * @param array $backendLabels Array of backend label strings
125 */
126 $backendLabels = apply_filters('ivyforms/admin/backend_labels', $backendLabels);
127
128 wp_localize_script(
129 $scriptId,
130 'wpIvyLabels',
131 $backendLabels
132 );
133
134 wp_localize_script(
135 $scriptId,
136 'wpIvyUrls',
137 [
138 'pluginURL' => IVYFORMS_URL,
139 'siteURL' => esc_url_raw(site_url()),
140 ]
141 );
142 wp_localize_script(
143 $scriptId,
144 'wpIvyApiSettings',
145 [
146 'root' => esc_url_raw(rest_url()),
147 'nonce' => wp_create_nonce('wp_rest'),
148 'namespace' => Routes::$routeNamespace,
149 ]
150 );
151 wp_localize_script(
152 $scriptId,
153 'wpIvyDateFormat',
154 [
155 'dateFormat' => get_option('date_format'),
156 'timeFormat' => get_option('time_format'),
157 'dateTimeFormat' => get_option('date_format') . ' ' . get_option('time_format'),
158 'locale' => get_locale(),
159 ]
160 );
161
162 /**
163 * Hook to enqueue additional scripts and styles in admin area
164 * @since 0.1.0
165 *
166 * Arguments:
167 * - string $scriptId The main script handle ID (for dependencies)
168 */
169 do_action('ivyforms/admin/enqueue_scripts', $scriptId);
170
171 include IVYFORMS_PATH . '/view/backend/view.php';
172 }
173 }
174