From 20533a723ea56d1bfbc5e9e3691c47c5c86a1ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20L=C3=B6ytynoja?= Date: Tue, 16 Jun 2026 14:22:06 +0300 Subject: [PATCH 1/4] Changelog. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6f5ece..c29d66a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [Unreleased] +### Added +- Support for registering example data for ACF Blocks. + ## [1.41.6] ### Added From dc77d2d5935264af71ddb550164fa860bf5c1b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20L=C3=B6ytynoja?= Date: Tue, 16 Jun 2026 14:23:39 +0300 Subject: [PATCH 2/4] Add support for block example data --- src/Block.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Block.php b/src/Block.php index 6ffbc1b..4619add 100644 --- a/src/Block.php +++ b/src/Block.php @@ -123,6 +123,16 @@ class Block implements GroupableInterface { */ protected $parent = null; + /** + * An array of example data for the block. + * + * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#example-optional + * @see https://www.advancedcustomfields.com/resources/acf_register_block_type/ + * + * @var array + */ + protected $example = []; + /** * The renderer for this block. * @@ -466,6 +476,16 @@ public function get_styles() : array { */ public function set_parent( ?array $parent ) : self { $this->parent = $parent; + } + + /** + * Setter for the block example data. + * + * @param array $example Array of example data. + * @return self + */ + public function set_example( array $example ) : self { + $this->example = $example; return $this; } @@ -479,6 +499,15 @@ public function get_parent() : ?array { return $this->parent; } + /* + * Getter for the example data of the block. + * + * @return array + */ + public function get_example() : array { + return $this->example; + } + /** * Add a data filtering function for the block * @@ -588,6 +617,10 @@ protected function register_block() { $args['post_types'] = $post_types; } + if ( ! empty( $this->get_example() ) ) { + $args['example'] = $this->get_example(); + } + // Register the ACF Block. return \acf_register_block( $args ); } From 32e413da3a3d038d8bd2d4e3b97533fdff7cb362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20L=C3=B6ytynoja?= <101459373+vloy@users.noreply.github.com> Date: Tue, 6 Oct 2026 10:39:01 +0300 Subject: [PATCH 3/4] Update set_parent method to return self Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/Block.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Block.php b/src/Block.php index 4619add..536531d 100644 --- a/src/Block.php +++ b/src/Block.php @@ -476,6 +476,8 @@ public function get_styles() : array { */ public function set_parent( ?array $parent ) : self { $this->parent = $parent; + + return $this; } /** From f17d7cc69ef633d804165c307c48b026c3a6b606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20L=C3=B6ytynoja?= Date: Wed, 7 Oct 2026 08:02:46 +0300 Subject: [PATCH 4/4] 1.42.0 --- CHANGELOG.md | 2 ++ plugin.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd5024f..112a074 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [Unreleased] +## [1.42.0] + ### Added - Support for registering example data for ACF Blocks. diff --git a/plugin.php b/plugin.php index 960c671..80a5acd 100644 --- a/plugin.php +++ b/plugin.php @@ -3,7 +3,7 @@ Plugin Name: ACF Codifier Plugin URI: https://github.com/devgeniem/acf-codifier Description: A helper class to make defining ACF field groups and fields easier in the code. -Version: 1.41.8 +Version: 1.42.0 Author: Miika Arponen / Geniem Oy Author URI: https://geniem.fi License: GPL-3.0