Last active
February 9, 2022 15:45
-
-
Save jshwlkr/dcaf108f594c310693158b8bbfad8caf to your computer and use it in GitHub Desktop.
Scan your WordPress content for (anything) a URL and then insert some prefetch hint etc into the head element.
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
function prefix_filter_embeds( $content ) { | |
if strpos( $content, 'string' ) !== false ) { | |
add_action( 'wp_head', 'prefix_url_actions', 0 ); | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'prefix_filter_embeds' ); | |
function prefix_url_actions() { | |
echo '<link rel="prefetch" href="" crossorigin>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment