How to disable YouTube (and any other oembed) embeding in the editor

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

Responsive embed for the video shortcode

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

Checkbox on a meta box using CMB2 Plugin

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 field to dashboard to update embedded URL on homepage?

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

Applying an oEmbed filter to a custom post type

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

Embedding screencast.com Videos in WordPress Multisite

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

oEmbed does not work for comments

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)