Skip to content

Instantly share code, notes, and snippets.

@infocities
Forked from ptesei/inner-example.php
Created April 22, 2025 07:52
Show Gist options
  • Save infocities/a14a7fdbbf75196388dfa58045d669a1 to your computer and use it in GitHub Desktop.
Save infocities/a14a7fdbbf75196388dfa58045d669a1 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