From 2152e4d4350fae01bf215acadd9b89b7fd339c16 Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Tue, 7 Jun 2022 19:33:46 +0900 Subject: [PATCH] disable oembed if url is not my site url. --- functions.php | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/functions.php b/functions.php index 444bb1d..68dae55 100644 --- a/functions.php +++ b/functions.php @@ -1,30 +1,35 @@ @@ -37,3 +42,14 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= EOF; } + +// disable oembed if url is not my site url +add_filter('oembed_request_post_id', 'niu_check_oembed_url', 10, 2); +function niu_check_oembed_url($post_id, $url) +{ + if (!preg_match('/^'.preg_quote(get_site_url(), '/').'/', $url)) { + return 0; + } + + return $post_id; +}