<?php
function serialize_block( $block ) {
// Non-block content has no block name.
if ( null === $block['blockName'] ) {
return $block['innerHTML'];
}
$output = '';
// ...
return $output;
}
$block = array(
//'blockName' => 'test/void',
'attrs' => array(),
'innerBlocks' => array(),
'innerHTML' => '',
'innerContent' => array(),
);
echo serialize_block( $block );
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- Warning: Undefined array key "blockName" in /in/5Vjh3 on line 5
- Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
- Notice: Undefined index: blockName in /in/5Vjh3 on line 5
- Output for 7.3.32 - 7.3.33
preferences:
146.42 ms | 408 KiB | 5 Q