简体   繁体   中英

Load external HTTPS script in HTTP WordPress site

I am trying to load a script on a WordPress HTTP site using PHP. The script itself is on another site, and is only accessible through HTTPS. I am loading the script using the line:

wp_enqueue_script('airtable_embed', 'https://static.airtable.com/js/embed/airtable_embed.js');

However, when the page loads, the https in the url is always replaced by http, and the script is not available through HTTP - only HTTPS. Since it can't find the HTTP version, it gives the following error:

http://static.airtable.com/js/embed/airtable_embed.js?ver=4.3.1
Failed to load resource: the server responded with a status of 403 (Forbidden)

The WordPress documentation says that

Remote scripts can be specified with a protocol-agnostic URL, eg //otherdomain.com/js/their-script.js.

So, I think the reason the protocol is being changed from HTTPS to HTTP is that WordPress forces it to use the same protocol as the current site. How can I get around this and include the HTTPS script in my HTTP site?

如果您将可嵌入空气的代码段粘贴到HTML页面中,然后检查DOM,则只需为wordpress网站获取原始HTML。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM