Skip to content

Commit

Permalink
Merge pull request #1423 from rocklobster-in/dev/5.9
Browse files Browse the repository at this point in the history
Update block registration process
  • Loading branch information
takayukister authored May 12, 2024
2 parents 6be9633 + 001df40 commit 435b39d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 41 deletions.
41 changes: 1 addition & 40 deletions includes/block-editor/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,7 @@
);

function wpcf7_init_block_editor_assets() {
$assets = array();

$asset_file = wpcf7_plugin_path(
'includes/block-editor/index.asset.php'
);

if ( file_exists( $asset_file ) ) {
$assets = include( $asset_file );
}

$assets = wp_parse_args( $assets, array(
'dependencies' => array(
'react',
'wp-api-fetch',
'wp-block-editor',
'wp-blocks',
'wp-components',
'wp-element',
'wp-i18n',
'wp-url',
),
'version' => WPCF7_VERSION,
) );

wp_register_script(
'contact-form-7-block-editor',
wpcf7_plugin_url( 'includes/block-editor/index.js' ),
$assets['dependencies'],
$assets['version']
);

wp_set_script_translations(
'contact-form-7-block-editor',
'contact-form-7'
);

register_block_type(
wpcf7_plugin_path( 'includes/block-editor' ),
array(
'editor_script_handles' => 'contact-form-7-block-editor',
)
wpcf7_plugin_path( 'includes/block-editor' )
);
}
2 changes: 1 addition & 1 deletion includes/block-editor/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
"default": "form"
}
},
"editorScript": "file:./index.js"
"editorScript": [ "file:./index.js", "contact-form-7-block-editor" ]
}

0 comments on commit 435b39d

Please sign in to comment.