| @@ -21,10 +21,9 @@ | ||
| 21 | 21 | true |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | 24 | $icon = apply_filters( 'frm_icon', 'svg' ); |
| 25 | - | |
| 26 | - if ( str_starts_with( $icon, 'data:image/svg+xml;base64,' ) ) { | |
| 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 ); |
| 30 | 29 | } |
| @@ -29,9 +28,8 @@ | ||
| 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 | |
| @@ -46,45 +44,29 @@ | ||
| 46 | 44 | 'name' => $block_name, |
| 47 | 45 | 'link' => FrmAppHelper::admin_upgrade_link( 'block' ), |
| 48 | 46 | 'url' => FrmAppHelper::plugin_url(), |
| 49 | 47 | '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'] ), | |
| 48 | + 'link' => FrmAppHelper::admin_upgrade_link( 'block', $modal_addon['link'] ), | |
| 49 | + 'hasAccess' => ! empty( $modal_addon['url'] ), | |
| 52 | 50 | ), |
| 53 | 51 | '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'] ), | |
| 52 | + 'link' => FrmAppHelper::admin_upgrade_link( 'block', $views_addon_info['link'] ), | |
| 53 | + 'hasAccess' => ! empty( $views_addon_info['url'] ), | |
| 56 | 54 | 'url' => ! empty( $views_addon_info['url'] ) ? $views_addon_info['url'] : '', |
| 57 | - 'installed' => is_array( $views_addon ) && 'installed' === $views_addon['status']['type'], | |
| 55 | + 'installed' => 'installed' === $views_addon['status']['type'], | |
| 58 | 56 | ), |
| 59 | 57 | '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'] ), | |
| 58 | + 'link' => FrmAppHelper::admin_upgrade_link( 'block', $charts_addon['link'] ), | |
| 59 | + 'hasAccess' => ! empty( $charts_addon['url'] ), | |
| 62 | 60 | 'installed' => class_exists( 'FrmChartsAppController' ), |
| 63 | 61 | ), |
| 64 | 62 | ); |
| 65 | 63 | |
| 66 | 64 | wp_localize_script( 'formidable-form-selector', 'formidable_form_selector', $script_vars ); |
| 67 | - | |
| 68 | 65 | if ( function_exists( 'wp_set_script_translations' ) ) { |
| 69 | 66 | wp_set_script_translations( 'formidable-form-selector', 'formidable' ); |
| 70 | 67 | } |
| 71 | - } | |
| 72 | 68 | |
| 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 | 69 | wp_enqueue_style( |
| 88 | 70 | 'formidable_block-editor-css', |
| 89 | 71 | FrmAppHelper::plugin_url() . '/css/frm_blocks.css', |
| 90 | 72 | array( 'wp-edit-blocks' ), |
| @@ -97,9 +79,8 @@ | ||
| 97 | 79 | * |
| 98 | 80 | * @since 6.8 |
| 99 | 81 | * |
| 100 | 82 | * @param int $addon_id Addon ID. |
| 101 | - * | |
| 102 | 83 | * @return array|false |
| 103 | 84 | */ |
| 104 | 85 | private static function get_addon_info( $addon_id ) { |
| 105 | 86 | $api = new FrmFormApi(); |
| @@ -193,9 +174,8 @@ | ||
| 193 | 174 | /** |
| 194 | 175 | * Renders a form given the specified attributes. |
| 195 | 176 | * |
| 196 | 177 | * @param array $attributes |
| 197 | - * | |
| 198 | 178 | * @return string |
| 199 | 179 | */ |
| 200 | 180 | public static function simple_form_render( $attributes ) { |
| 201 | 181 | if ( ! isset( $attributes['formId'] ) ) { |
| @@ -201,38 +181,19 @@ | ||
| 201 | 181 | if ( ! isset( $attributes['formId'] ) ) { |
| 202 | 182 | return ''; |
| 203 | 183 | } |
| 204 | 184 | |
| 205 | - ob_start(); | |
| 206 | - | |
| 207 | 185 | /** |
| 208 | 186 | * @since 5.5.2 |
| 209 | - * | |
| 210 | 187 | * @param array $attributes |
| 211 | 188 | */ |
| 212 | 189 | do_action( 'frm_before_simple_form_render', $attributes ); |
| 213 | 190 | |
| 214 | - $form = ob_get_clean(); | |
| 215 | - | |
| 216 | - if ( false === $form ) { | |
| 217 | - $form = ''; | |
| 218 | - } | |
| 219 | - | |
| 220 | 191 | $params = array_filter( $attributes ); |
| 221 | 192 | $params['id'] = $params['formId']; |
| 222 | 193 | unset( $params['formId'] ); |
| 223 | 194 | |
| 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 | - } | |
| 234 | - | |
| 195 | + $form = FrmFormsController::get_form_shortcode( $params ); | |
| 235 | 196 | return self::maybe_remove_fade_on_load_for_block_preview( $form ); |
| 236 | 197 | } |
| 237 | 198 | |
| 238 | 199 | /** |
| @@ -239,9 +200,8 @@ | ||
| 239 | 200 | * Remove fade on load when /wp-json/wp/v2/block-renderer/formidable/simple-form is called. |
| 240 | 201 | * With the class set, the form never appears in the form block preview. |
| 241 | 202 | * |
| 242 | 203 | * @param string $form |
| 243 | - * | |
| 244 | 204 | * @return string |
| 245 | 205 | */ |
| 246 | 206 | private static function maybe_remove_fade_on_load_for_block_preview( $form ) { |
| 247 | 207 | if ( is_callable( 'wp_is_json_request' ) && wp_is_json_request() ) { |