Last active
June 14, 2018 17:32
-
-
Save eudesgit/5bac0d55e2c3f42f08a529010c42e22d to your computer and use it in GitHub Desktop.
A render function for a WordPress Gutenberg block in 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 | |
/** | |
* CALLBACK | |
* | |
* Render callback for the dynamic block. | |
* | |
* Instead of rendering from the block's save(), this callback will render the front-end | |
* | |
* @since 1.0.0 | |
* @param $att Attributes from the JS block | |
* @return string Rendered HTML | |
*/ | |
public function block_dynamic_render_cb ( $att ) { | |
// Coming from RichText, each line is an array's element | |
$sum = $att['number1'][0] + $att['number2'][0]; | |
$html = "<h1>$sum</h1>"; | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment