Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/block-directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,22 @@ function gutenberg_enqueue_block_editor_assets_block_directory() {
wp_enqueue_style( 'wp-block-directory' );
}
add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );

/**
* Add data attribute of handle to all script tags output in the wp-admin.
*
* @param string $tag The `<script>` tag for the enqueued script.
* @param string $handle The script's registered handle.
*
* @return string Filter script tag.
*/
function gutenberg_change_script_tag( $tag, $handle ) {
if ( ! is_admin() ) {
return $tag;
}
$tag = str_replace( '<script ', sprintf( '<script data-handle="%s" ', esc_attr( $handle ) ), $tag );

return $tag;
}
add_filter( 'script_loader_tag', 'gutenberg_change_script_tag', 10, 2 );
}