I'm using this code to embed Gists in WordPress. It works fine, Gists show up, but I keep getting an error in my debug.log file: PHP Notice: Undefined offset: 2 in /functions.php on line 333
(line 333 is esc_attr($matches[2])
)
wp_embed_register_handler( 'gist', '/https?:\/\/gist\.github\.com\/([a-z0-9]+)(\?file=.*)?/i', 'embed_handler_gist' );
function embed_handler_gist( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<script src="https://gist.github.com/%1$s.js%2$s"></script>',
esc_attr($matches[1]),
esc_attr($matches[2])
);
return apply_filters( 'embed_gist', $embed, $matches, $attr, $url, $rawattr );
}