Skip to content

Instantly share code, notes, and snippets.

@ptesei
Created May 17, 2022 07:15
Show Gist options
  • Save ptesei/5bf90a5689e5fd0c13632474c0498d9b to your computer and use it in GitHub Desktop.
Save ptesei/5bf90a5689e5fd0c13632474c0498d9b to your computer and use it in GitHub Desktop.
inner-example.php
<?php
/**
* Restricted Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
*/
// Create class attribute allowing for custom "className" and "align" values.
$classes = '';
if( !empty($block['className']) ) {
$classes .= sprintf( ' %s', $block['className'] );
}
if( !empty($block['align']) ) {
$classes .= sprintf( ' align%s', $block['align'] );
}
$allowed_blocks = array( 'core/image', 'core/paragraph' );
// Please note that only a single <InnerBlocks />
?>
<div class="restricted-block <?php echo esc_attr($classes); ?>">
<!-- <div class="inner-example">inner block example</div>-->
<!-- <InnerBlocks />-->
<div class="inner-example">inner block with image and paragraph</div>
<InnerBlocks allowedBlocks="<?php echo esc_attr( wp_json_encode( $allowed_blocks ) );?>"/>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment