| 1 |
<?php |
| 2 |
/** |
| 3 |
* Timeline Block server-side render. |
| 4 |
* |
| 5 |
* Only the wrapper and the entries are written here — no classes and no |
| 6 |
* styles. Both are applied on the client from the attributes forwarded in |
| 7 |
* `data-attributes`: the wrapper's classes by Components/Frontend/Timeline.js |
| 8 |
* and every style by Components/Common/Style.js, the same way the Data Table |
| 9 |
* block renders. |
| 10 |
* |
| 11 |
* That leaves the class list with a single source of truth in |
| 12 |
* utils/functions.js rather than a copy here that has to be kept in step. |
| 13 |
* |
| 14 |
* The entries are InnerBlocks, so they are rendered into a holder that |
| 15 |
* view.js adopts into the React tree rather than re-creating. |
| 16 |
* |
| 17 |
* @package bBlocks |
| 18 |
* |
| 19 |
* @var array $attributes Block attributes. |
| 20 |
* @var string $content Rendered inner blocks. |
| 21 |
*/ |
| 22 |
|
| 23 |
if ( ! defined( 'ABSPATH' ) ) { |
| 24 |
exit; |
| 25 |
} |
| 26 |
|
| 27 |
$id = wp_unique_id( 'timeline-' ); |
| 28 |
?> |
| 29 |
<div |
| 30 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 31 |
<?php echo get_block_wrapper_attributes(); ?> |
| 32 |
id='<?php echo esc_attr( $id ); ?>' |
| 33 |
data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>' |
| 34 |
> |
| 35 |
<div class='b-blocks-timeline-innerBlocks-contents'> |
| 36 |
<div class='b-blocks-timeline-items'> |
| 37 |
<?php |
| 38 |
// $content is the rendered inner blocks — a series of Timeline |
| 39 |
// Items, each of which escaped its own output in its render.php. |
| 40 |
echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- inner blocks render their own escaped markup |
| 41 |
?> |
| 42 |
</div> |
| 43 |
</div> |
| 44 |
</div> |
| 45 |
|