-
-
Save infocities/a14a7fdbbf75196388dfa58045d669a1 to your computer and use it in GitHub Desktop.
inner-example.php
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 | |
/** | |
* 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