Changeset 54132 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 09/12/2022 01:12:21 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r53892 r54132 236 236 * @since 5.7.0 Added support for `textdomain` field and i18n handling for all translatable fields. 237 237 * @since 5.9.0 Added support for `variations` and `viewScript` fields. 238 * @since 6.1.0 Added support for `render` field. 238 239 * 239 240 * @param string $file_or_folder Path to the JSON file with metadata definition for … … 344 345 'style' 345 346 ); 347 } 348 349 if ( ! empty( $metadata['render'] ) ) { 350 $template_path = wp_normalize_path( 351 realpath( 352 dirname( $metadata['file'] ) . '/' . 353 remove_block_asset_path_prefix( $metadata['render'] ) 354 ) 355 ); 356 if ( file_exists( $template_path ) ) { 357 /** 358 * Renders the block on the server. 359 * 360 * @since 6.1.0 361 * 362 * @param array $attributes Block attributes. 363 * @param string $content Block default content. 364 * @param WP_Block $block Block instance. 365 * 366 * @return string Returns the block content. 367 */ 368 $settings['render_callback'] = function( $attributes, $content, $block ) use ( $template_path ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable 369 ob_start(); 370 require $template_path; 371 return ob_get_clean(); 372 }; 373 } 346 374 } 347 375
Note: See TracChangeset
for help on using the changeset viewer.