Tribe__Assets::filter_modify_to_module( string $tag, string $handle )
Filters the Script tags to attach type=module based on the rules we set in our Asset class.
Contents
Parameters
- $tag
-
(string) (Required) Tag we are filtering.
- $handle
-
(string) (Required) Which is the ID/Handle of the tag we are about to print.
Return
(string) Script tag with the type=module
Source
File: src/Tribe/Assets.php
public function filter_modify_to_module( $tag, $handle ) { // Only filter for own own filters. if ( ! $asset = $this->get( $handle ) ) { return $tag; } // Bail when not dealing with JS assets. if ( 'js' !== $asset->type ) { return $tag; } // When not module we bail with the tag. if ( ! $asset->module ) { return $tag; } // These themes already have the `type='text/javascript'` added by WordPress core. if ( ! current_theme_supports( 'html5', 'script' ) ) { $replacement = 'type="module"'; return str_replace( "type='text/javascript'", $replacement, $tag ); } $replacement = '<script type="module" '; return str_replace( '<script ', $replacement, $tag ); }
Changelog
Version | Description |
---|---|
4.14.14 | Introduced. |