'acscf_form', 'posts_per_page' => 100, 'post_status' => 'publish', 'orderby' => 'title', 'order' => 'ASC', ) ); $options = array( array( 'label' => __( 'Select a form...', 'acs-contact-form' ), 'value' => '', ), ); foreach ( $forms as $form ) { $options[] = array( /* translators: 1: form title, 2: form ID. */ 'label' => sprintf( __( '%1$s (ID: %2$d)', 'acs-contact-form' ), $form->post_title, $form->ID ), 'value' => (string) $form->ID, ); } wp_localize_script( 'acscf-block', 'acscf_block_data', array( 'forms' => $options, 'i18n' => array( 'title' => __( 'ACS Contact Form', 'acs-contact-form' ), 'select' => __( 'Choose the form to display', 'acs-contact-form' ), ), ) ); register_block_type( ACSCF_PLUGIN_DIR . 'blocks/form', array( 'render_callback' => 'acscf_render_block_callback', ) ); } add_action( 'init', 'acscf_register_block' ); /** * Server side rendering of the block. * * @param array $attributes Block attributes. * @return string */ function acscf_render_block_callback( $attributes ) { if ( empty( $attributes['formId'] ) ) { return ''; } return acscf_form_shortcode( array( 'id' => (int) $attributes['formId'] ) ); }