| @@ -21,9 +21,8 @@ | ||
| 21 | 21 | true |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | 24 | $icon = apply_filters( 'frm_icon', 'svg' ); |
| 25 | - | |
| 26 | 25 | if ( 0 === strpos( $icon, 'data:image/svg+xml;base64,' ) ) { |
| 27 | 26 | $icon = ' ' . FrmAppHelper::get_menu_icon_class(); |
| 28 | 27 | } else { |
| 29 | 28 | $icon = str_replace( 'dashicons-', '', $icon ); |
| @@ -29,62 +28,37 @@ | ||
| 29 | 28 | $icon = str_replace( 'dashicons-', '', $icon ); |
| 30 | 29 | } |
| 31 | 30 | |
| 32 | 31 | $block_name = FrmAppHelper::get_menu_name(); |
| 33 | - | |
| 34 | 32 | if ( $block_name === 'Formidable' ) { |
| 35 | 33 | $block_name = 'Formidable Forms'; |
| 36 | 34 | } |
| 37 | 35 | |
| 38 | - $modal_addon = self::get_addon_info( 185013 ); | |
| 39 | - $charts_addon = self::get_addon_info( 28248560 ); | |
| 40 | - $views_addon = FrmAddonsController::get_addon( 'views' ); | |
| 41 | - $views_addon_info = self::get_addon_info( 28027505 ); | |
| 36 | + $modal_addon = self::get_addon_info( 185013 ); | |
| 37 | + $charts_addon = self::get_addon_info( 28248560 ); | |
| 42 | 38 | |
| 43 | 39 | $script_vars = array( |
| 44 | - 'forms' => self::get_forms_options(), | |
| 45 | - 'icon' => $icon, | |
| 46 | - 'name' => $block_name, | |
| 47 | - 'link' => FrmAppHelper::admin_upgrade_link( 'block' ), | |
| 48 | - 'url' => FrmAppHelper::plugin_url(), | |
| 49 | - 'modalAddon' => array( | |
| 50 | - 'link' => is_array( $modal_addon ) && isset( $modal_addon['link'] ) ? FrmAppHelper::admin_upgrade_link( 'block', $modal_addon['link'] ) : '', | |
| 51 | - 'hasAccess' => is_array( $modal_addon ) && ! empty( $modal_addon['url'] ), | |
| 40 | + 'forms' => self::get_forms_options(), | |
| 41 | + 'icon' => $icon, | |
| 42 | + 'name' => $block_name, | |
| 43 | + 'link' => FrmAppHelper::admin_upgrade_link( 'block' ), | |
| 44 | + 'url' => FrmAppHelper::plugin_url(), | |
| 45 | + 'modalAddon' => array( | |
| 46 | + 'link' => FrmAppHelper::admin_upgrade_link( 'block', $modal_addon['link'] ), | |
| 47 | + 'hasAccess' => ! empty( $modal_addon['url'] ), | |
| 52 | 48 | ), |
| 53 | - 'viewsAddon' => array( | |
| 54 | - 'link' => is_array( $views_addon_info ) && isset( $views_addon_info['link'] ) ? FrmAppHelper::admin_upgrade_link( 'block', $views_addon_info['link'] ) : '', | |
| 55 | - 'hasAccess' => is_array( $views_addon_info ) && ! empty( $views_addon_info['url'] ), | |
| 56 | - 'url' => ! empty( $views_addon_info['url'] ) ? $views_addon_info['url'] : '', | |
| 57 | - 'installed' => is_array( $views_addon ) && 'installed' === $views_addon['status']['type'], | |
| 58 | - ), | |
| 59 | 49 | 'chartsAddon' => array( |
| 60 | - 'link' => is_array( $charts_addon ) && isset( $charts_addon['link'] ) ? FrmAppHelper::admin_upgrade_link( 'block', $charts_addon['link'] ) : '', | |
| 61 | - 'hasAccess' => is_array( $charts_addon ) && ! empty( $charts_addon['url'] ), | |
| 50 | + 'link' => FrmAppHelper::admin_upgrade_link( 'block', $charts_addon['link'] ), | |
| 51 | + 'hasAccess' => ! empty( $charts_addon['url'] ), | |
| 62 | 52 | 'installed' => class_exists( 'FrmChartsAppController' ), |
| 63 | 53 | ), |
| 64 | 54 | ); |
| 65 | 55 | |
| 66 | 56 | wp_localize_script( 'formidable-form-selector', 'formidable_form_selector', $script_vars ); |
| 67 | - | |
| 68 | 57 | if ( function_exists( 'wp_set_script_translations' ) ) { |
| 69 | 58 | wp_set_script_translations( 'formidable-form-selector', 'formidable' ); |
| 70 | 59 | } |
| 71 | - } | |
| 72 | 60 | |
| 73 | - /** | |
| 74 | - * Enqueue Formidable Simple Blocks' JS and CSS for the content. | |
| 75 | - * | |
| 76 | - * @since 6.26 | |
| 77 | - * | |
| 78 | - * @return void | |
| 79 | - */ | |
| 80 | - public static function block_assets() { | |
| 81 | - if ( ! is_admin() ) { | |
| 82 | - return; | |
| 83 | - } | |
| 84 | - | |
| 85 | - $version = FrmAppHelper::plugin_version(); | |
| 86 | - | |
| 87 | 61 | wp_enqueue_style( |
| 88 | 62 | 'formidable_block-editor-css', |
| 89 | 63 | FrmAppHelper::plugin_url() . '/css/frm_blocks.css', |
| 90 | 64 | array( 'wp-edit-blocks' ), |
| @@ -97,9 +71,8 @@ | ||
| 97 | 71 | * |
| 98 | 72 | * @since 6.8 |
| 99 | 73 | * |
| 100 | 74 | * @param int $addon_id Addon ID. |
| 101 | - * | |
| 102 | 75 | * @return array|false |
| 103 | 76 | */ |
| 104 | 77 | private static function get_addon_info( $addon_id ) { |
| 105 | 78 | $api = new FrmFormApi(); |
| @@ -193,9 +166,8 @@ | ||
| 193 | 166 | /** |
| 194 | 167 | * Renders a form given the specified attributes. |
| 195 | 168 | * |
| 196 | 169 | * @param array $attributes |
| 197 | - * | |
| 198 | 170 | * @return string |
| 199 | 171 | */ |
| 200 | 172 | public static function simple_form_render( $attributes ) { |
| 201 | 173 | if ( ! isset( $attributes['formId'] ) ) { |
| @@ -201,37 +173,19 @@ | ||
| 201 | 173 | if ( ! isset( $attributes['formId'] ) ) { |
| 202 | 174 | return ''; |
| 203 | 175 | } |
| 204 | 176 | |
| 205 | - ob_start(); | |
| 206 | - | |
| 207 | 177 | /** |
| 208 | 178 | * @since 5.5.2 |
| 209 | - * | |
| 210 | 179 | * @param array $attributes |
| 211 | 180 | */ |
| 212 | 181 | do_action( 'frm_before_simple_form_render', $attributes ); |
| 213 | 182 | |
| 214 | - $form = ob_get_clean(); | |
| 215 | - | |
| 216 | - if ( false === $form ) { | |
| 217 | - $form = ''; | |
| 218 | - } | |
| 219 | - | |
| 220 | 183 | $params = array_filter( $attributes ); |
| 221 | 184 | $params['id'] = $params['formId']; |
| 222 | 185 | unset( $params['formId'] ); |
| 223 | 186 | |
| 224 | - // Still pass false for title and description options if nothing is set, | |
| 225 | - // so a default doesn't overwrite the block option. | |
| 226 | - $params['title'] = ! empty( $params['title'] ); | |
| 227 | - $params['description'] = ! empty( $params['description'] ); | |
| 228 | - | |
| 229 | - $form .= FrmFormsController::get_form_shortcode( $params ); | |
| 230 | - | |
| 231 | - if ( ! empty( $attributes['className'] ) ) { | |
| 232 | - $form = preg_replace( '/\bfrm_forms\b/', 'frm_forms ' . esc_attr( $attributes['className'] ), $form, 1 ); | |
| 233 | - } | |
| 187 | + $form = FrmFormsController::get_form_shortcode( $params ); | |
| 234 | 188 | return self::maybe_remove_fade_on_load_for_block_preview( $form ); |
| 235 | 189 | } |
| 236 | 190 | |
| 237 | 191 | /** |
| @@ -238,9 +192,8 @@ | ||
| 238 | 192 | * Remove fade on load when /wp-json/wp/v2/block-renderer/formidable/simple-form is called. |
| 239 | 193 | * With the class set, the form never appears in the form block preview. |
| 240 | 194 | * |
| 241 | 195 | * @param string $form |
| 242 | - * | |
| 243 | 196 | * @return string |
| 244 | 197 | */ |
| 245 | 198 | private static function maybe_remove_fade_on_load_for_block_preview( $form ) { |
| 246 | 199 | if ( is_callable( 'wp_is_json_request' ) && wp_is_json_request() ) { |