PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 +12 -82 6.255.0 View file →
@@ -6,10 +6,8 @@
6 6 class FrmSimpleBlocksController {
7 7
8 8 /**
9 9 * Enqueue Formidable Simple Blocks' js and CSS for editor in admin.
10 - *
11 - * @return void
12 10 */
13 11 public static function block_editor_assets() {
14 12 $version = FrmAppHelper::plugin_version();
15 13
@@ -15,51 +13,25 @@
15 13
16 14 wp_register_script(
17 15 'formidable-form-selector',
18 16 FrmAppHelper::plugin_url() . '/js/formidable_blocks.js',
19 - array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-block-editor' ),
17 + array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
20 18 $version,
21 19 true
22 20 );
23 21
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 -
22 + $icon = str_replace( 'dashicons-', '', apply_filters( 'frm_icon', 'svg' ) );
31 23 $block_name = FrmAppHelper::get_menu_name();
32 24 if ( $block_name === 'Formidable' ) {
33 25 $block_name = 'Formidable Forms';
34 26 }
35 27
36 - $modal_addon = self::get_addon_info( 185013 );
37 - $charts_addon = self::get_addon_info( 28248560 );
38 - $views_addon = FrmAddonsController::get_addon( 'views' );
39 - $views_addon_info = self::get_addon_info( 28027505 );
40 -
41 28 $script_vars = array(
42 - 'forms' => self::get_forms_options(),
43 - 'icon' => $icon,
44 - 'name' => $block_name,
45 - 'link' => FrmAppHelper::admin_upgrade_link( 'block' ),
46 - 'url' => FrmAppHelper::plugin_url(),
47 - 'modalAddon' => array(
48 - 'link' => is_array( $modal_addon ) && isset( $modal_addon['link'] ) ? FrmAppHelper::admin_upgrade_link( 'block', $modal_addon['link'] ) : '',
49 - 'hasAccess' => is_array( $modal_addon ) && ! empty( $modal_addon['url'] ),
50 - ),
51 - 'viewsAddon' => array(
52 - 'link' => is_array( $views_addon_info ) && isset( $views_addon_info['link'] ) ? FrmAppHelper::admin_upgrade_link( 'block', $views_addon_info['link'] ) : '',
53 - 'hasAccess' => is_array( $views_addon_info ) && ! empty( $views_addon_info['url'] ),
54 - 'url' => ! empty( $views_addon_info['url'] ) ? $views_addon_info['url'] : '',
55 - 'installed' => is_array( $views_addon ) && 'installed' === $views_addon['status']['type'],
56 - ),
57 - 'chartsAddon' => array(
58 - 'link' => is_array( $charts_addon ) && isset( $charts_addon['link'] ) ? FrmAppHelper::admin_upgrade_link( 'block', $charts_addon['link'] ) : '',
59 - 'hasAccess' => is_array( $charts_addon ) && ! empty( $charts_addon['url'] ),
60 - 'installed' => class_exists( 'FrmChartsAppController' ),
61 - ),
29 + 'forms' => self::get_forms_options(),
30 + 'icon' => $icon,
31 + 'name' => $block_name,
32 + 'link' => FrmAppHelper::admin_upgrade_link( 'block' ),
33 + 'url' => FrmAppHelper::plugin_url(),
62 34 );
63 35
64 36 wp_localize_script( 'formidable-form-selector', 'formidable_form_selector', $script_vars );
65 37 if ( function_exists( 'wp_set_script_translations' ) ) {
@@ -74,27 +46,8 @@
74 46 );
75 47 }
76 48
77 49 /**
78 - * Gets addon info.
79 - *
80 - * @since 6.8
81 - *
82 - * @param int $addon_id Addon ID.
83 - * @return array|false
84 - */
85 - private static function get_addon_info( $addon_id ) {
86 - $api = new FrmFormApi();
87 - $addons = $api->get_api_info();
88 -
89 - if ( ! is_array( $addons ) || ! array_key_exists( $addon_id, $addons ) ) {
90 - return false;
91 - }
92 -
93 - return $addons[ $addon_id ];
94 - }
95 -
96 - /**
97 50 * Returns a filtered list of form options with the name as label and the id as value, sorted by label
98 51 *
99 52 * @return array
100 53 */
@@ -117,15 +70,15 @@
117 70
118 71 /**
119 72 * Returns an array for a form with name as label and id as value
120 73 *
121 - * @param object $form
74 + * @param $form
122 75 *
123 76 * @return array
124 77 */
125 78 private static function set_form_options( $form ) {
126 79 return array(
127 - 'label' => FrmFormsHelper::edit_form_link_label( $form ),
80 + 'label' => $form->name,
128 81 'value' => $form->id,
129 82 );
130 83 }
131 84
@@ -130,10 +83,8 @@
130 83 }
131 84
132 85 /**
133 86 * Registers simple form block
134 - *
135 - * @return void
136 87 */
137 88 public static function register_simple_form_block() {
138 89 if ( ! is_callable( 'register_block_type' ) ) {
139 90 return;
@@ -173,9 +124,10 @@
173 124
174 125 /**
175 126 * Renders a form given the specified attributes.
176 127 *
177 - * @param array $attributes
128 + * @param $attributes
129 + *
178 130 * @return string
179 131 */
180 132 public static function simple_form_render( $attributes ) {
181 133 if ( ! isset( $attributes['formId'] ) ) {
@@ -181,35 +133,13 @@
181 133 if ( ! isset( $attributes['formId'] ) ) {
182 134 return '';
183 135 }
184 136
185 - ob_start();
186 -
187 - /**
188 - * @since 5.5.2
189 - * @param array $attributes
190 - */
191 - do_action( 'frm_before_simple_form_render', $attributes );
192 -
193 - $form = ob_get_clean();
194 -
195 - if ( false === $form ) {
196 - $form = '';
197 - }
198 -
199 137 $params = array_filter( $attributes );
200 138 $params['id'] = $params['formId'];
201 139 unset( $params['formId'] );
202 140
203 - // Still pass false for title and description options if nothing is set,
204 - // so a default doesn't overwrite the block option.
205 - $params['title'] = ! empty( $params['title'] );
206 - $params['description'] = ! empty( $params['description'] );
207 -
208 - $form .= FrmFormsController::get_form_shortcode( $params );
209 - if ( ! empty( $attributes['className'] ) ) {
210 - $form = preg_replace( '/\bfrm_forms\b/', 'frm_forms ' . esc_attr( $attributes['className'] ), $form, 1 );
211 - }
141 + $form = FrmFormsController::get_form_shortcode( $params );
212 142 return self::maybe_remove_fade_on_load_for_block_preview( $form );
213 143 }
214 144
215 145 /**