PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 1.8.0
Gutenify – Visual Site Builder Blocks & Starter Templates v1.8.0
1.9.0 1.8.0 1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 74 releases
gutenify / core / inc / blocks / class-fix-third-party-block-issues.php

class-fix-third-party-block-issues.php in Gutenify – Visual Site Builder Blocks & Starter Templates 1.8.0, at core/inc/blocks/class-fix-third-party-block-issues.php

75 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Fix integration issues with third-party blocks (e.g., WPForms).
4 *
5 * Adds missing attributes required by Gutenify for better block compatibility.
6 *
7 * @package gutenify
8 * @subpackage Compatibility
9 * @since 1.0.0
10 */
11
12 namespace gutenify;
13
14 defined( 'ABSPATH' ) || exit;
15
16 /**
17 * Class Fix_Third_Party_Block_Issues
18 *
19 * Ensures compatibility with WPForms Gutenberg block by adding required attributes.
20 */
21 class Fix_Third_Party_Block_Issues {
22
23 /**
24 * Attributes to inject into WPForms Gutenberg block.
25 *
26 * @var array
27 */
28 private static $attributes = array(
29 // 'customCss' => array(
30 // 'type' => 'string',
31 // ),
32 // 'blockClientId' => array(
33 // 'type' => 'string',
34 // ),
35 'animationsSettings' => array(
36 'type' => 'object',
37 'default' => array(
38 'duration' => 1000,
39 ),
40 ),
41 );
42
43 /**
44 * Constructor: hooks into WPForms block attribute filter.
45 */
46 public function __construct() {
47 add_filter(
48 'wpforms_gutenberg_form_selector_attributes',
49 array( __CLASS__, 'add_custom_block_attributes' )
50 );
51 }
52
53 /**
54 * Adds missing attributes to the WPForms block if not already set.
55 *
56 * @param array $attrs Existing block attributes.
57 * @return array Modified attributes.
58 */
59 public static function add_custom_block_attributes( $attrs ) {
60 foreach ( self::$attributes as $key => $val ) {
61 if ( ! isset( $attrs[ $key ] ) ) {
62 $attrs[ $key ] = array(
63 'type' => ! empty( $val['type'] ) ? $val['type'] : 'string',
64 'default' => ! empty( $val['default'] ) ? $val['default'] : '',
65 );
66 }
67 }
68
69 return $attrs;
70 }
71 }
72
73 // Initialize the class.
74 new Fix_Third_Party_Block_Issues();
75