Skip to content

Commit

Permalink
Add in a new caveat for block rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgestephanis committed Oct 24, 2018
1 parent d702c1d commit a12356b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/contact-form/grunion-contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ function __construct() {
register_block_type( 'jetpack/form', array(
'render_callback' => array( __CLASS__, 'gutenblock_render_form' ),
) );
// 👆 is negated by the filter 👇, if this change makes it into gutenberg core.
// https://github.com/WordPress/gutenberg/pull/10463#pullrequestreview-167500686
add_filter( 'pre_do_block_jetpack/form', array( __CLASS__, 'pre_do_block_jetpack_form' ), 10, 3 );

// These can all use a common render method.
register_block_type( 'jetpack/field-text', array(
Expand Down Expand Up @@ -301,6 +304,11 @@ public static function gutenblock_render_form( $atts, $content ) {
public static function gutenblock_render_field( $atts, $content ) {
return Grunion_Contact_Form::parse_contact_field( $atts, $content );
}
public static function pre_do_block_jetpack_form( $pre_rendered_content, $block, $all_blocks ) {
$pre_rendered_content = _recurse_blocks( $block['innerBlocks'], $all_blocks );
return Grunion_Contact_Form::parse( $block['attrs'], $pre_rendered_content );
}

public static function gutenblock_render_field_textarea( $atts, $content ) {
$atts['type'] = 'textarea';
return Grunion_Contact_Form::parse_contact_field( $atts, $content );
Expand Down

0 comments on commit a12356b

Please sign in to comment.