PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4
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 +10 -74 6.25.15.4 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
@@ -32,34 +30,14 @@
32 30 if ( $block_name === 'Formidable' ) {
33 31 $block_name = 'Formidable Forms';
34 32 }
35 33
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 34 $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 - ),
35 + 'forms' => self::get_forms_options(),
36 + 'icon' => $icon,
37 + 'name' => $block_name,
38 + 'link' => FrmAppHelper::admin_upgrade_link( 'block' ),
39 + 'url' => FrmAppHelper::plugin_url(),
62 40 );
63 41
64 42 wp_localize_script( 'formidable-form-selector', 'formidable_form_selector', $script_vars );
65 43 if ( function_exists( 'wp_set_script_translations' ) ) {
@@ -74,27 +52,8 @@
74 52 );
75 53 }
76 54
77 55 /**
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 56 * Returns a filtered list of form options with the name as label and the id as value, sorted by label
98 57 *
99 58 * @return array
100 59 */
@@ -117,15 +76,15 @@
117 76
118 77 /**
119 78 * Returns an array for a form with name as label and id as value
120 79 *
121 - * @param object $form
80 + * @param $form
122 81 *
123 82 * @return array
124 83 */
125 84 private static function set_form_options( $form ) {
126 85 return array(
127 - 'label' => FrmFormsHelper::edit_form_link_label( $form ),
86 + 'label' => $form->name,
128 87 'value' => $form->id,
129 88 );
130 89 }
131 90
@@ -130,10 +89,8 @@
130 89 }
131 90
132 91 /**
133 92 * Registers simple form block
134 - *
135 - * @return void
136 93 */
137 94 public static function register_simple_form_block() {
138 95 if ( ! is_callable( 'register_block_type' ) ) {
139 96 return;
@@ -173,9 +130,10 @@
173 130
174 131 /**
175 132 * Renders a form given the specified attributes.
176 133 *
177 - * @param array $attributes
134 + * @param $attributes
135 + *
178 136 * @return string
179 137 */
180 138 public static function simple_form_render( $attributes ) {
181 139 if ( ! isset( $attributes['formId'] ) ) {
@@ -181,35 +139,13 @@
181 139 if ( ! isset( $attributes['formId'] ) ) {
182 140 return '';
183 141 }
184 142
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 143 $params = array_filter( $attributes );
200 144 $params['id'] = $params['formId'];
201 145 unset( $params['formId'] );
202 146
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 - }
147 + $form = FrmFormsController::get_form_shortcode( $params );
212 148 return self::maybe_remove_fade_on_load_for_block_preview( $form );
213 149 }
214 150
215 151 /**