| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* Server-side rendering of the `wtblocks/chart` block |
| 8 |
* |
| 9 |
* $attributes (array): The block attributes |
| 10 |
* $content (string): The block default content |
| 11 |
* $block (WP_Block): The block instance |
| 12 |
*/ |
| 13 |
|
| 14 |
$chart_id = $attributes['chartId'] ?? null; |
| 15 |
|
| 16 |
if ( ! empty( $chart_id ) ) : |
| 17 |
$allowed_show = [ 'chart', 'image', 'table' ]; |
| 18 |
$show = in_array( $attributes['show'] ?? '', $allowed_show, true ) ? $attributes['show'] : 'chart'; |
| 19 |
|
| 20 |
echo '[m-chart id="' . absint( $chart_id ) . '" show="' . esc_attr( $show ) . '"]'; |
| 21 |
endif; |
| 22 |
|