Last active
March 21, 2023 12:51
-
-
Save davidfcarr/6e0a750f58c903b054323fd3ac0c8373 to your computer and use it in GitHub Desktop.
This file contains 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 | |
function rsvpBlockDataOutput($block, $post_id) { | |
if(empty($block)) | |
return; | |
$attrs = ($block->attrs) ? json_encode($block->attrs) : ''; | |
if(!empty($block->innerHTML) || (!empty($block->innerBlocks) && sizeof($block->innerBlocks)) ) { | |
$output = sprintf('<!-- wp:%s %s -->',$block->blockName,$attrs)."\n"; | |
if(!empty($block->innerHTML)) | |
$output .= $block->innerHTML."\n"; | |
if(!empty($block->innerBlocks) && is_array($block->innerBlocks) && sizeof($block->innerBlocks)) { | |
foreach($block->innerBlocks as $innerblock) { | |
$output .= jsonBlockDataOutput($innerblock,$post_id); | |
} | |
} | |
$output .= sprintf('<!-- /wp:%s -->',$block->blockName)."\n\n"; | |
} | |
else | |
$output = sprintf('<!-- wp:%s %s /-->',$block->blockName,$attrs)."\n\n"; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment