$form->ID, 'label' => $form->post_title ? $form->post_title : sprintf( /* translators: %d: form ID number. */ __( 'Form #%d', 'phemightforms' ), $form->ID ), ]; } wp_localize_script( 'phemightforms-block', 'PhemightFormsBlock', [ 'forms' => $options ] ); register_block_type( 'phemightforms/form', [ 'editor_script' => 'phemightforms-block', 'render_callback' => [ $this, 'render' ], 'attributes' => [ 'formId' => [ 'type' => 'number', 'default' => 0, ], ], ] ); } /** * Server-side render for the block. * * @param array $attributes Block attributes. * @return string */ public function render( $attributes ) { $form_id = isset( $attributes['formId'] ) ? absint( $attributes['formId'] ) : 0; if ( ! $form_id ) { return ''; } return do_shortcode( sprintf( '[phemightform id="%d"]', $form_id ) ); } }