PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 5.2.1
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v5.2.1
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / app / Modules / EditorButtonModule.php

EditorButtonModule.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 5.2.1, at app/Modules/EditorButtonModule.php

78 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules;
4
5 use FluentForm\Framework\Helpers\ArrayHelper;
6
7 class EditorButtonModule
8 {
9 public function addButton()
10 {
11 if (! $this->pageSupportedMediaButtons()) {
12 return;
13 }
14
15 $this->addMceButtonAssets();
16
17 $url = fluentformMix('img/icon_black_small.png');
18
19 echo "<button id='fluent_form_insert_button' class='button'><span style='background-image: url(" . esc_url($url) . "); width: 16px;height: 16px;background-repeat: no-repeat;display: inline-block;background-size: contain;opacity: 0.4;margin-right: 5px;vertical-align: middle;'></span>" . __('Add Form', 'fluentform') . '</button>';
20 }
21
22 private function addMceButtonAssets()
23 {
24 wp_enqueue_script(
25 'fluentform_editor_script',
26 fluentformMix('js/fluentform_editor_script.js'),
27 ['jquery'],
28 FLUENTFORM_VERSION
29 );
30
31 $forms = wpFluent()->table('fluentform_forms')
32 ->select(['id', 'title'])
33 ->get();
34
35 $forms = array_map(function ($item) {
36 return ['value' => $item->id, 'text' => $item->title];
37 }, $forms);
38
39 wp_localize_script('fluentform_editor_script', 'fluentform_editor_vars', [
40 'forms' => $forms,
41 ]);
42 }
43
44 private function pageSupportedMediaButtons()
45 {
46 $currentPage = basename(sanitize_text_field(wpFluentForm('request')->server('PHP_SELF')));
47 $isEligiblePage = in_array($currentPage, [
48 'post.php',
49 'page.php',
50 'page-new.php',
51 'post-new.php',
52 'customize.php',
53 ]);
54
55 if ($isEligiblePage) {
56 $option = get_option('_fluentform_global_form_settings');
57 $isEligiblePage = 'yes' == ArrayHelper::get($option, 'misc.classicEditorButton');
58 }
59
60 $isEligiblePage = apply_filters_deprecated(
61 'fluentform_display_add_form_button',
62 [
63 $isEligiblePage
64 ],
65 FLUENTFORM_FRAMEWORK_UPGRADE,
66 'fluentform/display_add_form_button',
67 'Use fluentform/display_add_form_button instead of fluentform_display_add_form_button'
68 );
69
70 return apply_filters('fluentform/display_add_form_button', $isEligiblePage);
71 }
72
73 private function getMenuIcon()
74 {
75 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>');
76 }
77 }
78