From fc7b0ea2dcda86a7db8609388f3086c2ef564b3d Mon Sep 17 00:00:00 2001 From: Henry Saniuk Date: Mon, 21 Sep 2020 16:51:56 -0400 Subject: [PATCH 1/3] =?UTF-8?q?Adds=20=E2=80=98SupportsInnerBlocks?= =?UTF-8?q?=E2=80=99=20and=20=E2=80=98SupportsAlignText=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sage-acf-gutenberg-blocks.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sage-acf-gutenberg-blocks.php b/sage-acf-gutenberg-blocks.php index 4d49702..963ccf8 100644 --- a/sage-acf-gutenberg-blocks.php +++ b/sage-acf-gutenberg-blocks.php @@ -68,6 +68,8 @@ 'supports_align' => 'SupportsAlign', 'supports_anchor' => 'SupportsAnchor', 'supports_mode' => 'SupportsMode', + 'supports_jsx' => 'SupportsInnerBlocks', + 'supports_align_text' => 'SupportsAlignText', 'supports_multiple' => 'SupportsMultiple', 'enqueue_style' => 'EnqueueStyle', 'enqueue_script' => 'EnqueueScript', @@ -127,6 +129,16 @@ $data['supports']['mode'] = $file_headers['supports_mode'] === 'true' ? true : false; } + // If the SupportsInnerBlocks header is set in the template, restrict this block mode feature + if (!empty($file_headers['supports_jsx'])) { + $data['supports']['jsx'] = $file_headers['supports_jsx'] === 'true' ? true : false; + } + + // If the SupportsInnerBlocks header is set in the template, restrict this block mode feature + if (!empty($file_headers['supports_align_text'])) { + $data['supports']['align_text'] = $file_headers['supports_align_text'] === 'true' ? true : false; + } + // If the SupportsMultiple header is set in the template, restrict this block multiple feature if (!empty($file_headers['supports_multiple'])) { $data['supports']['multiple'] = $file_headers['supports_multiple'] === 'true' ? true : false; From ef008b681e6091b17691b652e6acead799ddb8ac Mon Sep 17 00:00:00 2001 From: Henry Saniuk Date: Mon, 21 Sep 2020 17:01:58 -0400 Subject: [PATCH 2/3] =?UTF-8?q?Adds=20=E2=80=98SupportsAlignContent?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sage-acf-gutenberg-blocks.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sage-acf-gutenberg-blocks.php b/sage-acf-gutenberg-blocks.php index 963ccf8..4675664 100644 --- a/sage-acf-gutenberg-blocks.php +++ b/sage-acf-gutenberg-blocks.php @@ -70,6 +70,7 @@ 'supports_mode' => 'SupportsMode', 'supports_jsx' => 'SupportsInnerBlocks', 'supports_align_text' => 'SupportsAlignText', + 'supports_align_content' => 'SupportsAlignContent', 'supports_multiple' => 'SupportsMultiple', 'enqueue_style' => 'EnqueueStyle', 'enqueue_script' => 'EnqueueScript', @@ -134,11 +135,16 @@ $data['supports']['jsx'] = $file_headers['supports_jsx'] === 'true' ? true : false; } - // If the SupportsInnerBlocks header is set in the template, restrict this block mode feature + // If the SupportsAlignText header is set in the template, restrict this block mode feature if (!empty($file_headers['supports_align_text'])) { $data['supports']['align_text'] = $file_headers['supports_align_text'] === 'true' ? true : false; } + // If the SupportsAlignContent header is set in the template, restrict this block mode feature + if (!empty($file_headers['supports_align_text'])) { + $data['supports']['align_content'] = $file_headers['supports_align_content'] === 'true' ? true : false; + } + // If the SupportsMultiple header is set in the template, restrict this block multiple feature if (!empty($file_headers['supports_multiple'])) { $data['supports']['multiple'] = $file_headers['supports_multiple'] === 'true' ? true : false; From c588c62b49e20ef64b7de46893a14d867c4091ee Mon Sep 17 00:00:00 2001 From: Henry Saniuk Date: Mon, 21 Sep 2020 17:03:23 -0400 Subject: [PATCH 3/3] Update README to include support for new properties --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a897e0..f77a2cb 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,9 @@ Add blade templates to `views/blocks` which get and use ACF data. Each template The options in the file header map to options in the [`acf_register_block_type` function](https://www.advancedcustomfields.com/resources/acf_register_block_type/). | Field | Description | Values | Notes | -| ------------------ | ------------------------------------------------ | ---------- | ---- | +| ------------------ | ------------------------------------------------ | ---------- | ---- | | `Title` | Title of the block in the gutenberg editor | i.e. `Testimonial` | _required_ | -| `Description` | Description of the block in the gutenberg editor | i.e. `My testimonial block` | _optional_ | +| `Description` | Description of the block in the gutenberg editor | i.e. `My testimonial block` | _optional_ | | `Category` | Category to store the block in. Use these values or [register your own custom block categories](https://wordpress.org/gutenberg/handbook/extensibility/extending-blocks/#managing-block-categories) | `common`, `formatting`, `layout`, `widgets`, `embed` | _required_ | | `Icon` | An icon property can be specified to make it easier to identify a block. Uses [dashicons](https://developer.wordpress.org/resource/dashicons/) | i.e. `book-alt` | _optional_ | | `Keywords` | An array of search terms to help user discover the block while searching. Sepearate values with a space. | i.e. `quote mention cite` | _optional_ | @@ -79,7 +79,10 @@ The options in the file header map to options in the [`acf_register_block_type` | `PostTypes` | An array of post types to restrict this block type to. Sepearate values with a space. | i.e. `post page` | | `SupportsAlign` | This property adds block controls which allow the user to change the block’s alignment. Set to true to show all alignments, false to hide the alignment toolbar. Set to an array (strings separated by spaces) of specific alignment names to customize the toolbar. | (boolean) `true`, `false`
or (array) `left center right wide full` | _optional_ (defaults to true) | | `SupportsMode` | This property allows the user to toggle between edit and preview modes via a button. | `true` or `false` |_optional_ (defaults to `true`) | -| `SupportsMultiple` |This property allows the block to be added multiple times. | `true` or `false` |_optional_ (defaults to `true`) | +| `SupportsMultiple` | This property allows the block to be added multiple times. | `true` or `false` |_optional_ (defaults to `true`) | +| `SupportsInnerBlocks` | This property allows the block to support the nesting of other blocks within it. | `true` or `false` |_optional_ (defaults to `false`) | +| `SupportsAlignText` | This property adds an alignment toolbar button similar to that seen when editing a paragraph of text. | `true` or `false` |_optional_ (defaults to `false`) | +| `SupportsAlignContent` | This property adds an alignment toolbar button similar to that seen when editing a core "Cover block" | `true` or `false` |_optional_ (defaults to `false`) | ## Creating ACF fields Once a block is created you'll be able to assign ACF fields to it using the standard Custom Fields interface in WordPress. We recommend using [sage-advanced-custom-fields](https://github.com/MWDelaney/sage-advanced-custom-fields) to keep your ACF fields in version control with Sage.