How to hide two lines which disclose secured data inside WordPress?

How to hide two lines which disclose secured data inside WordPress?

<link rel="alternate" type="application/json+oembed" href="https://example.com/wp-json/oembed/1.0/embed?url=" />
<link rel="alternate" type="text/xml+oembed" href="https://example.com/wp-json/oembed/1.0/embed?url=;format=xml" />

As I understand disabled embed content can be achieved and throws warning 404:

   {"code":"rest_no_route","message":"No route was found matching the URL and request method.","data":{"status":404}}

But is it possible to hide code within WordPress and not possible to be clicked?
Source: https://kinsta.com/knowledgebase/disable-embeds-wordpress/

What links are you talking about that could be clicked?

Maybe read https://wordpress.stackexchange.com/questions/242180/what-are-the-oembed-links-for

Do you have a service configured in those links? (I assume you altered them for this post.)

https://oembed.com/

The simplest way to disable the embeds is by using a WordPress plugin like “Disable Embeds”. However, if you prefer not to use a plugin, you can add the following code to your theme’s functions.php file or a custom functionality plugin

// Disable the oEmbed REST API route
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-specific JavaScript from the front-end and back-end.
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
add_filter( 'tiny_mce_plugins', 'disable_embed_tinymce_plugin' );

// Remove all embed discovery links.
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );

// Remove the JavaScript used to embed the media.
remove_action( 'wp_head', 'wp_oembed_add_host_js' );

function disable_embed_tinymce_plugin( $plugins ) {
    return array_diff( $plugins, array( 'wpembed' ) );
}

The above code will also take care of removing the <link rel="alternate" ... /> tags from your site’s header.

I suggest, instead of editing your main theme’s functions.php, consider using a child theme or a custom functionality plugin to add the above code. This will ensure that you don’t lose these changes when the theme gets updated.
Good luck

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.