From 9b87639974084c4f833eb5a18e97b6d0fdbab9f1 Mon Sep 17 00:00:00 2001 From: Steve Ross Date: Sun, 4 Jan 2026 17:54:46 +0000 Subject: [PATCH] most block lists to json files --- app/blocks.php | 64 +++---------------- resources/json/block-attributes.json | 53 +++++++++++++++ ...itelist.json => block-core-whitelist.json} | 0 resources/json/block-parents.json | 4 ++ 4 files changed, 67 insertions(+), 54 deletions(-) create mode 100644 resources/json/block-attributes.json rename resources/json/{core-block-whitelist.json => block-core-whitelist.json} (100%) create mode 100644 resources/json/block-parents.json diff --git a/app/blocks.php b/app/blocks.php index 6a9d961..acacda9 100644 --- a/app/blocks.php +++ b/app/blocks.php @@ -103,59 +103,7 @@ add_action('init', function () { 'style' => "{$slug}-style", 'script' => "{$slug}-script", 'view_script' => "{$slug}-view-script", - 'attributes' => [ - 'container_width' => [ - 'type' => 'string', - 'default' => '', - ], - 'alignment' => [ - 'type' => 'string', - ], - 'padding_top' => [ - 'type' => 'boolean', - 'default' => true - ], - 'padding_bottom' => [ - 'type' => 'boolean', - 'default' => true - ], - 'background_colour' => [ - 'type' => 'string', - 'default' => '', - ], - 'background_hex' => [ - 'type' => 'string', - 'default' => '', - ], - 'background_tint' => [ - 'type' => 'string', - 'default' => '0', - ], - 'background_image' => [ - 'type' => 'integer', - 'default' => 0, - ], - 'background_url' => [ - 'type' => 'string', - 'default' => '', - ], - 'background_opacity' => [ - 'type' => 'integer', - 'default' => 30 - ], - 'background_position' => [ - 'type' => 'string', - 'default' => '', - ], - 'background_fixed' => [ - 'type' => 'boolean', - 'default' => false, - ], - 'background_contrast' => [ - 'type' => 'boolean', - 'default' => false, - ], - ], + 'attributes' => attributes(), ]; if(!property_exists($json, 'acf') && \Roots\view()->exists("blocks.{$slug}.render")) { @@ -176,12 +124,20 @@ add_action('init', function () { function list_inner() { - $file = file_get_contents(get_theme_file_path("resources/json/core-block-whitelist.json")); + $file = file_get_contents(get_theme_file_path("resources/json/block-core-whitelist.json")); $json = json_decode($file); return $json; } +function attributes() +{ + $file = file_get_contents(get_theme_file_path("resources/json/block-attributes.json")); + $json = json_decode($file, true); + + return $json; +} + function list_all() { $blocks = array_map(function($block) { diff --git a/resources/json/block-attributes.json b/resources/json/block-attributes.json new file mode 100644 index 0000000..ee21c1c --- /dev/null +++ b/resources/json/block-attributes.json @@ -0,0 +1,53 @@ +{ + "container_width": { + "type": "string", + "default": "" + }, + "alignment": { + "type": "string" + }, + "padding_top": { + "type": "boolean", + "default": true + }, + "padding_bottom": { + "type": "boolean", + "default": true + }, + "background_colour": { + "type": "string", + "default": "" + }, + "background_hex": { + "type": "string", + "default": "" + }, + "background_tint": { + "type": "string", + "default": "0" + }, + "background_image": { + "type": "integer", + "default": 0 + }, + "background_url": { + "type": "string", + "default": "" + }, + "background_opacity": { + "type": "integer", + "default": 30 + }, + "background_position": { + "type": "string", + "default": "" + }, + "background_fixed": { + "type": "boolean", + "default": false + }, + "background_contrast": { + "type": "boolean", + "default": false + } +} diff --git a/resources/json/core-block-whitelist.json b/resources/json/block-core-whitelist.json similarity index 100% rename from resources/json/core-block-whitelist.json rename to resources/json/block-core-whitelist.json diff --git a/resources/json/block-parents.json b/resources/json/block-parents.json new file mode 100644 index 0000000..ecb5a4c --- /dev/null +++ b/resources/json/block-parents.json @@ -0,0 +1,4 @@ +[ + "acf/badegg-editor", + "badegg/article" +]