Skip to content

Commit

Permalink
✨ Add support for saving block data as post meta (Fixes #248) (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Jun 6, 2024
1 parent 7e3c6fa commit 284c40b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ abstract class Block extends Composer implements BlockContract
*/
public $style;

/**
* The block dimensions.
*
* @var string
*/
public $inlineStyle;

/**
* Context values inherited by the block.
*
Expand Down Expand Up @@ -243,11 +250,11 @@ abstract class Block extends Composer implements BlockContract
public $template = [];

/**
* The block dimensions.
* Determine whether to save the block's data as post meta.
*
* @var string
* @var bool
*/
public $inlineStyle;
public $usePostMeta = false;

/**
* The block attributes.
Expand Down Expand Up @@ -484,6 +491,7 @@ public function settings(): Collection
'enqueue_assets' => fn ($block) => method_exists($this, 'assets') ? $this->assets($block) : null,
'textdomain' => $this->getTextDomain(),
'acf_block_version' => 2,
'use_post_meta' => $this->usePostMeta,
'render_callback' => function (
$block,
$content = '',
Expand Down Expand Up @@ -530,9 +538,11 @@ public function toJson(): string
'enqueue_assets',
'mode',
'render_callback',
'use_post_meta',
])->put('acf', [
'mode' => $this->mode,
'renderTemplate' => $this::class,
'usePostMeta' => $this->usePostMeta,
])->put('name', $this->namespace);

return $settings->filter()->toJson(JSON_PRETTY_PRINT);
Expand Down

0 comments on commit 284c40b

Please sign in to comment.