PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.01.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.01.02
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmSimpleBlocksController.php +6 -64 6.54.01.02 View file →
@@ -1,15 +1,10 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 class FrmSimpleBlocksController {
7 4
8 5 /**
9 6 * Enqueue Formidable Simple Blocks' js and CSS for editor in admin.
10 - *
11 - * @return void
12 7 */
13 8 public static function block_editor_assets() {
14 9 $version = FrmAppHelper::plugin_version();
15 10
@@ -15,37 +10,23 @@
15 10
16 11 wp_register_script(
17 12 'formidable-form-selector',
18 13 FrmAppHelper::plugin_url() . '/js/formidable_blocks.js',
19 - array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-block-editor' ),
14 + array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
20 15 $version,
21 16 true
22 17 );
23 18
24 - $icon = apply_filters( 'frm_icon', 'svg' );
25 - if ( 0 === strpos( $icon, 'data:image/svg+xml;base64,' ) ) {
26 - $icon = ' ' . FrmAppHelper::get_menu_icon_class();
27 - } else {
28 - $icon = str_replace( 'dashicons-', '', $icon );
29 - }
30 -
19 + $icon = str_replace( 'dashicons-', '', apply_filters( 'frm_icon', 'svg' ) );
31 20 $block_name = FrmAppHelper::get_menu_name();
32 21 if ( $block_name === 'Formidable' ) {
33 22 $block_name = 'Formidable Forms';
34 23 }
35 24
36 - $modal_addon = self::get_modal_addon_info();
37 -
38 25 $script_vars = array(
39 26 'forms' => self::get_forms_options(),
40 27 'icon' => $icon,
41 28 'name' => $block_name,
42 - 'link' => FrmAppHelper::admin_upgrade_link( 'block' ),
43 - 'url' => FrmAppHelper::plugin_url(),
44 - 'modalAddon' => array(
45 - 'link' => FrmAppHelper::admin_upgrade_link( 'block', $modal_addon['link'] ),
46 - 'hasAccess' => ! empty( $modal_addon['url'] ),
47 - ),
48 29 );
49 30
50 31 wp_localize_script( 'formidable-form-selector', 'formidable_form_selector', $script_vars );
51 32 if ( function_exists( 'wp_set_script_translations' ) ) {
@@ -60,27 +41,8 @@
60 41 );
61 42 }
62 43
63 44 /**
64 - * Gets the modal addon info.
65 - *
66 - * @since 6.3.2
67 - *
68 - * @return array|false
69 - */
70 - private static function get_modal_addon_info() {
71 - $api = new FrmFormApi();
72 - $addons = $api->get_api_info();
73 - $addon_id = 185013;
74 -
75 - if ( ! is_array( $addons ) || ! array_key_exists( $addon_id, $addons ) ) {
76 - return false;
77 - }
78 -
79 - return $addons[ $addon_id ];
80 - }
81 -
82 - /**
83 45 * Returns a filtered list of form options with the name as label and the id as value, sorted by label
84 46 *
85 47 * @return array
86 48 */
@@ -109,9 +71,9 @@
109 71 * @return array
110 72 */
111 73 private static function set_form_options( $form ) {
112 74 return array(
113 - 'label' => FrmFormsHelper::edit_form_link_label( $form ),
75 + 'label' => $form->name,
114 76 'value' => $form->id,
115 77 );
116 78 }
117 79
@@ -116,10 +78,8 @@
116 78 }
117 79
118 80 /**
119 81 * Registers simple form block
120 - *
121 - * @return void
122 82 */
123 83 public static function register_simple_form_block() {
124 84 if ( ! is_callable( 'register_block_type' ) ) {
125 85 return;
@@ -159,9 +119,10 @@
159 119
160 120 /**
161 121 * Renders a form given the specified attributes.
162 122 *
163 - * @param array $attributes
123 + * @param $attributes
124 + *
164 125 * @return string
165 126 */
166 127 public static function simple_form_render( $attributes ) {
167 128 if ( ! isset( $attributes['formId'] ) ) {
@@ -167,32 +128,13 @@
167 128 if ( ! isset( $attributes['formId'] ) ) {
168 129 return '';
169 130 }
170 131
171 - /**
172 - * @since 5.5.2
173 - * @param array $attributes
174 - */
175 - do_action( 'frm_before_simple_form_render', $attributes );
176 -
177 132 $params = array_filter( $attributes );
178 133 $params['id'] = $params['formId'];
179 134 unset( $params['formId'] );
180 135
181 136 $form = FrmFormsController::get_form_shortcode( $params );
182 - return self::maybe_remove_fade_on_load_for_block_preview( $form );
183 - }
184 137
185 - /**
186 - * Remove fade on load when /wp-json/wp/v2/block-renderer/formidable/simple-form is called.
187 - * With the class set, the form never appears in the form block preview.
188 - *
189 - * @param string $form
190 - * @return string
191 - */
192 - private static function maybe_remove_fade_on_load_for_block_preview( $form ) {
193 - if ( is_callable( 'wp_is_json_request' ) && wp_is_json_request() ) {
194 - $form = str_replace( ' frm_logic_form ', ' ', $form );
195 - }
196 - return $form;
138 + return str_replace( ' frm_logic_form ', ' ', $form ); // prevent the form from hiding
197 139 }
198 140 }