should you disable embed scripts in wordpress

Solutions on MaxInterview for should you disable embed scripts in wordpress by the best coders in the world

showing results for - "should you disable embed scripts in wordpress"
Fernando
22 Jan 2018
1function disable_embeds_code_init() {
2
3 // Remove the REST API endpoint.
4 remove_action( 'rest_api_init', 'wp_oembed_register_route' );
5
6 // Turn off oEmbed auto discovery.
7 add_filter( 'embed_oembed_discover', '__return_false' );
8
9 // Don't filter oEmbed results.
10 remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
11
12 // Remove oEmbed discovery links.
13 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
14
15 // Remove oEmbed-specific JavaScript from the front-end and back-end.
16 remove_action( 'wp_head', 'wp_oembed_add_host_js' );
17 add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' );
18
19 // Remove all embeds rewrite rules.
20 add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
21
22 // Remove filter of the oEmbed result before any HTTP requests are made.
23 remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
24}
25
26add_action( 'init', 'disable_embeds_code_init', 9999 );
27
28function disable_embeds_tiny_mce_plugin($plugins) {
29    return array_diff($plugins, array('wpembed'));
30}
31
32function disable_embeds_rewrites($rules) {
33    foreach($rules as $rule => $rewrite) {
34        if(false !== strpos($rewrite, 'embed=true')) {
35            unset($rules[$rule]);
36        }
37    }
38    return $rules;
39}
similar questions