aboutsummaryrefslogtreecommitdiffstats
path: root/functions.php
diff options
context:
space:
mode:
authorJesús Eduardo <heckyel@hyperbola.info>2017-09-01 18:40:42 -0500
committerJesús Eduardo <heckyel@hyperbola.info>2017-09-01 18:40:42 -0500
commit3aed6c0e5c9eab77ba8fb99145d48a3625be6edf (patch)
tree4477f926dbd53583ba4ed37cf7430e1e636b6ecf /functions.php
parent4f3fc7f26ccc87e0c0e24e1ac28002e03863b3d8 (diff)
downloadlidra-theme-3aed6c0e5c9eab77ba8fb99145d48a3625be6edf.tar.lz
lidra-theme-3aed6c0e5c9eab77ba8fb99145d48a3625be6edf.tar.xz
lidra-theme-3aed6c0e5c9eab77ba8fb99145d48a3625be6edf.zip
limpiador de wp-embed
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/functions.php b/functions.php
index 8544cd2..b5fa805 100644
--- a/functions.php
+++ b/functions.php
@@ -114,6 +114,47 @@ function remove_dns_prefetch( $hints, $relation_type ) {
add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
+/* Limpiador de wp-embed
+------------------------------------------------------------------------------*/
+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;
+}
+
/* LibreVideoJS
------------------------------------------------------------------------------*/
include_once 'librevideojs/librevideojs.php';