Created
February 25, 2022 14:18
-
-
Save markhowellsmead/cdc85598e67e1330dfe6448cc31dce89 to your computer and use it in GitHub Desktop.
Use alignment in server-side rendered blocks for WordPress Gutenberg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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