PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.17
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.17
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 4.3.17, at app/Modules/EditorButtonModule.php

72 lines 2.9 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\App;
6 use FluentForm\Config;
7 use FluentForm\Framework\Helpers\ArrayHelper;
8 use FluentForm\Request;
9 use FluentForm\View;
10
11 class EditorButtonModule
12 {
13 public function addButton()
14 {
15 if (! $this->pageSupportedMediaButtons()) {
16 return;
17 }
18
19 $this->addMceButtonAssets();
20
21 $url = App::publicUrl('img/icon_black_small.png');
22
23 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>';
24 }
25
26 private function addMceButtonAssets()
27 {
28 wp_enqueue_script(
29 'fluentform_editor_script',
30 fluentformMix('js/fluentform_editor_script.js'),
31 ['jquery'],
32 FLUENTFORM_VERSION
33 );
34
35 $forms = wpFluent()->table('fluentform_forms')
36 ->select(['id', 'title'])
37 ->get();
38
39 $forms = array_map(function ($item) {
40 return ['value' => $item->id, 'text' => $item->title];
41 }, $forms);
42
43 wp_localize_script('fluentform_editor_script', 'fluentform_editor_vars', [
44 'forms' => $forms,
45 ]);
46 }
47
48 private function pageSupportedMediaButtons()
49 {
50 $currentPage = basename(sanitize_text_field(wpFluentForm('request')->server('PHP_SELF')));
51 $isEligiblePage = in_array($currentPage, [
52 'post.php',
53 'page.php',
54 'page-new.php',
55 'post-new.php',
56 'customize.php',
57 ]);
58
59 if ($isEligiblePage) {
60 $option = get_option('_fluentform_global_form_settings');
61 $isEligiblePage = 'yes' == ArrayHelper::get($option, 'misc.classicEditorButton');
62 }
63
64 return apply_filters('fluentform_display_add_form_button', $isEligiblePage);
65 }
66
67 private function getMenuIcon()
68 {
69 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>');
70 }
71 }
72