Video Auto Embed problem with Kadence Virtue Premium Theme

The function has_blocks() was introduced in version 5.0 of WordPress, hence the reason for the error in ClassicPress.

There’s no reason for this function to exist in CP as it is not block based.

As Tim says, there’s a very simple way around this - and one that fixes the problem of embeds not working.

If you’re using a child theme, in its functions.php add the following:

function remove_virtue_embed() {
	remove_filter( 'embed_oembed_html', 'virtue_embed_wrap', 90, 4 );
}
add_action( 'after_setup_theme', 'remove_virtue_embed', 91 );

function cp_virtue_embed_wrap( $cache, $url, $attr = '', $post_ID = '' ) {
	if ( ! function_exists( 'classicpress_version' ) ) {
		if ( ! has_blocks() ) {
			$cache = '<div class="entry-content-asset videofit">' . $cache . '</div>';
		}
	}
	return $cache;
}
add_filter( 'embed_oembed_html', 'cp_virtue_embed_wrap', 91, 4 );

I was only able to test this on the free version of the theme but it worked for me. It not only got rid of the error, it restored the standard WordPress embed functionality.

4 Likes

@1stepforward… Yippe! this code solved the problem! Thank you very, very much for your kind attention to this!

3 Likes

You’re welcome :slight_smile:

4 Likes

One takeaway from this, maybe we should consider creating a doc article about making WordPress theme compatible with ClassicPress. So users can send it to theme developers.

5 Likes

Yes, you’re right @viktor. That would be a good addition to the docs, although it is already covered to some extent here https://www.classicpress.net/for-plugin-developers/.

For now at least, I think the use of function_exists( 'classicpress_version' ) would be best in the FAQ section of the docs, which is currently in the process of being updated (see https://github.com/ClassicPress/ClassicPress-docs/blob/47eb9a3c7bd4175599404a132aa0a59877a58ea3/faq-support.md). In due course, we’ll need to consider creating a separate page for theme and plugin developers to cover issues such as this.

I had been thinking of creating a short blog post about it too.

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.