[Support request] Disable Embeds

Home Forums Support [Support request] Disable Embeds

Home Forums Support Disable Embeds

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #809127
    Florian

    Hello,
    I tried many different plugins and PHP snippets to disable the automatic embedding of external content (YT videos, tweets etc.) but none is working.
    Is it possible that the theme is the reason for it?

    #809380
    David
    Staff
    Customer Support

    Hi there,

    this article provides a few options:

    https://kinsta.com/knowledgebase/disable-embeds-wordpress/

    #809383
    Florian

    Thank you but I’ve tried this and all other plugins I could find. I also tried all PHP code snippets from the first few pages of Google results. I tried everything but I am still able to embed all forms of content (Instagram, Twitter, Youtube).

    #809464
    David
    Staff
    Customer Support

    Odd, this may be a WP 5.0 issue – might be worth reaching out to the author of the Disable Embeds plugin he is a major contributor to WordPress he may be able to advise.

    #809489
    Florian

    The plugin you posted is not for disabling embeds of Youtube, Twitter etc, but just to disable embeds of other WP sites, so there is no point in reaching out.

    “This basically means nobody can embed your WordPress site and you can’t embed other WordPress sites.
    Embeds for Twitter, Facebook, etc. aren’t blocked or anything and they continue to work.”
    https://wordpress.org/support/topic/latest-update-has-broken-plugin-2/

    #809516
    Tom
    Lead Developer
    Lead Developer

    Are you adding the links inside Gutenberg? It’s likely that Gutenberg will automatically embed them. What happens if you add the links using a custom HTML block?

    #809525
    Florian

    I add the links over the classic editor and over the editor in a forum plugin (which uses the normal backend editor)

    I tried different approaches for like 16h now but something must be interfering with it.

    #809527
    Tom
    Lead Developer
    Lead Developer

    The theme itself doesn’t do anything when it comes to embeds.

    Perhaps this might help?: https://wordpress.stackexchange.com/questions/202496/disable-automatic-oembed-of-a-youtube-url-within-the-content

    #809528
    Florian

    No I’ve tried this snippet alone probably 5 times already.

    I have to figure out a way now how to check for any interfering code.

    #809824
    Tom
    Lead Developer
    Lead Developer

    Did you try the second code on that page?: https://wordpress.stackexchange.com/a/208065

    That should handle everything inside WordPress which outputs embeds.

    #809827
    Florian

    Yes, I tried all of them. Anyway, the problem resolved itself indirectly (I don’t need it anymore)

    #1064650
    Shrawan

    Hello support,

    To disable Embeds can I use the Code Snippets WP plugin?

    And which of the codes would you recommend I run?

    OPTION 1 —

    function disable_embeds_code_init() {

    // Remove the REST API endpoint.
    remove_action( ‘rest_api_init’, ‘wp_oembed_register_route’ );

    // Turn off oEmbed auto discovery.
    add_filter( ’embed_oembed_discover’, ‘__return_false’ );

    // Don’t filter oEmbed results.
    remove_filter( ‘oembed_dataparse’, ‘wp_filter_oembed_result’, 10 );

    // Remove oEmbed discovery links.
    remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’ );

    // Remove oEmbed-specific JavaScript from the front-end and back-end.
    remove_action( ‘wp_head’, ‘wp_oembed_add_host_js’ );
    add_filter( ‘tiny_mce_plugins’, ‘disable_embeds_tiny_mce_plugin’ );

    // Remove all embeds rewrite rules.
    add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ );

    // Remove filter of the oEmbed result before any HTTP requests are made.
    remove_filter( ‘pre_oembed_result’, ‘wp_filter_pre_oembed_result’, 10 );
    }

    add_action( ‘init’, ‘disable_embeds_code_init’, 9999 );

    function disable_embeds_tiny_mce_plugin($plugins) {
    return array_diff($plugins, array(‘wpembed’));
    }

    function disable_embeds_rewrites($rules) {
    foreach($rules as $rule => $rewrite) {
    if(false !== strpos($rewrite, ’embed=true’)) {
    unset($rules[$rule]);
    }
    }
    return $rules;
    }

    OPTION 2 —

    function wpassist_dequeue_scripts(){
    wp_deregister_script(‘wp-embed’);
    }
    add_action( ‘wp_enqueue_scripts’, ‘wpassist_dequeue_scripts’ );

    #1064971
    Leo
    Staff
    Customer Support

    Yeah Code Snippets plugin can be used to insert those functions.

    You will need to try the codes yourself and see which one works and suits your need.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.