$attr ) { $type = is_array( $attr ) && isset( $attr['type'] ) && in_array( $attr['type'], self::TYPES, true ) ? $attr['type'] : 'string'; $def = is_array( $attr ) && isset( $attr['default'] ) ? $attr['default'] : ''; $normalized_attrs[ $k ] = array( 'type' => $type, 'default' => $def, ); } $block_meta = array( '$schema' => 'https://schemas.wp.org/trunk/block.json', 'apiVersion' => 3, 'name' => $block_slug, 'version' => '1.0.0', 'title' => $spec['title'], 'category' => $spec['category'] ?? 'widgets', 'icon' => $spec['icon'] ?? 'block-default', 'description' => $spec['description'] ?? '', 'attributes' => $normalized_attrs, 'supports' => array( 'html' => false, 'align' => true, 'color' => true, 'spacing' => true, ), 'render' => 'file:./render.php', ); $template = (string) ( $spec['template'] ?? '

{{title}}

{{content}}

' ); $render = EMCP_Tools_Sandbox_Template_Compiler::build_php_render( $template, $normalized_attrs ); return array( 'block_json' => wp_json_encode( $block_meta, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ), 'render_php' => $render, 'editor_js' => '', ); } }