PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
6.2.14 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 All 196 releases
← All changes | app/Modules/EditorButtonModule.php +63 -54 3.6.226.2.14 View file →
@@ -1,69 +1,78 @@
1 -<?php namespace FluentForm\App\Modules;
1 +<?php
2 2
3 -use FluentForm\App;
4 -use FluentForm\Config;
3 +namespace FluentForm\App\Modules;
4 +
5 5 use FluentForm\Framework\Helpers\ArrayHelper;
6 -use FluentForm\Request;
7 -use FluentForm\View;
8 6
9 7 class EditorButtonModule
10 8 {
11 - public function addButton()
12 - {
13 - if (! $this->pageSupportedMediaButtons()) {
14 - return;
15 - }
9 + public function addButton()
10 + {
11 + if (! $this->pageSupportedMediaButtons()) {
12 + return;
13 + }
16 14
17 - $this->addMceButtonAssets();
15 + $this->addMceButtonAssets();
18 16
19 - $label = __('Add Form', 'fluentform');
20 - $url = App::publicUrl('img/icon_black_small.png');
21 - echo "<button id='fluent_form_insert_button' class='button'><span style='background-image: 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>{$label}</button>";
22 - }
23 -
24 - private function addMceButtonAssets()
25 - {
26 - wp_enqueue_script(
27 - 'fluentform_editor_script',
28 - fluentformMix('js/fluentform_editor_script.js'),
29 - array('jquery'),
30 - FLUENTFORM_VERSION
31 - );
17 + $url = fluentformMix('img/icon_black_small.png');
32 18
33 - $forms = wpFluent()->table('fluentform_forms')
34 - ->select(array('id', 'title'))
35 - ->get();
36 -
37 - $forms = array_map(function($item) {
38 - return array('value' => $item->id, 'text'=> $item->title);
39 - }, $forms);
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>" . esc_html__('Add Form', 'fluentform') . '</button>';
20 + }
40 21
41 - wp_localize_script('fluentform_editor_script', 'fluentform_editor_vars', array(
42 - 'forms' => $forms
43 - ));
44 - }
45 -
46 - private function pageSupportedMediaButtons()
47 - {
48 - $currentPage = basename( $_SERVER['PHP_SELF'] );
49 - $isEligiblePage = in_array( $currentPage, array(
50 - 'post.php',
51 - 'page.php',
52 - 'page-new.php',
53 - 'post-new.php',
54 - 'customize.php',
55 - ));
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 + false
30 + );
56 31
57 - if ($isEligiblePage) {
32 + $forms = wpFluent()->table('fluentform_forms')
33 + ->select(['id', 'title'])
34 + ->get();
35 +
36 + $forms = $forms->map(function ($item) {
37 + return ['value' => $item->id, 'text' => $item->title];
38 + })->all();
39 +
40 + wp_localize_script('fluentform_editor_script', 'fluentform_editor_vars', [
41 + 'forms' => $forms,
42 + ]);
43 + }
44 +
45 + private function pageSupportedMediaButtons()
46 + {
47 + $currentPage = basename(sanitize_text_field(wpFluentForm('request')->server('PHP_SELF')));
48 + $isEligiblePage = in_array($currentPage, [
49 + 'post.php',
50 + 'page.php',
51 + 'page-new.php',
52 + 'post-new.php',
53 + 'customize.php',
54 + ]);
55 +
56 + if ($isEligiblePage) {
58 57 $option = get_option('_fluentform_global_form_settings');
59 - $isEligiblePage = ArrayHelper::get($option, 'misc.classicEditorButton') == 'yes';
58 + $isEligiblePage = 'yes' == ArrayHelper::get($option, 'misc.classicEditorButton');
60 59 }
60 +
61 + $isEligiblePage = apply_filters_deprecated(
62 + 'fluentform_display_add_form_button',
63 + [
64 + $isEligiblePage
65 + ],
66 + FLUENTFORM_FRAMEWORK_UPGRADE,
67 + 'fluentform/display_add_form_button',
68 + 'Use fluentform/display_add_form_button instead of fluentform_display_add_form_button'
69 + );
61 70
62 - return apply_filters( 'fluentform_display_add_form_button', $isEligiblePage );
63 - }
71 + return apply_filters('fluentform/display_add_form_button', $isEligiblePage);
72 + }
64 73
65 - private function getMenuIcon()
66 - {
67 - 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>');
68 - }
74 + private function getMenuIcon()
75 + {
76 + 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>');
77 + }
69 78 }