我正在尝试使用 PHP 在 WordPress HTTP 站点上加载脚本。脚本本身在另一个站点上,只能通过 HTTPS 访问。我正在使用以下行加载脚本:
wp_enqueue_script('airtable_embed', 'https://static.airtable.com/js/embed/airtable_embed.js');
但是,当页面加载时,url 中的 https 总是替换为 http,并且脚本不可通过 HTTP - 仅 HTTPS。由于找不到 HTTP 版本,因此出现以下错误:
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)
WordPress 文档说
Remote scripts can be specified with a protocol-agnostic URL, e.g. //otherdomain.com/js/their-script.js.
因此,我认为协议(protocol)从 HTTPS 更改为 HTTP 的原因是 WordPress 强制它使用与当前站点相同的协议(protocol)。我怎样才能解决这个问题并在我的 HTTP 站点中包含 HTTPS 脚本?
最佳答案
如果您将 airtable 嵌入代码段粘贴到 HTML 页面中,然后检查 DOM,您只需获取 wordpress 网站的原始 HTML。
关于php - 在 HTTP WordPress 站点中加载外部 HTTPS 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32980323/