This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Inpspired by Scott Jehl: https://www.filamentgroup.com/lab/load-css-simpler/ | |
* | |
**/ | |
add_action( 'style_loader_tag', 'async_preload_stylesheets', 99, 4 ); | |
function async_preload_stylesheets( string $tag, string $handle, string $href, string $media ) : string { | |
// Add the stylesheet handles you want to load async | |
$allowlist = [ 'your-stylesheet-handle' ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_html_attributes(array $atts) { | |
return array_reduce($atts, function($carry, $name) use($atts) { | |
$value = $atts[$name]; | |
return "$carry $name=\"$value\""; | |
}); | |
} | |
function get_svg( string $name, array $atts = [] ) : string { | |
$file = get_template_directory() . "/dist/images/$name.svg"; |