Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/fluentform/app/Modules/Registerer/Menu.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + namespace FluentForm\App\Modules\Registerer;
4 +
5 + use FluentForm\App\Helpers\Helper;
6 + use FluentForm\App\Hooks\Handlers\ActivationHandler;
7 + use FluentForm\App\Modules\Acl\Acl;
8 + use FluentForm\App\Modules\AddOnModule;
9 + use FluentForm\App\Modules\DocumentationModule;
10 + use FluentForm\App\Modules\Payments\PaymentHelper;
11 + use FluentForm\App\Services\FluentConversational\Classes\Converter\Converter;
12 + use FluentForm\App\Services\Manager\FormManagerService;
13 + use FluentForm\Framework\Foundation\Application;
14 + use FluentForm\Framework\Helpers\ArrayHelper;
15 +
16 + class Menu
17 + {
18 + /**
19 + * App instance
20 + *
21 + * @var \FluentForm\Framework\Foundation\Application
22 + */
23 + protected $app;
24 +
25 + /**
26 + * Menu constructor.
27 + *
28 + * @param \FluentForm\Framework\Foundation\Application $application
29 + */
30 + public function __construct(Application $application)
31 + {
32 + $this->app = $application;
33 +
34 + $this->app->addFilter('fluentform/form_settings_menu', [
35 + $this, 'filterFormSettingsMenu',
36 + ], 10, 2);
37 + }
38 +
39 + public function reisterScripts()
40 + {
41 + if (!$this->isFluentPages()) {
42 + return;
43 + }
44 +
45 + $app = $this->app;
46 +
47 + wp_register_script(
48 + 'fluent_forms_global',
49 + fluentFormMix('js/fluent_forms_global.js'),
50 + ['jquery'],
51 + FLUENTFORM_VERSION,
52 + true
53 + );
54 +
55 + $settingsGlobalStyle = fluentFormMix('css/settings_global.css');
56 + $allFormsStyle = fluentFormMix('css/fluent-all-forms.css');
57 + $fluentFormAdminEditorStyles = fluentFormMix('css/fluent-forms-admin-sass.css');
58 + $fluentFormAdminCSS = fluentFormMix('css/fluent-forms-admin.css');
59 + $addOnsCss = fluentFormMix('css/add-ons.css');
60 + $adminDocCss = fluentFormMix('css/admin_docs.css');
61 + $reportsCss = fluentFormMix('css/fluent-forms-reports.css');
62 + if (is_rtl()) {
63 + $settingsGlobalStyle = fluentFormMix('css/settings_global_rtl.css');
64 + $allFormsStyle = fluentFormMix('css/fluent-all-forms-rtl.css');
65 + $fluentFormAdminEditorStyles = fluentFormMix('css/fluent-forms-admin-sass-rtl.css');
66 + $fluentFormAdminCSS = fluentFormMix('css/fluent-forms-admin-rtl.css');
67 + $addOnsCss = fluentFormMix('css/add-ons-rtl.css');
68 + $adminDocCss = fluentFormMix('css/admin_docs_rtl.css');
69 + $reportsCss = fluentFormMix('css/fluent-forms-reports-rtl.css');
70 + }
71 +
72 + wp_register_style(
73 + 'fluentform_settings_global',
74 + $settingsGlobalStyle,
75 + [],
76 + FLUENTFORM_VERSION,
77 + 'all'
78 + );
79 +
80 + wp_register_script(
81 + 'clipboard',
82 + fluentFormMix('libs/clipboard.min.js'),
83 + [],
84 + FLUENTFORM_VERSION,
85 + true
86 + );
87 +
88 + wp_register_script(
89 + 'copier',
90 + fluentFormMix('js/copier.js'),
91 + [],
92 + FLUENTFORM_VERSION,
93 + true
94 + );
95 +
96 + wp_register_script(
97 + 'fluentform_form_settings',
98 + fluentFormMix('js/form_settings_app.js'),
99 + ['jquery'],
100 + FLUENTFORM_VERSION,
101 + true
102 + );
103 +
104 + wp_register_script(
105 + 'fluent_all_forms',
106 + fluentFormMix('js/fluent-all-forms-admin.js'),
107 + ['jquery'],
108 + FLUENTFORM_VERSION,
109 + true
110 + );
111 +
112 + wp_register_style(
113 + 'fluent_all_forms',
114 + $allFormsStyle,
115 + [],
116 + FLUENTFORM_VERSION,
117 + 'all'
118 + );
119 +
120 + wp_register_script(
121 + 'fluentform_editor_script',
122 + fluentFormMix('js/fluent-forms-editor.js'),
123 + ['jquery'],
124 + FLUENTFORM_VERSION,
125 + true
126 + );
127 +
128 +
129 + wp_register_style(
130 + 'fluentform_editor_style',
131 + $fluentFormAdminEditorStyles,
132 + [],
133 + FLUENTFORM_VERSION,
134 + 'all'
135 + );
136 +
137 + wp_register_style(
138 + 'fluentform_editor_sass',
139 + $fluentFormAdminCSS,
140 + [],
141 + FLUENTFORM_VERSION,
142 + 'all'
143 + );
144 +
145 + wp_register_script(
146 + 'fluentform-transfer-js',
147 + fluentFormMix('js/fluentform-transfer.js'),
148 + ['jquery'],
149 + FLUENTFORM_VERSION,
150 + true
151 + );
152 +
153 + wp_register_script(
154 + 'fluentform-global-settings-js',
155 + fluentFormMix('js/fluentform-global-settings.js'),
156 + ['jquery'],
157 + FLUENTFORM_VERSION,
158 + true
159 + );
160 +
161 + wp_register_script(
162 + 'fluentform-modules',
163 + fluentFormMix('js/modules.js'),
164 + ['jquery'],
165 + FLUENTFORM_VERSION,
166 + true
167 + );
168 +
169 + wp_register_script(
170 + 'fluentform-docs',
171 + fluentFormMix('js/docs.js'),
172 + ['jquery'],
173 + FLUENTFORM_VERSION,
174 + true
175 + );
176 +
177 + wp_register_script(
178 + 'fluentform_form_entries',
179 + fluentFormMix('js/form_entries.js'),
180 + ['jquery', 'fluentform_chart_js', 'fluentform_vue_chart_js'],
181 + FLUENTFORM_VERSION,
182 + true
183 + );
184 +
185 + wp_register_script(
186 + 'fluentform_reports',
187 + fluentFormMix('js/reports.js'),
188 + ['jquery'],
189 + FLUENTFORM_VERSION,
190 + true
191 + );
192 +
193 + wp_register_style(
194 + 'fluentform_reports',
195 + $reportsCss,
196 + [],
197 + FLUENTFORM_VERSION,
198 + 'all'
199 + );
200 +
201 + wp_register_script(
202 + 'fluentform_all_entries',
203 + fluentFormMix('js/all_entries.js'),
204 + ['jquery', 'fluentform_chart_js', 'fluentform_vue_chart_js'],
205 + FLUENTFORM_VERSION,
206 + true
207 + );
208 +
209 + wp_register_script(
210 + 'fluentform_chart_js',
211 + fluentFormMix('libs/chartjs/chart.min.js'),
212 + [],
213 + FLUENTFORM_VERSION,
214 + true
215 + );
216 +
217 + wp_register_script(
218 + 'fluentform_vue_chart_js',
219 + fluentFormMix('libs/chartjs/vue-chartjs.min.js'),
220 + [],
221 + FLUENTFORM_VERSION,
222 + true
223 + );
224 +
225 + wp_register_style(
226 + 'fluentform-add-ons',
227 + $addOnsCss,
228 + [],
229 + FLUENTFORM_VERSION,
230 + 'all'
231 + );
232 +
233 + wp_register_style(
234 + 'fluentform_doc_style',
235 + $adminDocCss,
236 + [],
237 + FLUENTFORM_VERSION,
238 + 'all'
239 + );
240 +
241 + add_filter('admin_footer_text', function ($text) {
242 + return '<span id="footer-thankyou">If you like the plugin please rate Fluent Forms <a target="_blank" rel="nofollow" href="https://wordpress.org/support/plugin/fluentform/reviews/#new-post">★★★★★ </a> on <a target="_blank" rel="nofollow" href="https://wordpress.org/support/plugin/fluentform/reviews/#new-post">WordPress.org</a> to help us spread the word ♥ from the Fluent Forms team. </span>';
243 + });
244 +
245 + add_filter('update_footer', function ($text) {
246 + $footerContent = 'Version ' . FLUENTFORM_VERSION;
247 + if (defined('FLUENTFORMPRO')) {
248 + $footerContent .= ' & Pro ' . FLUENTFORMPRO_VERSION;
249 + }
250 + return $footerContent;
251 + });
252 +
253 + $elementUIStyle = fluentFormMix('css/element-ui-css.css');
254 + if (is_rtl()) {
255 + $elementUIStyle = fluentFormMix('css/element-ui-css-rtl.css');
256 + }
257 + wp_enqueue_style(
258 + 'fluentform_global_elements',
259 + $elementUIStyle,
260 + [],
261 + FLUENTFORM_VERSION,
262 + 'all'
263 + );
264 + }
265 +
266 + public function isFluentPages()
267 + {
268 + return Helper::isFluentAdminPage();
269 + }
270 +
271 + public function enqueuePageScripts()
272 + {
273 + if (!$this->isFluentPages()) {
274 + return;
275 + }
276 +
277 + $forms = wpFluent()->table('fluentform_forms')
278 + ->orderBy('id', 'desc')
279 + ->select(['id', 'title'])
280 + ->get();
281 +
282 + wp_enqueue_script('fluent_forms_global');
283 + wp_localize_script('fluent_forms_global', 'fluent_forms_global_var', [
284 + 'fluent_forms_admin_nonce' => wp_create_nonce('fluent_forms_admin_nonce'),
285 + 'ajaxurl' => Helper::getAjaxUrl(),
286 + 'admin_i18n' => TranslationString::getAdminI18n(),
287 + 'global_search_active' => apply_filters('fluentform/global_search_active', 'yes'),
288 + 'payments_str' => TranslationString::getPaymentsI18n(),
289 + 'permissions' => Acl::getCurrentUserPermissions(),
290 + 'rest' => Helper::getRestInfo(),
291 + 'card_brands' => [
292 + 'visa' => fluentformMix('img/card-brand/visa.jpg'),
293 + 'paypal' => fluentformMix('img/card-brand/paypal.jpg'),
294 + 'mastercard' => fluentformMix('img/card-brand/mastercard.jpg'),
295 + 'amex' => fluentformMix('img/card-brand/amex.jpg')
296 + ],
297 + 'payment_icons' => [
298 + 'offline' => fluentformMix('img/payment/offline.png'),
299 + 'mollie' => fluentformMix('img/payment/mollie.png'),
300 + 'paypal' => fluentformMix('img/payment/paypal.png'),
301 + 'stripe' => fluentformMix('img/payment/stripe.png')
302 + ],
303 + 'forms' => $forms,
304 + 'hasPro' => defined('FLUENTFORMPRO'),
305 + 'has_entries_import' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.7', '>='),
306 + 'disable_time_diff' => Helper::isDefaultWPDateEnabled(),
307 + 'wp_date_time_format' => Helper::getDefaultDateTimeFormatForMoment(),
308 + 'server_time' => current_time('mysql'),
309 + ]);
310 +
311 + $page = sanitize_text_field($this->app->request->get('page'));
312 + $route = sanitize_text_field($this->app->request->get('route'));
313 + $formId = intval($this->app->request->get('form_id'));
314 +
315 + if ('fluent_forms' == $page && $route && $formId) {
316 + if (true) {
317 + wp_enqueue_style('fluentform_settings_global');
318 + wp_enqueue_script('clipboard');
319 + wp_enqueue_script('copier');
320 +
321 + if (Acl::hasPermission('fluentform_forms_manager', $formId)) {
322 + if ('settings' == $route) {
323 + if (function_exists('wp_enqueue_editor')) {
324 + add_filter('user_can_richedit', function ($status) {
325 + return true;
326 + });
327 +
328 + wp_enqueue_editor();
329 + wp_enqueue_media();
330 + }
331 + do_action('fluentform/loading_settings_assets', $formId);
332 + wp_enqueue_script('fluentform_form_settings');
333 + } elseif ('editor' == $route) {
334 + $this->enqueueEditorAssets();
335 + }
336 + }
337 + }
338 + } elseif ('fluent_forms' == $page) {
339 + wp_enqueue_script('fluent_all_forms');
340 + wp_enqueue_style('fluent_all_forms');
341 + }elseif ('fluent_forms_transfer' == $page) {
342 + wp_enqueue_style('fluentform_settings_global');
343 + wp_enqueue_script('fluentform-transfer-js');
344 + } elseif (
345 + 'fluent_forms_settings' == $page ||
346 + 'fluent_forms_payment_entries' == $page ||
347 + 'fluent_forms_all_entries' == $page
348 + ) {
349 + wp_enqueue_style('fluentform_settings_global');
350 + } elseif ('fluent_forms_add_ons' == $page) {
351 + wp_enqueue_style('fluentform-add-ons');
352 + } elseif ('fluent_forms_docs' == $page || 'fluent_forms_smtp' == $page) {
353 + wp_enqueue_style('fluentform_doc_style');
354 + }
355 + }
356 +
357 + /**
358 + * Register menu and sub-menus.
359 + */
360 + public function register()
361 + {
362 + $dashBoardCapability = apply_filters_deprecated(
363 + 'fluentform_dashboard_capability',
364 + [
365 + 'fluentform_dashboard_access'
366 + ],
367 + FLUENTFORM_FRAMEWORK_UPGRADE,
368 + 'fluentform/dashboard_capability',
369 + 'Use fluentform/dashboard_capability instead of fluentform_dashboard_capability.'
370 + );
371 +
372 + $dashBoardCapability = $this->app->applyFilters(
373 + 'fluentform/dashboard_capability',
374 + $dashBoardCapability
375 + );
376 +
377 + $settingManager = apply_filters_deprecated(
378 + 'fluentform_settings_capability',
379 + [
380 + 'fluentform_settings_manager'
381 + ],
382 + FLUENTFORM_FRAMEWORK_UPGRADE,
383 + 'fluentform/settings_capability',
384 + 'Use fluentform/settings_capability instead of fluentform_settings_capability.'
385 + );
386 +
387 + $settingsCapability = $this->app->applyFilters(
388 + 'fluentform/settings_capability',
389 + $settingManager
390 + );
391 +
392 + $fromRole = false;
393 + if (!current_user_can($dashBoardCapability) && !current_user_can($settingsCapability)) {
394 + $currentUserCapability = Acl::getCurrentUserCapability();
395 +
396 + if (!$currentUserCapability) {
397 + return;
398 + } else {
399 + $fromRole = true;
400 + $dashBoardCapability = $settingsCapability = $currentUserCapability;
401 + }
402 + }
403 +
404 + if (Acl::isSuperMan()) {
405 + $fromRole = true;
406 + }
407 +
408 + if (defined('FLUENTFORMPRO')) {
409 + $title = __('Fluent Forms Pro', 'fluentform');
410 + } else {
411 + $title = __('Fluent Forms', 'fluentform');
412 + }
413 +
414 + $menuPriority = 25;
415 +
416 + if (defined('FLUENTCRM')) {
417 + $menuPriority = 3;
418 + }
419 +
420 + add_menu_page(
421 + $title,
422 + $title,
423 + $dashBoardCapability,
424 + 'fluent_forms',
425 + [$this, 'renderFormAdminRoute'],
426 + $this->getMenuIcon(),
427 + $menuPriority
428 + );
429 +
430 + add_submenu_page(
431 + 'fluent_forms',
432 + __('Forms', 'fluentform'),
433 + __('Forms', 'fluentform'),
434 + $dashBoardCapability,
435 + 'fluent_forms',
436 + [$this, 'renderFormAdminRoute']
437 + );
438 +
439 + if ($settingsCapability) {
440 + add_submenu_page(
441 + 'fluent_forms',
442 + __('New Form', 'fluentform'),
443 + __('New Form', 'fluentform'),
444 + $fromRole ? $settingsCapability : 'fluentform_forms_manager',
445 + 'fluent_forms#add=1',
446 + [$this, 'renderAddNewFormRoute']
447 + );
448 +
449 + $entriesTitle = __('Entries', 'fluentform');
450 +
451 + if (Helper::isFluentAdminPage()) {
452 + $allowForms = FormManagerService::getUserAllowedForms();
453 + $entriesCount = wpFluent()->table('fluentform_submissions')
454 + ->where('status', 'unread')
455 + ->when($allowForms, function ($q) use ($allowForms){
456 + return $q->whereIn('form_id', $allowForms);
457 + })
458 + ->count();
459 +
460 + if ($entriesCount) {
461 + $entriesTitle .= ' <span class="ff_unread_count" style="background: #197efb;color: white;border-radius: 8px;padding: 1px 8px;">' . $entriesCount . '</span>';
462 + }
463 + }
464 +
465 + // Register entries intermediary page
466 + add_submenu_page(
467 + 'fluent_forms',
468 + $entriesTitle,
469 + $entriesTitle,
470 + $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
471 + 'fluent_forms_all_entries',
472 + [$this, 'renderAllEntriesAdminRoute']
473 + );
474 +
475 + // Register Reports sub menu page.
476 + add_submenu_page(
477 + 'fluent_forms',
478 + __('Reports', 'fluentform'),
479 + __('Reports', 'fluentform'),
480 + $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
481 + 'fluent_forms_reports',
482 + [$this, 'renderReports']
483 + );
484 +
485 + $isShowPaymentSubmission = apply_filters_deprecated(
486 + 'fluentform_show_payment_entries',
487 + [
488 + false
489 + ],
490 + FLUENTFORM_FRAMEWORK_UPGRADE,
491 + 'fluentform/show_payment_entries',
492 + 'Use fluentform/show_payment_entries instead of fluentform_show_payment_entries.'
493 + );
494 +
495 + if (apply_filters('fluentform/show_payment_entries', $isShowPaymentSubmission)) {
496 + add_submenu_page(
497 + 'fluent_forms',
498 + __('Payments', 'fluentform'),
499 + __('Payments', 'fluentform'),
500 + $fromRole ? $settingsCapability : 'fluentform_view_payments',
501 + 'fluent_forms_payment_entries',
502 + [$this, 'renderPaymentEntries']
503 + );
504 + }
505 +
506 + // Register global settings sub menu page.
507 + add_submenu_page(
508 + 'fluent_forms',
509 + __('Global Settings', 'fluentform'),
510 + __('Global Settings', 'fluentform'),
511 + $fromRole ? $settingsCapability : 'fluentform_settings_manager',
512 + 'fluent_forms_settings',
513 + [$this, 'renderGlobalSettings']
514 + );
515 +
516 + // Register import/export sub menu page.
517 + add_submenu_page(
518 + 'fluent_forms',
519 + __('Tools', 'fluentform'),
520 + __('Tools', 'fluentform'),
521 + $fromRole ? $settingsCapability : 'fluentform_settings_manager',
522 + 'fluent_forms_transfer',
523 + [$this, 'renderTransfer']
524 + );
525 +
526 + // Register FluentSMTP Sub Menu.
527 + add_submenu_page(
528 + 'fluent_forms',
529 + __('SMTP', 'fluentform'),
530 + __('SMTP', 'fluentform'),
531 + $fromRole ? $settingsCapability : 'fluentform_settings_manager',
532 + 'fluent_forms_smtp',
533 + [$this, 'renderSmtpPromo']
534 + );
535 +
536 + // Register Add-Ons
537 + add_submenu_page(
538 + 'fluent_forms',
539 + __('Integrations', 'fluentform'),
540 + __('Integrations', 'fluentform'),
541 + $fromRole ? $settingsCapability : 'fluentform_settings_manager',
542 + 'fluent_forms_add_ons',
543 + [$this, 'renderAddOns']
544 + );
545 + }
546 +
547 + // Register Documentation
548 + add_submenu_page(
549 + 'fluent_forms',
550 + __('Support', 'fluentform'),
551 + __('Support', 'fluentform'),
552 + $dashBoardCapability,
553 + 'fluent_forms_docs',
554 + [$this, 'renderDocs']
555 + );
556 +
557 + $this->commonAction();
558 + }
559 +
560 + private function getMenuIcon()
561 + {
562 + return 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><defs><style>.cls-1{fill:#fff;}</style></defs><title>dashboard_icon</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M15.57,0H4.43A4.43,4.43,0,0,0,0,4.43V15.57A4.43,4.43,0,0,0,4.43,20H15.57A4.43,4.43,0,0,0,20,15.57V4.43A4.43,4.43,0,0,0,15.57,0ZM12.82,14a2.36,2.36,0,0,1-1.66.68H6.5A2.31,2.31,0,0,1,7.18,13a2.36,2.36,0,0,1,1.66-.68l4.66,0A2.34,2.34,0,0,1,12.82,14Zm3.3-3.46a2.36,2.36,0,0,1-1.66.68H3.21a2.25,2.25,0,0,1,.68-1.64,2.36,2.36,0,0,1,1.66-.68H16.79A2.25,2.25,0,0,1,16.12,10.53Zm0-3.73a2.36,2.36,0,0,1-1.66.68H3.21a2.25,2.25,0,0,1,.68-1.64,2.36,2.36,0,0,1,1.66-.68H16.79A2.25,2.25,0,0,1,16.12,6.81Z"/></g></g></svg>');
563 + }
564 +
565 + public function renderFormAdminRoute()
566 + {
567 + $formId = intval($this->app->request->get('form_id'));
568 + $route = sanitize_key($this->app->request->get('route'));
569 +
570 + if ($route && $formId) {
571 + $formRoutePermissionSet = apply_filters('fluentform/form_inner_route_permission_set', [
572 + 'editor' => 'fluentform_forms_manager',
573 + 'settings' => 'fluentform_forms_manager',
574 + 'entries' => 'fluentform_entries_viewer',
575 + 'reports' => 'fluentform_entries_viewer',
576 + ]);
577 +
578 + $toVerifyPermission = ArrayHelper::get(
579 + $formRoutePermissionSet,
580 + $route,
581 + 'fluentform_forms_manager'
582 + );
583 +
584 + $hasPermission = apply_filters(
585 + 'fluentform/inner_route_has_permission',
586 + Acl::hasPermission($toVerifyPermission, $formId),
587 + $route,
588 + $formId
589 + );
590 +
591 + if ($hasPermission) {
592 + return $this->renderFormInnerPages();
593 + } else {
594 + return $this->app->view->render('admin.no_permission');
595 + }
596 + }
597 +
598 + $this->renderForms();
599 + }
600 +
601 + public function renderAllEntriesAdminRoute()
602 + {
603 + wp_enqueue_script('fluentform_all_entries');
604 + $this->app->view->render('admin.all_entries', []);
605 + }
606 +
607 + public function renderFormInnerPages()
608 + {
609 + $form_id = intval($this->app->request->get('form_id'));
610 +
611 + $form = wpFluent()->table('fluentform_forms')->find($form_id);
612 +
613 + if (!$form) {
614 + echo '<h2>' . esc_html__('No form found', 'fluentform') . '</h2>';
615 + return;
616 + }
617 +
618 + $formAdminMenus = [];
619 +
620 + if (Acl::hasPermission('fluentform_forms_manager', $form_id)) {
621 + $formAdminMenus = [
622 + 'editor' => [
623 + 'slug' => 'editor',
624 + 'title' => __('Editor', 'fluentform'),
625 + 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=editor'),
626 + ],
627 + 'settings' => [
628 + 'slug' => 'settings',
629 + 'hash' => 'basic_settings',
630 + 'title' => __('Settings & Integrations', 'fluentform'),
631 + 'sub_route' => 'form_settings',
632 + 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=settings&sub_route=form_settings'),
633 + ],
634 + ];
635 + }
636 +
637 + if (Acl::hasPermission('fluentform_entries_viewer', $form_id)) {
638 + $formAdminMenus['entries'] = [
639 + 'slug' => 'entries',
640 + 'hash' => '/',
641 + 'title' => __('Entries', 'fluentform'),
642 + 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=entries'),
643 + ];
644 + }
645 +
646 + $formAdminMenus = apply_filters_deprecated(
647 + 'fluentform_form_admin_menu',
648 + [
649 + $formAdminMenus,
650 + $form_id,
651 + $form
652 + ],
653 + FLUENTFORM_FRAMEWORK_UPGRADE,
654 + 'fluentform/form_admin_menu',
655 + 'Use fluentform/form_admin_menu instead of fluentform_form_admin_menu.'
656 + );
657 +
658 + $formAdminMenus = apply_filters('fluentform/form_admin_menu', $formAdminMenus, $form_id, $form);
659 +
660 + $route = sanitize_key($this->app->request->get('route'));
661 +
662 + $this->app->view->render('admin.form.form_wrapper', [
663 + 'route' => $route,
664 + 'form_id' => $form_id,
665 + 'form' => $form,
666 + 'menu_items' => $formAdminMenus,
667 + ]);
668 + }
669 +
670 + public function renderSettings($form_id)
671 + {
672 + $settingsMenus = [
673 + 'form_settings' => [
674 + 'title' => __('Form Settings', 'fluentform'),
675 + 'slug' => 'form_settings',
676 + 'hash' => 'basic_settings',
677 + 'route' => '/',
678 + ],
679 + 'email_notifications' => [
680 + 'title' => __('Email Notifications', 'fluentform'),
681 + 'slug' => 'form_settings',
682 + 'hash' => 'email_notifications',
683 + 'route' => '/email-settings',
684 + ],
685 + 'conditional_confirmations' => [
686 + 'title' => __('Conditional Confirmations', 'fluentform'),
687 + 'slug' => 'form_settings',
688 + 'hash' => 'conditional_confirmations',
689 + 'route' => '/conditional-confirmations',
690 + ],
691 + 'all_integrations' => [
692 + 'title' => __('Configure Integrations', 'fluentform'),
693 + 'slug' => 'form_settings',
694 + 'route' => '/all-integrations',
695 + ],
696 + ];
697 +
698 + if (Helper::isSlackEnabled()) {
699 + $settingsMenus['slack'] = [
700 + 'title' => __('Slack', 'fluentform'),
701 + 'slug' => 'form_settings',
702 + 'hash' => 'slack',
703 + 'route' => '/slack',
704 + ];
705 + }
706 +
707 + $settingsMenus = apply_filters_deprecated('fluentform_form_settings_menu', [
708 + $settingsMenus,
709 + $form_id
710 + ],
711 + FLUENTFORM_FRAMEWORK_UPGRADE,
712 + 'fluentform/form_settings_menu',
713 + 'Use fluentform/form_settings_menu instead of fluentform_form_settings_menu.'
714 + );
715 +
716 + $settingsMenus = apply_filters('fluentform/form_settings_menu', $settingsMenus, $form_id);
717 +
718 + $externalMenuItems = [];
719 + foreach ($settingsMenus as $key => $menu) {
720 + if (empty($menu['hash'])) {
721 + unset($settingsMenus[$key]);
722 + $externalMenuItems[$key] = $menu;
723 + }
724 + }
725 +
726 + $settingsMenus['custom_css_js'] = [
727 + 'title' => __('Custom CSS/JS', 'fluentform'),
728 + 'slug' => 'form_settings',
729 + 'hash' => 'custom_css_js',
730 + 'route' => '/custom-css-js',
731 + ];
732 +
733 + $settingsMenus = array_filter(array_merge($settingsMenus, $externalMenuItems));
734 +
735 + $currentRoute = sanitize_key($this->app->request->get('sub_route', ''));
736 +
737 + $hasDoubleOptinEnable = 'yes' === ArrayHelper::get(get_option('_fluentform_double_optin_settings'), 'enabled');
738 +
739 + $this->app->view->render('admin.form.settings_wrapper', [
740 + 'form_id' => $form_id,
741 + 'settings_menus' => $settingsMenus,
742 + 'current_sub_route' => $currentRoute,
743 + 'has_double_opt_in' => $hasDoubleOptinEnable
744 + ]);
745 + }
746 +
747 + /**
748 + * Remove the inactive addOn menu items
749 + *
750 + * @param string $addOn
751 + *
752 + * @return boolean
753 + */
754 + public function filterFormSettingsMenu($settingsMenus, $form_id)
755 + {
756 + if (array_key_exists('mailchimp_integration', $settingsMenus)) {
757 + $option = (array) get_option('_fluentform_mailchimp_details');
758 + if (!isset($option['status']) || !$option['status']) {
759 + unset($settingsMenus['mailchimp_integration']);
760 + }
761 + }
762 +
763 + return $settingsMenus;
764 + }
765 +
766 + public function renderFormSettings($form_id)
767 + {
768 + wp_localize_script('fluentform_form_settings', 'FluentFormApp', [
769 + 'form_id' => $form_id,
770 + 'plugin' => $this->app->config->get('app.slug'),
771 + 'hasPro' => defined('FLUENTFORMPRO'),
772 + 'hasPDF' => defined('FLUENTFORM_PDF_VERSION'),
773 + 'hasFluentCRM' => defined('FLUENTCRM'),
774 + 'upgrade_url' => fluentform_upgrade_url(),
775 + 'ace_path_url' => fluentformMix('libs/ace'),
776 + 'is_conversion_form' => Helper::isConversionForm($form_id),
777 + 'has_fluent_smtp' => defined('FLUENTMAIL'),
778 + 'fluent_smtp_url' => admin_url('admin.php?page=fluent_forms_smtp'),
779 + 'form_settings_str' => TranslationString::getSettingsI18n(),
780 + 'integrationsResource' => [
781 + 'asset_url' => fluentformMix('img/integrations.png'),
782 + 'list_url' => fluentform_integrations_url(),
783 + 'instruction' => __("Fluent Forms Pro has tons of integrations to take your forms to the next level. From payment gateways to quiz building, SMS notifications to email marketing - you'll get integrations for various purposes. Even if you don't find your favorite tools, you can integrate them easily with Zapier.", 'fluentform'),
784 + ],
785 + 'countries' => getFluentFormCountryList(),
786 + 'getIpInfo' => Helper::getIpinfo(),
787 + 'has_conv_form_save_and_resume' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.12', '>=')
788 + ]);
789 +
790 + $this->app->view->render('admin.form.settings', [
791 + 'form_id' => $form_id,
792 + ]);
793 + }
794 +
795 + public function renderForms()
796 + {
797 + if (!get_option('_fluentform_installed_version')) {
798 + (new ActivationHandler())->migrate();
799 + }
800 +
801 + if ($allowForms = FormManagerService::getUserAllowedForms()) {
802 + $formsCount = wpFluent()->table('fluentform_forms')->whereIn('id', $allowForms)->count();
803 + } else {
804 + $formsCount = wpFluent()->table('fluentform_forms')->count();
805 + }
806 +
807 + $isDisabledAnalytics = apply_filters_deprecated(
808 + 'fluentform-disabled_analytics',
809 + [
810 + true
811 + ],
812 + FLUENTFORM_FRAMEWORK_UPGRADE,
813 + 'fluentform/disabled_analytics',
814 + 'Use fluentform/disabled_analytics instead of fluentform-disabled_analytics.'
815 + );
816 +
817 + $data = [
818 + 'plugin' => $this->app->config->get('app.slug'),
819 + 'formsCount' => $formsCount,
820 + 'hasPro' => defined('FLUENTFORMPRO'),
821 + 'upgrade_url' => fluentform_upgrade_url(),
822 + 'adminUrl' => admin_url('admin.php?page=fluent_forms'),
823 + 'adminUrlWithoutPageHash' => admin_url('admin.php'),
824 + 'isDisableAnalytics' => $this->app->applyFilters('fluentform/disabled_analytics', $isDisabledAnalytics),
825 + 'plugin_public_url' => fluentformMix(),
826 + 'siteUrl' => site_url(),
827 + ];
828 +
829 + if (defined('FLUENTFORMPRO')){
830 + $data['landing_page_enabled_forms']= Helper::getLandingPageEnabledForms();
831 + }
832 +
833 +
834 + $data = apply_filters_deprecated(
835 + 'fluent_all_forms_vars',
836 + [
837 + $data
838 + ],
839 + FLUENTFORM_FRAMEWORK_UPGRADE,
840 + 'fluentform/all_forms_vars',
841 + 'Use fluentform/all_forms_vars instead of fluent_all_forms_vars.'
842 + );
843 +
844 + wp_localize_script('fluent_all_forms', 'FluentFormApp', apply_filters('fluentform/all_forms_vars', $data));
845 +
846 + $this->app->view->render('admin.all_forms', []);
847 + }
848 +
849 + public function renderEditor($form_id)
850 + {
851 + $this->app->view->render('admin.form.editor', [
852 + 'plugin' => $this->app->config->get('app.slug'),
853 + 'form_id' => $form_id,
854 + ]);
855 + }
856 +
857 + public function renderDocs()
858 + {
859 + (new DocumentationModule())->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --
860 + }
861 +
862 + public function renderAddOns()
863 + {
864 + (new AddOnModule())->render();
865 + }
866 +
867 + private function enqueueEditorAssets()
868 + {
869 + $formId = (int) $this->app->request->get('form_id');
870 +
871 + $form = wpFluent()->table('fluentform_forms')->find($formId);
872 +
873 + do_action_deprecated(
874 + 'fluentform_loading_editor_assets',
875 + [
876 + $form
877 + ],
878 + FLUENTFORM_FRAMEWORK_UPGRADE,
879 + 'fluentform/loading_editor_assets',
880 + 'Use fluentform/loading_editor_assets instead of fluentform_loading_editor_assets'
881 + );
882 +
883 + do_action('fluentform/loading_editor_assets', $form);
884 +
885 + wp_enqueue_style('fluentform_editor_sass');
886 + wp_enqueue_style('fluentform_editor_style');
887 +
888 + $pluginSlug = $this->app->config->get('app.slug');
889 +
890 + if (function_exists('wp_enqueue_editor')) {
891 + add_filter('user_can_richedit', '__return_true');
892 + wp_enqueue_editor();
893 + wp_enqueue_media();
894 + }
895 +
896 + wp_enqueue_script('fluentform_editor_script');
897 +
898 + $jsonData = $form->form_fields;
899 +
900 + if (!defined('FLUENTFORM_DISABLE_EDITOR_FILED_HOOOK')) {
901 + $formFields = $form->form_fields;
902 +
903 + if ($formFields) {
904 + $formFields = json_decode($formFields, true);
905 +
906 + foreach ($formFields['fields'] as $index => $formField) {
907 + $formField = apply_filters_deprecated(
908 + 'fluentform_editor_init_element_' . $formField['element'],
909 + [
910 + $formField,
911 + $form
912 + ],
913 + FLUENTFORM_FRAMEWORK_UPGRADE,
914 + 'fluentform/editor_init_element_' . $formField['element'],
915 + 'Use fluentform/editor_init_element_' . $formField['element'] . ' instead of fluentform_editor_init_element_' . $formField['element']
916 + );
917 +
918 + $formField = $formFields['fields'][$index] = apply_filters(
919 + 'fluentform/editor_init_element_' . $formField['element'],
920 + $formField,
921 + $form
922 + );
923 +
924 + if (!$formFields['fields'][$index]) {
925 + unset($formFields['fields'][$index]);
926 + continue;
927 + }
928 +
929 + if ('container' == $formField['element']) {
930 + $columns = $formField['columns'];
931 + foreach ($columns as $columnIndex => $column) {
932 + foreach ($column['fields'] as $fieldIndex => $columnField) {
933 + $columnField = apply_filters_deprecated(
934 + 'fluentform_editor_init_element_' . $columnField['element'],
935 + [
936 + $columnField,
937 + $form
938 + ],
939 + FLUENTFORM_FRAMEWORK_UPGRADE,
940 + 'fluentform/editor_init_element_' . $columnField['element'],
941 + 'Use fluentform/editor_init_element_' . $columnField['element'] . ' instead of fluentform_editor_init_element_' . $columnField['element']
942 + );
943 +
944 + $columns[$columnIndex]['fields'][$fieldIndex] = apply_filters(
945 + 'fluentform/editor_init_element_' . $columnField['element'],
946 + $columnField,
947 + $form
948 + );
949 +
950 + if (!$columns[$columnIndex]['fields'][$fieldIndex]) {
951 + unset($columns[$columnIndex]['fields'][$fieldIndex]);
952 + }
953 + }
954 + }
955 +
956 + $formFields['fields'][$index]['columns'] = array_values($columns);
957 + }
958 + }
959 +
960 + $formFields['fields'] = array_values($formFields['fields']);
961 + $formFields = json_encode($formFields, true);
962 + }
963 +
964 + $form->form_fields = $formFields;
965 + }
966 +
967 + $searchTags = fluentformLoadFile('Services/FormBuilder/ElementSearchTags.php');
968 +
969 + $searchTags = apply_filters_deprecated(
970 + 'fluentform_editor_element_search_tags',
971 + [
972 + $searchTags
973 + ],
974 + FLUENTFORM_FRAMEWORK_UPGRADE,
975 + 'fluentform/editor_element_search_tags',
976 + 'Use fluentform/editor_element_search_tags instead of fluent_editor_element_search_tags.'
977 + );
978 + $searchTags = apply_filters('fluentform/editor_element_search_tags', $searchTags, $form);
979 +
980 + $elementPlacements = fluentformLoadFile('Services/FormBuilder/ElementSettingsPlacement.php');
981 + $elementPlacements = apply_filters_deprecated(
982 + 'fluentform_editor_element_settings_placement',
983 + [
984 + $elementPlacements,
985 + $form
986 + ],
987 + FLUENTFORM_FRAMEWORK_UPGRADE,
988 + 'fluentform/editor_element_settings_placement',
989 + 'Use fluentform/editor_element_settings_placement instead of fluent_editor_element_settings_placement.'
990 + );
991 +
992 + $elementPlacements = apply_filters(
993 + 'fluentform/editor_element_settings_placement',
994 + $elementPlacements,
995 + $form
996 + );
997 + $data = [
998 + 'plugin' => $pluginSlug,
999 + 'form_id' => $formId,
1000 + 'plugin_public_url' => fluentformMix(),
1001 + 'preview_url' => Helper::getPreviewUrl($formId),
1002 + 'form' => $form,
1003 + 'hasPro' => defined('FLUENTFORMPRO'),
1004 + 'countries' => getFluentFormCountryList(),
1005 + 'element_customization_settings' => fluentformLoadFile('Services/FormBuilder/ElementCustomization.php'),
1006 + 'validation_rule_settings' => fluentformLoadFile('Services/FormBuilder/ValidationRuleSettings.php'),
1007 + 'conversational_form_fields' => array_keys(Converter::fieldTypes()),
1008 + 'form_editor_str' => TranslationString::getEditorI18n(),
1009 + 'element_search_tags' => $searchTags,
1010 + 'element_settings_placement' => $elementPlacements,
1011 + 'all_forms_url' => admin_url('admin.php?page=fluent_forms'),
1012 + 'has_payment_features' => true,
1013 + 'upgrade_url' => fluentform_upgrade_url(),
1014 + 'is_conversion_form' => Helper::isConversionForm($formId),
1015 + 'is_autoload_captcha' => Helper::isAutoloadCaptchaEnabled(),
1016 + 'autosave_enabled' => Helper::isAutosaveEnabled(),
1017 + 'used_name_attributes' => $this->usedNameAttributes($formId),
1018 + 'bulk_options_json' => '{"Countries":["Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antarctica","Antigua and Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bonaire, Sint Eustatius and Saba","Bosnia and Herzegovina","Botswana","Bouvet Island","Brazil","British Indian Ocean Territory","Brunei Darussalam","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Central African Republic","Chad","Chile","China","Christmas Island","Cocos Islands","Colombia","Comoros","Congo, Democratic Republic of the","Congo, Republic of the","Cook Islands","Costa Rica","Croatia","Cuba","Cura\u00e7ao","Cyprus","Czech Republic","C\u00f4te d\'Ivoire","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Eswatini (Swaziland)","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","French Southern Territories","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guam","Guatemala","Guernsey","Guinea","Guinea-Bissau","Guyana","Haiti","Heard and McDonald Islands","Holy See","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kiribati","Kuwait","Kyrgyzstan","Lao People\'s Democratic Republic","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania","Mauritius","Mayotte","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Niue","Norfolk Island","North Korea","Northern Mariana Islands","Norway","Oman","Pakistan","Palau","Palestine, State of","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Pitcairn","Poland","Portugal","Puerto Rico","Qatar","Romania","Russia","Rwanda","R\u00e9union","Saint Barth\u00e9lemy","Saint Helena","Saint Kitts and Nevis","Saint Lucia","Saint Martin","Saint Pierre and Miquelon","Saint Vincent and the Grenadines","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Sint Maarten","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","South Georgia","South Korea","South Sudan","Spain","Sri Lanka","Sudan","Suriname","Svalbard and Jan Mayen Islands","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor-Leste","Togo","Tokelau","Tonga","Trinidad and Tobago","Tunisia","Türkiye","Turkmenistan","Turks and Caicos Islands","Tuvalu","US Minor Outlying Islands","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Venezuela","Vietnam","Virgin Islands, British","Virgin Islands, U.S.","Wallis and Futuna","Western Sahara","Yemen","Zambia","Zimbabwe","\u00c5land Islands"],"U.S. States":["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District of Columbia","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming","Armed Forces Americas","Armed Forces Europe","Armed Forces Pacific"],"Canadian Province\/Territory":["Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon"],"Continents":["Africa","Antarctica","Asia","Australia","Europe","North America","South America"],"Gender":["Male","Female","Prefer Not to Answer"],"Age":["Under 18","18-24","25-34","35-44","45-54","55-64","65 or Above","Prefer Not to Answer"],"Marital Status":["Single","Married","Divorced","Widowed"],"Employment":["Employed Full-Time","Employed Part-Time","Self-employed","Not employed but looking for work","Not employed and not looking for work","Homemaker","Retired","Student","Prefer Not to Answer"],"Job Type":["Full-Time","Part-Time","Per Diem","Employee","Temporary","Contract","Intern","Seasonal"],"Industry":["Accounting\/Finance","Advertising\/Public Relations","Aerospace\/Aviation","Arts\/Entertainment\/Publishing","Automotive","Banking\/Mortgage","Business Development","Business Opportunity","Clerical\/Administrative","Construction\/Facilities","Consumer Goods","Customer Service","Education\/Training","Energy\/Utilities","Engineering","Government\/Military","Green","Healthcare","Hospitality\/Travel","Human Resources","Installation\/Maintenance","Insurance","Internet","Job Search Aids","Law Enforcement\/Security","Legal","Management\/Executive","Manufacturing\/Operations","Marketing","Non-Profit\/Volunteer","Pharmaceutical\/Biotech","Professional Services","QA\/Quality Control","Real Estate","Restaurant\/Food Service","Retail","Sales","Science\/Research","Skilled Labor","Technology","Telecommunications","Transportation\/Logistics","Other"],"Education":["High School","Associate Degree","Bachelor\'s Degree","Graduate or Professional Degree","Some College","Other","Prefer Not to Answer"],"Days of the Week":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"Months of the Year":["January","February","March","April","May","June","July","August","September","October","November","December"],"How Often":["Every day","Once a week","2 to 3 times a week","Once a month","2 to 3 times a month","Less than once a month"],"How Long":["Less than a month","1-6 months","1-3 years","Over 3 years","Never used"],"Satisfaction":["Very Satisfied","Satisfied","Neutral","Unsatisfied","Very Unsatisfied"],"Importance":["Very Important","Important","Somewhat Important","Not Important"],"Agreement":["Strongly Agree","Agree","Disagree","Strongly Disagree"],"Comparison":["Much Better","Somewhat Better","About the Same","Somewhat Worse","Much Worse"],"Would You":["Definitely","Probably","Not Sure","Probably Not","Definitely Not"],"Size":["Extra Small","Small","Medium","Large","Extra Large"],"Timezone":["(GMT -12-00) Eniwetok, Kwajalein:-12","(GMT -11-00) Midway Island, Samoa:-11","(GMT -10-00) Hawaii:-10","(GMT -9-00) Alaska:-9","(GMT -8-00) Pacific Time (US & Canada):-8","(GMT -7-00) Mountain Time (US & Canada):-7","(GMT -6-00) Central Time (US & Canada), Mexico City:-6","(GMT -5-00) Eastern Time (US & Canada), Bogota, Lima:-5","(GMT -4-00) Atlantic Time (Canada), Caracas, La Paz:-4","(GMT -3-30) Newfoundland:-3.5","(GMT -3-00) Brazil, Buenos Aires, Georgetown:-3","(GMT -2-00) Mid-Atlantic:-2","(GMT -1-00) Azores, Cape Verde Islands:-1","(GMT) Western Europe Time, London, Lisbon, Casablanca:0","(GMT +1-00) Brussels, Copenhagen, Madrid, Paris:1","(GMT +2-00) Kaliningrad, South Africa:2","(GMT +3-00) Baghdad, Riyadh, Moscow, St. Petersburg:3","(GMT +3-30) Tehran:3.5","(GMT +4-00) Abu Dhabi, Muscat, Baku, Tbilisi:4","(GMT +4-30) Kabul:4.5","(GMT +5-00) Ekaterinburg, Islamabad, Karachi, Tashkent:5","(GMT +5-30) Bombay, Calcutta, Madras, New Delhi:5.5","(GMT +5-45) Kathmandu:5.75","(GMT +6-00) Almaty, Dhaka, Colombo:6","(GMT +7-00) Bangkok, Hanoi, Jakarta:7","(GMT +8-00) Beijing, Perth, Singapore, Hong Kong:8","(GMT +9-00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk:9","(GMT +9-30) Adelaide, Darwin:9.5","(GMT +10-00) Eastern Australia, Guam, Vladivostok:10","(GMT +11-00) Magadan, Solomon Islands, New Caledonia:11","(GMT +12-00) Auckland, Wellington, Fiji, Kamchatka:12"]}',
1019 + ];
1020 +
1021 + // if has pro and payment enable. We will use this filter hook to push custom elements
1022 + if (defined('FLUENTFORMPRO')) {
1023 + $data['calc_items'] = [
1024 + 'paymentElements' => [
1025 + 'multi_payment_component',
1026 + 'input_number',
1027 + 'repeater_field',
1028 + 'net_promoter_score',
1029 + 'rangeslider',
1030 + 'custom_payment_component',
1031 + 'item_quantity_component'
1032 + ]
1033 + ];
1034 + }
1035 +
1036 + $data = apply_filters_deprecated(
1037 + 'fluentform_editor_vars',
1038 + [
1039 + $data
1040 + ],
1041 + FLUENTFORM_FRAMEWORK_UPGRADE,
1042 + 'fluentform/editor_vars',
1043 + 'Use fluentform/editor_vars instead of fluentform_editor_vars.'
1044 + );
1045 +
1046 + wp_localize_script('fluentform_editor_script', 'FluentFormApp', apply_filters('fluentform/editor_vars', $data));
1047 +
1048 + do_action('fluentform/editor_script_loaded', $form);
1049 + }
1050 +
1051 + /**
1052 + * Render global settings page.
1053 + *
1054 + * @throws \Exception
1055 + */
1056 + public function renderGlobalSettings()
1057 + {
1058 + if (function_exists('wp_enqueue_editor')) {
1059 + add_filter('user_can_richedit', '__return_true');
1060 + wp_enqueue_editor();
1061 + wp_enqueue_media();
1062 + }
1063 +
1064 + // Fire an event letting others know the current component
1065 + // that fluentform is rendering for the global settings
1066 + // page. So that they can hook and load their custom
1067 + // components on this page dynamically & easily.
1068 + // N.B. native 'components' will always use
1069 + // 'settings' as their current component.
1070 + $currentComponent = $this->app->request->get('component', 'settings');
1071 +
1072 + $currentComponent = apply_filters_deprecated('fluentform_global_settings_current_component', [
1073 + $currentComponent
1074 + ],
1075 + FLUENTFORM_FRAMEWORK_UPGRADE,
1076 + 'fluentform/global_settings_current_component',
1077 + 'Use fluentform/global_settings_current_component instead of fluentform_global_settings_current_component.'
1078 + );
1079 +
1080 + $currentComponent = apply_filters(
1081 + 'fluentform/global_settings_current_component',
1082 + $currentComponent
1083 + );
1084 +
1085 + $currentComponent = sanitize_key($currentComponent);
1086 + $components = [];
1087 + $components = apply_filters_deprecated('fluentform_global_settings_components', [
1088 + $components
1089 + ],
1090 + FLUENTFORM_FRAMEWORK_UPGRADE,
1091 + 'fluentform/global_settings_components',
1092 + 'Use fluentform/global_settings_components instead of fluentform_global_settings_components.'
1093 + );
1094 +
1095 + $components = apply_filters('fluentform/global_settings_components', $components);
1096 +
1097 + $components['reCAPTCHA'] = [
1098 + 'hash' => 're_captcha',
1099 + 'title' => 'reCAPTCHA',
1100 + ];
1101 +
1102 + $components['hCAPTCHA'] = [
1103 + 'hash' => 'h_captcha',
1104 + 'title' => 'hCaptcha',
1105 + ];
1106 +
1107 + $components['Turnstile'] = [
1108 + 'hash' => 'turnstile',
1109 + 'title' => 'Turnstile',
1110 + ];
1111 +
1112 + $components['CleanTalk'] = [
1113 + 'hash' => 'cleantalk',
1114 + 'title' => 'CleanTalk',
1115 + ];
1116 +
1117 + $customLinks = apply_filters('fluentform/global_settings_menu', []);
1118 + $this->app->view->render('admin.globalSettings.menu', [
1119 + 'components' => $components,
1120 + 'customLinks' => $customLinks,
1121 + 'currentComponent' => $currentComponent,
1122 + ]);
1123 + }
1124 +
1125 + public function renderTransfer()
1126 + {
1127 + $allowForms = FormManagerService::getUserAllowedForms();
1128 + $forms = wpFluent()->table('fluentform_forms')
1129 + ->orderBy('id', 'desc')
1130 + ->select(['id', 'title'])
1131 + ->when($allowForms, function ($q) use ($allowForms){
1132 + return $q->whereIn('id', $allowForms);
1133 + })
1134 + ->get();
1135 +
1136 + wp_localize_script('fluentform-transfer-js', 'FluentFormApp', [
1137 + 'plugin' => $this->app->config->get('app.slug'),
1138 + 'forms' => $forms,
1139 + 'upgrade_url' => fluentform_upgrade_url(),
1140 + 'hasPro' => defined('FLUENTFORMPRO'),
1141 + 'transfer_str' => TranslationString::getTransferModuleI18n(),
1142 + 'source_query' => sanitize_text_field($this->app->request->get('source')),
1143 + 'status_query' => sanitize_text_field($this->app->request->get('status')),
1144 + 'date_start_query' => sanitize_text_field($this->app->request->get('start_date')),
1145 + 'date_end_query' => sanitize_text_field($this->app->request->get('end_date')),
1146 + 'has_entries_import' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.7', '>='),
1147 + ]);
1148 +
1149 + $this->app->view->render('admin.tools.index');
1150 + }
1151 +
1152 + public function addPreviewButton($formId)
1153 + {
1154 + $previewUrl = Helper::getPreviewUrl($formId);
1155 + $previewText = __('Preview & Design', 'fluentform');
1156 + $formId = (int)$formId;
1157 + if (Helper::isConversionForm($formId)) {
1158 + $previewText = __('Preview', 'fluentform');
1159 + }
1160 + echo '<a target="_blank" class="el-button el-button--info is-plain" href="' . esc_url($previewUrl) . '">' . '<i class="ff-icon ff-icon-eye-filled fs-15"></i> ' . '<span>' . esc_attr($previewText) . '</span>' . '</a>';
1161 + }
1162 +
1163 + public function addCopyShortcodeButton($formId)
1164 + {
1165 + $formId = (int) $formId;
1166 + $shortcode = '[fluentform id="' . $formId . '"]';
1167 + if (Helper::isConversionForm($formId)) {
1168 + $shortcode = '[fluentform type="conversational" id="' . $formId . '"]';
1169 + }
1170 + echo '<button title="Click to Copy" class="ff_shortcode_btn ff_shortcode_btn_md copy truncate" data-clipboard-text=\'' . $shortcode . '\'><i class="el-icon el-icon-document-copy"></i> ' . $shortcode . '</button>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $shortcode is escaped before being passed in.
1171 + return;
1172 + }
1173 +
1174 + public function commonAction()
1175 + {
1176 + $fluentFormPages = [
1177 + 'fluent_forms',
1178 + 'fluent_forms_transfer',
1179 + 'fluent_forms_settings',
1180 + 'fluent_forms_add_ons',
1181 + 'fluent_forms_docs',
1182 + 'fluent_forms_smtp',
1183 + ];
1184 +
1185 + $page = sanitize_text_field($this->app->request->get('page'));
1186 +
1187 + if ($page && in_array($page, $fluentFormPages)) {
1188 + // Let's deregister existing vuejs by other devs
1189 + // Other devs should not regis
1190 + add_action('admin_print_scripts', function () {
1191 + wp_dequeue_script('vuejs');
1192 + wp_dequeue_script('vue');
1193 + wp_deregister_script('elementor-admin-app');
1194 + });
1195 + }
1196 + }
1197 +
1198 + public function renderGlobalMenu()
1199 + {
1200 + $showPayment = !PaymentHelper::hasPaymentSettings();
1201 + if ($showPayment) {
1202 + $formCount = wpFluent()->table('fluentform_forms')
1203 + ->count();
1204 + $showPayment = $formCount > 2;
1205 + }
1206 + $showPaymentEntry = apply_filters_deprecated('fluentform_show_payment_entries', [
1207 + false
1208 + ],
1209 + FLUENTFORM_FRAMEWORK_UPGRADE,
1210 + 'fluentform/show_payment_entries',
1211 + 'Use fluentform/show_payment_entries instead of fluentform/show_payment_entries.'
1212 + );
1213 +
1214 + $this->app->view->render('admin.global_menu', [
1215 + 'logo' => fluentformMix('img/fluentform-logo.svg'),
1216 + 'show_payment' => $showPayment,
1217 + 'show_payment_entries' => apply_filters('fluentform/show_payment_entries', $showPaymentEntry),
1218 + ]);
1219 + }
1220 +
1221 + public function renderPaymentEntries()
1222 + {
1223 + do_action_deprecated(
1224 + 'flunetform_render_payment_entries', [],
1225 + FLUENTFORM_FRAMEWORK_UPGRADE,
1226 + 'fluentform/render_payment_entries',
1227 + 'Use fluentform/render_payment_entries instead of flunetform/render_payment_entries'
1228 + );
1229 +
1230 + do_action('fluentform/render_payment_entries');
1231 + }
1232 +
1233 + public function renderSmtpPromo()
1234 + {
1235 + wp_enqueue_script('fluentform_admin_notice', fluentformMix('js/admin_notices.js'), [
1236 + 'jquery',
1237 + ], FLUENTFORM_VERSION, true);
1238 +
1239 + $this->app->view->render('admin.smtp.index', [
1240 + 'logo' => fluentformMix('img/fluentsmtp.svg'),
1241 + 'banner_image' => fluentformMix('img/fluentsmtp-banner.png'),
1242 + 'is_installed' => defined('FLUENTMAIL'),
1243 + 'setup_url' => admin_url('options-general.php?page=fluent-mail#/connections'),
1244 + ]);
1245 + }
1246 +
1247 + public function renderReports()
1248 + {
1249 + do_action('fluentform/render_report');
1250 + }
1251 +
1252 + private function usedNameAttributes($formId)
1253 + {
1254 + return wpFluent()->table('fluentform_entry_details')
1255 + ->select(['field_name'])
1256 + ->where('form_id', $formId)
1257 + ->orderBy('submission_id', 'desc')
1258 + ->groupBy('field_name')
1259 + ->get();
1260 + }
1261 + }
1262 +