Last active
June 22, 2024 22:05
-
-
Save Crocoblock/4eca30f9704da5d60e998b9fc298ad97 to your computer and use it in GitHub Desktop.
JetFormBuilder Fix embedding videos in some cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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