Skip to content

Instantly share code, notes, and snippets.

@markhowellsmead
Created February 25, 2022 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhowellsmead/cdc85598e67e1330dfe6448cc31dce89 to your computer and use it in GitHub Desktop.
Save markhowellsmead/cdc85598e67e1330dfe6448cc31dce89 to your computer and use it in GitHub Desktop.
Use alignment in server-side rendered blocks for WordPress Gutenberg
<?php
register_block_type('shb/demo', [
'attributes' => [
'align' => [
'type' => 'string',
'enum' => ['wide', 'full'],
]
],
if (!empty($align = $attributes['align'] ?? '')) {
$align = "align{$align}";
}
<div <?php echo get_block_wrapper_attributes(['class' => $align]); ?>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment