- WordPress主題選項面板。
- 用戶輸入無響應的AdSense代碼的textarea字段。
我需要,如果用戶輸入一個非響應AdSense代碼,該代碼可以在響應代碼轉換爲:如何使用preg_match自動轉換自適應廣告中的常規Google AdSense廣告?
NON REPONSIVE CODE:
<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規則? – Cerbrus 2014-10-10 13:35:10
有趣。日Thnx – 2014-10-10 13:38:14