Want to block oEmbed requests that contain non-https URLs, but following code isn’t helping me. Not sure if this is even the right hook. Any ideas?

add_filter('pre_oembed_result', array($this, 'filter_oembed'), 5, 3);

function filter_oembed ($result, $url, $args) {
    if (substr($url, 0, 7) === "http://") {
        return null;

I am using WordPress 4.7.2.

Read more here: How to block WordPress oEmbed HTTP URLs


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: