Skip to content

Commit d1dde09

Browse files
authored
Add support for block parent attribute (#119)
1 parent 8638799 commit d1dde09

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
[Unreleased]
88

9+
## [1.39.0]
10+
11+
### Added
12+
- Add support for block parent attribute.
13+
914
## [1.38.4]
1015

1116
- Fix previous tag pointing to earlier commit.

docs/classes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
| public | <strong>get_keywords()</strong> : <em>array</em><br /><em>Getter for the keywords.</em> |
234234
| public | <strong>get_mode()</strong> : <em>string</em><br /><em>Getter for the display mode.</em> |
235235
| public | <strong>get_name()</strong> : <em>string</em><br /><em>Getter for the name.</em> |
236+
| public | <strong>get_parent()</strong> : <em>array|null</em><br /><em>Getter for the parent of the block.</em> |
236237
| public | <strong>get_post_types()</strong> : <em>array</em><br /><em>Getter for the post types.</em> |
237238
| public | <strong>get_renderer()</strong> : <em>[\Geniem\ACF\Interfaces\Renderer](#interface-geniemacfinterfacesrenderer)</em><br /><em>Getter for the component renderer.</em> |
238239
| public | <strong>get_styles()</strong> : <em>array</em><br /><em>Getter for the styles of the block.</em> |
@@ -253,6 +254,7 @@
253254
| public | <strong>set_keywords(</strong><em>array</em> <strong>$keywords</strong>)</strong> : <em>\Geniem\ACF\self</em><br /><em>Setter for the keywords.</em> |
254255
| public | <strong>set_mode(</strong><em>\string</em> <strong>$mode</strong>)</strong> : <em>\Geniem\ACF\self</em><br /><em>Setter for the display mode Options: auto, preview or edit.</em> |
255256
| public | <strong>set_name(</strong><em>\string</em> <strong>$name</strong>)</strong> : <em>\Geniem\ACF\self</em><br /><em>Setter for the name.</em> |
257+
| public | <strong>set_parent(</strong><em>\array|null</em> <strong>$parent</strong>)</strong> : <em>\Geniem\ACF\self</em><br /><em>Setter for the parent of the block.</em> |
256258
| public | <strong>set_post_types(</strong><em>array</em> <strong>$post_types</strong>)</strong> : <em>\Geniem\ACF\self</em><br /><em>Setter for the post_ ypes.</em> |
257259
| public | <strong>set_renderer(</strong><em>[\Geniem\ACF\Interfaces\Renderer](#interface-geniemacfinterfacesrenderer)</em> <strong>$renderer</strong>)</strong> : <em>void</em><br /><em>Set the renderer for the component.</em> |
258260
| public | <strong>set_styles(</strong><em>array</em> <strong>$styles</strong>)</strong> : <em>\Geniem\ACF\self</em><br /><em>Setter for the styles of the block.</em> |

plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: ACF Codifier
44
Plugin URI: https://github.com/devgeniem/acf-codifier
55
Description: A helper class to make defining ACF field groups and fields easier in the code.
6-
Version: 1.38.4
6+
Version: 1.39.0
77
Author: Miika Arponen / Geniem Oy
88
Author URI: https://geniem.fi
99
License: GPL-3.0

src/Block.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ class Block implements GroupableInterface {
114114
*/
115115
protected $styles = [];
116116

117+
/**
118+
* An array of parent blocks for the block.
119+
*
120+
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#parent-optional
121+
*
122+
* @var array|null
123+
*/
124+
protected $parent = null;
125+
117126
/**
118127
* The renderer for this block.
119128
*
@@ -449,6 +458,27 @@ public function get_styles() : array {
449458
return $this->styles;
450459
}
451460

461+
/**
462+
* Setter for the parent of the block.
463+
*
464+
* @param array|null $parent Array of parent blocks or null.
465+
* @return self
466+
*/
467+
public function set_parent( ?array $parent ) : self {
468+
$this->parent = $parent;
469+
470+
return $this;
471+
}
472+
473+
/**
474+
* Getter for the parent of the block.
475+
*
476+
* @return array|null
477+
*/
478+
public function get_parent() : ?array {
479+
return $this->parent;
480+
}
481+
452482
/**
453483
* Add a data filtering function for the block
454484
*
@@ -546,6 +576,7 @@ protected function register_block() {
546576
'align' => $this->get_align(),
547577
'supports' => $this->get_supports(),
548578
'styles' => $this->get_styles(),
579+
'parent' => $this->get_parent(),
549580
];
550581

551582
if ( ! empty( $this->get_post_types() ) ) {

0 commit comments

Comments
 (0)