【发布时间】:2014-10-11 17:28:10
【问题描述】:
- WordPress 主题选项面板。
- 用户输入其非响应式 AdSense 代码的文本区域字段。
如果用户输入非响应式 Adsense 代码,我需要将该代码转换为响应式代码,如下所示:
无响应代码:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- non responsive ads -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-12345"
data-ad-slot="xxxxxxxxxxxxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
以上代码需要转换成:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-12345"
data-ad-slot="xxxxxxxxxxxxxx"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
我想这项工作可以使用 preg_match 完成,但如何?
谢谢。
【问题讨论】:
-
为
.adsbygoogle添加css规则怎么样?
标签: javascript php preg-match adsense