阻止WordPress将脚本包含在CDATA中 [英] Stop WordPress from enclosing script in CDATA

查看:74
本文介绍了阻止WordPress将脚本包含在CDATA中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WordPress的HTML导入插件导入HTML页面。

I am importing HTML pages using HTML import plugin for WordPress.

我有一个用于导入的google地图的代码段。

I have a code snippet for google maps, which is imported.

但是,在导入后,它包含了 CDATA 中的 script 标记。如果我删除了CDATA,则映射工作正常。如何阻止WordPress用CDATA封闭脚本?

However, after import, it encloses the script tag in CDATA. If I remove CDATA, the map works fine. How do I stop WordPress from enclosing the script with CDATA?

这是脚本:

<script type="text/javascript">
    <[[CDATA[
      var locations = [ ['<strong>Alabama', 33.606379, -86.50249, 1] ];
      var map = new google.maps.Map(document.getElementById("map"), {
        zoom: 5,
        center: new google.maps.LatLng(33.606379, -86.50249),
        mapTypeId: google.maps.MapTypeId.ROADMAP
      });
      var infowindow = new google.maps.InfoWindow();
      var marker, i;
      for (i = 0; i < locations.length; i++) {
        marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map
      });
      google.maps.event.addListener(marker, click, (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  ]]>;
</script>


推荐答案

$content = str_replace(']]>', ']]&gt;', $content);

wp-includes\post-template.php第167行

wp-includes\post-template.php line 167

这篇关于阻止WordPress将脚本包含在CDATA中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆