WordPress 6.9 开始 URL 转义函数可以支持 HTTPS作为默认协议

💡 原文中文,约900字,阅读约需3分钟。
📝

内容提要

在 WordPress 6.9 之前,esc_url() 函数仅支持 http:// 协议。自 6.9 起,如果 $protocols 的第一个元素为 'https',则会添加 https://,推荐默认使用 HTTPS。

🎯

关键要点

  • 在 WordPress 6.9 之前,esc_url() 函数只能添加 http:// 协议。
  • WordPress 6.9 开始支持 HTTPS 作为默认协议。
  • 当 esc_url() 的 $protocols 参数第一个元素为 'https' 时,会在 URL 前添加 https://。
  • 如果 $protocols 参数中只有 'https',则 esc_url() 返回空字符串。
  • 推荐在保持向后兼容性的前提下,默认使用 'https'。
➡️

继续阅读