render_block_core_file() – When the `core/file` block is rendering, check if we need to enqueue the `’wp-block-file-view` script.

You appear to be a bot. Output may be restricted

Description

When the core/file block is rendering, check if we need to enqueue the 'wp-block-file-view script.

Usage

$string = render_block_core_file( $attributes, $content );

Parameters

$attributes
( array ) required – The block attributes.
$content
( string ) required – The block content.

Returns

string Returns the block content.

Source

File name: wordpress/wp-includes/blocks/file.php
Lines:

1 to 8 of 8
function render_block_core_file( $attributes, $content ) {
  $should_load_view_script = ! empty( $attributes['displayPreview'] ) && ! wp_script_is( 'wp-block-file-view' );
  if ( $should_load_view_script ) {
    wp_enqueue_script( 'wp-block-file-view' );
  }

  return $content;
}
 

 View on GitHub View on Trac