Skip to content

Instantly share code, notes, and snippets.

@ngm
Created March 28, 2019 22:50
Show Gist options
  • Save ngm/868e7ae1617fd41a185eddc4599681f0 to your computer and use it in GitHub Desktop.
Save ngm/868e7ae1617fd41a185eddc4599681f0 to your computer and use it in GitHub Desktop.
Wordpress embed handler for invidio.us
wp_embed_register_handler( 'invidious_watch', '#https?://invidio\.us/watch\?v=([A-Za-z0-9\-_]+)#i', 'wp_embed_handler_invidious' );
wp_embed_register_handler( 'invidious_embed', '#https?://invidio\.us/embed/([A-Za-z0-9\-_]+)#i', 'wp_embed_handler_invidious' );
function wp_embed_handler_invidious( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<iframe src="https://invidio.us/embed/%1$s" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" width="600" height="400"></iframe>',
esc_attr($matches[1])
);
return $embed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment