Is there any way to render the WordPress Gutenberg core/embed block in PHP by passing in the URL?
Is there any way to render the WordPress Gutenberg core/embed block in PHP by passing in the URL?
Is there any way to render the WordPress Gutenberg core/embed block in PHP by passing in the URL?
The quick way to disable oEmbeds would be add_filter( ‘pre_oembed_result’, ‘__return_false’ ); If you want to disable it for all external links then try: /** * Disable oEmbeds for external links */ add_filter( ‘pre_oembed_result’, function( $result, $url, $args ) { if( parse_url( home_url(), PHP_URL_HOST ) !== parse_url( $url, PHP_URL_HOST ) ) $result = false; return … Read more
You could create a new callback for the embed_oembed_html filter and target the third input argument, the oembed $url. Then you could e.g. create boolean helper functions like (untested): function is_oembed_from_video_specific_hosts_wpse274552( $url ) { return in_array( parse_url( $url, PHP_URL_HOST ), [ ‘youtube.com’, ‘youtu.be’, ‘vimeo.com’, // … etc ], true ); } or a more detailed … Read more
If i get it right, then you just need to get that value from post meta, and make condition. $image_or_video = get_post_meta($post_id, $prefix . ‘image_or_video’, true); // Option 2 is selected if( ‘custom’ === $image_or_video ){ //Then execute some PHP code }
Add the below code in the functions.php file and it will create a text field in the general setting options page add_action(‘admin_init’, ’embed_url_initialize’); function embed_url_initialize() { // First, we register a section. This is necessary since all future options must belong to one. add_settings_section( ‘general_settings_section’, // ID used to identify this section and with which … Read more
Answering my own question… I figured it would be something simple. I had assumed that the videos I was trying to embed had ‘allow embedding’ activated. They didn’t. When you edit the video in Youtube Studio, go to the “Advanced” tag and click “Allow Embedding”. It’s the only way a Youtube video will show in … Read more
After looking at the code reference for wp_oembed_get (and WP_oEmbed::get_html()) I don’t think embed_oembed_html fitler gets fired when that function is called. But I might have missed something. You could try using WP_Embed::shortcode( array $attr, string $url=”” ) instead of wp_oembed_get as this would mimic what happens with the native post types and the filter … Read more
When you’re referring to using oEmbed codes, I’m assuming that you’re referring to WordPress’ ability to take a URL to media (such as one from YouTube) and automatically embed that into a post. If that’s the case, then you can take advantage of the embed_oembed_html hook that WordPress provides. Here’s how you can do it … Read more
Screencast.com has a dedicated GitHub page with hands full of tutorials (no need to clone them over here). You can then utilize wp_oembed_get() or register a new provider using wp_oembed_add_provider(). echo wp_oembed_get( ‘http://example.com’, array( ‘width’ => 1920, ‘height’ => 1080 ) ); Or add the provider: wp_oembed_add_provider( ‘http://screencast.com/*’, // The Format ‘http://screencast.com/’, // The Provider … Read more
You can use the oEmbed in Comments plugin. This is the code the author, Evan Solomon, uses in this plugin, I used it on a site a while back just copy it in your themes functions file or even better, download his plugin 🙂 class ES_oEmbed_Comments { function __construct() { add_action( ‘init’, array( $this, ‘init’ … Read more