wp/wp-includes/blocks/file.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    17  * @return string Returns the block content.
    17  * @return string Returns the block content.
    18  */
    18  */
    19 function render_block_core_file( $attributes, $content ) {
    19 function render_block_core_file( $attributes, $content ) {
    20 	// If it's interactive, enqueue the script module and add the directives.
    20 	// If it's interactive, enqueue the script module and add the directives.
    21 	if ( ! empty( $attributes['displayPreview'] ) ) {
    21 	if ( ! empty( $attributes['displayPreview'] ) ) {
    22 		$suffix = wp_scripts_get_suffix();
    22 		wp_enqueue_script_module( '@wordpress/block-library/file/view' );
    23 		if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
       
    24 			$module_url = gutenberg_url( '/build/interactivity/file.min.js' );
       
    25 		}
       
    26 
       
    27 		wp_register_script_module(
       
    28 			'@wordpress/block-library/file',
       
    29 			isset( $module_url ) ? $module_url : includes_url( "blocks/file/view{$suffix}.js" ),
       
    30 			array( '@wordpress/interactivity' ),
       
    31 			defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
       
    32 		);
       
    33 		wp_enqueue_script_module( '@wordpress/block-library/file' );
       
    34 
    23 
    35 		$processor = new WP_HTML_Tag_Processor( $content );
    24 		$processor = new WP_HTML_Tag_Processor( $content );
    36 		$processor->next_tag();
    25 		$processor->next_tag();
    37 		$processor->set_attribute( 'data-wp-interactive', 'core/file' );
    26 		$processor->set_attribute( 'data-wp-interactive', 'core/file' );
    38 		$processor->next_tag( 'object' );
    27 		$processor->next_tag( 'object' );