Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Last active June 22, 2024 22:05
Show Gist options
  • Save Crocoblock/4eca30f9704da5d60e998b9fc298ad97 to your computer and use it in GitHub Desktop.
Save Crocoblock/4eca30f9704da5d60e998b9fc298ad97 to your computer and use it in GitHub Desktop.
JetFormBuilder Fix embedding videos in some cases
<?php
class JFB_Autoembed_Fix {
public function __construct() {
add_filter( 'jet-form-builder/before-start-form', array( $this, 'add_filter' ) );
add_filter( 'jet-form-builder/after-end-form', array( $this, 'remove_filter' ) );
}
public function add_filter( $start ) {
add_filter( 'render_block', array( $this, 'autoembed' ), 10 );
return $start;
}
public function remove_filter( $end ) {
remove_filter( 'render_block', array( $this, 'autoembed' ), 10 );
return $end;
}
public function autoembed( $content ) {
global $wp_embed;
if ( empty( $wp_embed ) ) {
return $content;
}
return $wp_embed->autoembed( $content );
}
}
new JFB_Autoembed_Fix();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment