wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



render_block_core_file › WordPress Function

Seitn/v
Veraltetn/v
render_block_core_file ( $attributes, $content )
Parameter: (2)
  • (array) $attributes The block attributes.
    Erforderlich: Ja
  • (array) $content The block content.
    Erforderlich: Ja
Gibt zurück:
  • (string) Returns the block content.
Definiert in:
Codex:

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



Quellcode

function render_block_core_file( $attributes, $content ) {
	if ( ! empty( $attributes['displayPreview'] ) ) {
		// Check if it's already enqueued, so we don't add the inline script multiple times.
		if ( ! wp_script_is( 'wp-block-library-file' ) ) {
			wp_enqueue_script( 'wp-block-library-file', plugins_url( 'file/frontend.js', __FILE__ ) );
		}
	}

	return $content;
}