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

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