| @@ -21,9 +21,10 @@ | ||
| 21 | 21 | true |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | 24 | $icon = apply_filters( 'frm_icon', 'svg' ); |
| 25 | - if ( 0 === strpos( $icon, 'data:image/svg+xml;base64,' ) ) { | |
| 25 | + | |
| 26 | + if ( str_starts_with( $icon, 'data:image/svg+xml;base64,' ) ) { | |
| 26 | 27 | $icon = ' ' . FrmAppHelper::get_menu_icon_class(); |
| 27 | 28 | } else { |
| 28 | 29 | $icon = str_replace( 'dashicons-', '', $icon ); |
| 29 | 30 | } |
| @@ -28,8 +29,9 @@ | ||
| 28 | 29 | $icon = str_replace( 'dashicons-', '', $icon ); |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | $block_name = FrmAppHelper::get_menu_name(); |
| 33 | + | |
| 32 | 34 | if ( $block_name === 'Formidable' ) { |
| 33 | 35 | $block_name = 'Formidable Forms'; |
| 34 | 36 | } |
| 35 | 37 | |
| @@ -61,12 +63,28 @@ | ||
| 61 | 63 | ), |
| 62 | 64 | ); |
| 63 | 65 | |
| 64 | 66 | wp_localize_script( 'formidable-form-selector', 'formidable_form_selector', $script_vars ); |
| 67 | + | |
| 65 | 68 | if ( function_exists( 'wp_set_script_translations' ) ) { |
| 66 | 69 | wp_set_script_translations( 'formidable-form-selector', 'formidable' ); |
| 67 | 70 | } |
| 71 | + } | |
| 68 | 72 | |
| 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 | + | |
| 69 | 87 | wp_enqueue_style( |
| 70 | 88 | 'formidable_block-editor-css', |
| 71 | 89 | FrmAppHelper::plugin_url() . '/css/frm_blocks.css', |
| 72 | 90 | array( 'wp-edit-blocks' ), |
| @@ -79,8 +97,9 @@ | ||
| 79 | 97 | * |
| 80 | 98 | * @since 6.8 |
| 81 | 99 | * |
| 82 | 100 | * @param int $addon_id Addon ID. |
| 101 | + * | |
| 83 | 102 | * @return array|false |
| 84 | 103 | */ |
| 85 | 104 | private static function get_addon_info( $addon_id ) { |
| 86 | 105 | $api = new FrmFormApi(); |
| @@ -174,8 +193,9 @@ | ||
| 174 | 193 | /** |
| 175 | 194 | * Renders a form given the specified attributes. |
| 176 | 195 | * |
| 177 | 196 | * @param array $attributes |
| 197 | + * | |
| 178 | 198 | * @return string |
| 179 | 199 | */ |
| 180 | 200 | public static function simple_form_render( $attributes ) { |
| 181 | 201 | if ( ! isset( $attributes['formId'] ) ) { |
| @@ -185,8 +205,9 @@ | ||
| 185 | 205 | ob_start(); |
| 186 | 206 | |
| 187 | 207 | /** |
| 188 | 208 | * @since 5.5.2 |
| 209 | + * | |
| 189 | 210 | * @param array $attributes |
| 190 | 211 | */ |
| 191 | 212 | do_action( 'frm_before_simple_form_render', $attributes ); |
| 192 | 213 | |
| @@ -200,16 +221,18 @@ | ||
| 200 | 221 | $params['id'] = $params['formId']; |
| 201 | 222 | unset( $params['formId'] ); |
| 202 | 223 | |
| 203 | 224 | // Still pass false for title and description options if nothing is set, |
| 204 | - // so a default doesn't overwrite the block option. | |
| 225 | + // So a default doesn't overwrite the block option. | |
| 205 | 226 | $params['title'] = ! empty( $params['title'] ); |
| 206 | 227 | $params['description'] = ! empty( $params['description'] ); |
| 207 | 228 | |
| 208 | 229 | $form .= FrmFormsController::get_form_shortcode( $params ); |
| 230 | + | |
| 209 | 231 | if ( ! empty( $attributes['className'] ) ) { |
| 210 | 232 | $form = preg_replace( '/\bfrm_forms\b/', 'frm_forms ' . esc_attr( $attributes['className'] ), $form, 1 ); |
| 211 | 233 | } |
| 234 | + | |
| 212 | 235 | return self::maybe_remove_fade_on_load_for_block_preview( $form ); |
| 213 | 236 | } |
| 214 | 237 | |
| 215 | 238 | /** |
| @@ -216,13 +239,14 @@ | ||
| 216 | 239 | * Remove fade on load when /wp-json/wp/v2/block-renderer/formidable/simple-form is called. |
| 217 | 240 | * With the class set, the form never appears in the form block preview. |
| 218 | 241 | * |
| 219 | 242 | * @param string $form |
| 243 | + * | |
| 220 | 244 | * @return string |
| 221 | 245 | */ |
| 222 | 246 | private static function maybe_remove_fade_on_load_for_block_preview( $form ) { |
| 223 | 247 | if ( is_callable( 'wp_is_json_request' ) && wp_is_json_request() ) { |
| 224 | - $form = str_replace( ' frm_logic_form ', ' ', $form ); | |
| 248 | + return str_replace( ' frm_logic_form ', ' ', $form ); | |
| 225 | 249 | } |
| 226 | 250 | return $form; |
| 227 | 251 | } |
| 228 | 252 | } |