Skip to content

Commit

Permalink
Gutenpack: Add/contact form to the gutenberg editor (#10537)
Browse files Browse the repository at this point in the history
* Add the gutenberg contact form gutenberg blocks

* Gutenpack: Add contact form block

* Update form block to use contact-form

* Add do_blocks call to the contact render form

* Add register_contact_form_blocks block method

* Provide default labels

* Updates to fix tests

the default value of a lable should be null of the type is not set

* Minor fixes

* Use the jetpack_register_block call to register the contact form blocks

Make sure we load them before we load the gutenberg blocks

* Bug fix: Only display selections when the option has a value.

* Added tests that show what the form doesn't recieve a lavel that we defaul to the default label.

* Add tests that shows that we remove empty options when we pass an string containing the empty options

* Minor bug fix. Add closing div to the phone field.

* Add support for class added in gutenberg

* Refactored field Render method so that it is easier to follow.

More DRY field render method

* Minor fixes

* Add unitests for output.

* Unit Test fixes so that they work with older version of PHP

* Fix: Add more liberal url validaton

This removed the validation error when a user doesn't add a http:// or https:// infront of the url.

* Improved pattern for the url.

* Revert "Improved pattern for the url."

This reverts commit 105fcca.

* Revert "Fix: Add more liberal url validaton"

This reverts commit 0f1a632.

* Add support for the defaultValue block attribute

* Gutenberg: Conact form

ensure we are exposing the contact form's sub-blocks in block availability data.

the sub blocks will not be in blocks-manifest.json, so we'll need to ensure we
are also including blocks that have been registered internally within jetpack

* Fix the tests again :P

* Fixes indentation of the js code

* Remove comment

* Add php doc block for remove_empty

* Fixes ugly quotes.

* Fix the tests since we are expecting the double quotes now.

* With escaped quotes
  • Loading branch information
enejb authored and jeherve committed Nov 20, 2018
1 parent b37b738 commit ea44f76
Show file tree
Hide file tree
Showing 3 changed files with 715 additions and 133 deletions.
9 changes: 6 additions & 3 deletions class.jetpack-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public static function get_preset( $preset ) {

/**
* Filters the results of `apply_filter( 'jetpack_set_available_blocks', array() )`
* using the contents of `_inc/blocks/blocks-manifest.json`
* using the merged contents of `_inc/blocks/blocks-manifest.json` ( $preset_blocks )
* and self::$jetpack_blocks ( $internal_blocks )
*
* @param $blocks The default list.
*
Expand All @@ -111,12 +112,14 @@ public static function get_preset( $preset ) {
public static function jetpack_set_available_blocks( $blocks ) {
$preset_blocks_manifest = self::preset_exists( 'block-manifest' ) ? self::get_preset( 'block-manifest' ) : (object) array( 'blocks' => $blocks );
$preset_blocks = isset( $preset_blocks_manifest->blocks ) ? (array) $preset_blocks_manifest->blocks : array() ;
$internal_blocks = array_keys( self::$jetpack_blocks );

if ( Jetpack_Constants::is_true( 'JETPACK_BETA_BLOCKS' ) ) {
$beta_blocks = isset( $preset_blocks_manifest->betaBlocks ) ? (array) $preset_blocks_manifest->betaBlocks : array();
return array_merge( $preset_blocks, $beta_blocks );
return array_unique( array_merge( $preset_blocks, $beta_blocks, $internal_blocks ) );
}

return $preset_blocks;
return array_unique( array_merge( $preset_blocks, $internal_blocks ) );
}

/**
Expand Down
Loading

0 comments on commit ea44f76

Please sign in to comment.