-
-
Save infocities/abb6029285cb9186a4e1371a18689ba0 to your computer and use it in GitHub Desktop.
example innerblocks patterns
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
add_action('acf/init', 'my_acf_init_blocks'); | |
function my_acf_init_blocks() { | |
// Check function exists. | |
if( function_exists('acf_register_block_type') ) { | |
// Register a restricted block. | |
acf_register_block_type(array( | |
'name' => 'restricted', | |
'title' => 'Restricted', | |
'description' => 'A restricted content block.', | |
'category' => 'formatting', | |
'mode' => 'preview', | |
'supports' => array( | |
'align' => true, | |
'mode' => false, | |
'jsx' => true | |
), | |
'render_template' => 'template-parts/blocks/inner-example.php', | |
)); | |
} | |
if( function_exists('acf_register_block_type') ) { | |
// Register a restricted block. | |
acf_register_block_type(array( | |
'name' => 'restricted-template', | |
'title' => 'Restricted Template', | |
'description' => 'A restricted content block.', | |
'category' => 'formatting', | |
'mode' => 'preview', | |
'supports' => array( | |
'align' => true, | |
'mode' => false, | |
'jsx' => true | |
), | |
'render_template' => 'template-parts/blocks/inner-example-template.php', | |
)); | |
} | |
} | |
register_block_pattern( | |
'my-plugin/example-pattern', | |
array( | |
'title' => __( 'Example pattern', 'my-plugin' ), | |
'keyword' => array( 'example','test' ), | |
'content' => '<!-- wp:paragraph {"backgroundColor":"black","textColor":"white"} --> | |
<p class="has-white-color has-black-background-color has-text-color has-background">Powered by WordPress</p> | |
<!-- /wp:paragraph -->', | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment