WordPress pornhub videos embed using wp_embed_register_handler not working

I’ve been trying to embed videos from pornhub in my website using wordpress’s wp_embed_register_handler(). I followed this example from wordpress but it’s not working.

wp_embed_register_handler(
    'pornhub',
    '#https://www\.pornhub\.com/view_video.php?viewkey=([a-zA-Z0-9_-]+)$#i',
    'wpdocs_embed_handler_pornhub'
);
 
function wpdocs_embed_handler_pornhub( $matches, $attr, $url, $rawattr ) {
 
    $embed = sprintf(
            '<iframe src="https://www.pornhub.com/embed/%1$s" frameborder="0" width="560" height="315" scrolling="no" allowfullscreen></iframe>',
            esc_attr($matches[1])
            );
 
    return $embed;
}

I’m on latest version 5.4.2. Has it stopped working or I’m not doing it correctly?

Leave a Comment