# contact-forms/2.2.32/block-editor.php

Contact Forms by Cimatti, version 2.2.32. 45 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/2.2.32/code/block-editor.php
- Raw: https://pluginprobe.com/plugins/contact-forms/2.2.32/raw/block-editor.php
- Modified: 2026-04-08T09:49:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/2.2.32/code/block-editor.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * Register the Contact Forms block for the block editor.
 */
function accua_forms_register_block() {
	if ( ! function_exists( 'register_block_type' ) ) {
		return;
	}

	wp_register_script(
		'contact-forms-block-editor',
		plugins_url( 'block-editor/index.js', ACCUA_FORMS_FILE ),
		array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-block-editor', 'wp-i18n', 'wp-server-side-render' ),
		ACCUA_FORMS_JS_VERSION,
		true
	);

	wp_set_script_translations( 'contact-forms-block-editor', 'contact-forms', plugin_dir_path( ACCUA_FORMS_FILE ) . 'languages' );

	// Pass form list to the block editor script
	$forms = get_option( 'accua_forms_saved_forms', array() );
	$form_list = array();
	foreach ( $forms as $fid => $form_data ) {
		$title = ! empty( $form_data['title'] ) ? $form_data['title'] : __( '(untitled)', 'contact-forms' );
		$form_list[] = array(
			'text'  => $title,
			'value' => (string) $fid,
		);
	}
	usort( $form_list, function( $a, $b ) {
		return (int) $b['value'] - (int) $a['value'];
	} );

	wp_add_inline_script(
		'contact-forms-block-editor',
		'var accua_forms_block_data = ' . wp_json_encode( array( 'forms' => $form_list ) ) . ';',
		'before'
	);

	register_block_type( plugin_dir_path( ACCUA_FORMS_FILE ) . 'block-editor' );
}
add_action( 'init', 'accua_forms_register_block' );

```
