0
我在放網頁 有錯誤此代碼插入插件Ajax的命中計數器,禁用腳本WordPress的
<script type="text/javascript"><![CDATA[function ahc_getXmlHttp(){var e;try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(n){e=false}}if(!e&&typeof XMLHttpRequest!="undefined"){e=new XMLHttpRequest}return e};var ahc_xmlhttp=ahc_getXmlHttp();ahc_xmlhttp.open("GET", "https://example.org/wp-content/plugins/ajax-hits-counte5r/increment-hits.rapid.php?post_id=547754&t="+(parseInt(new Date().getTime()))+"&r="+(parseInt(Math.random()*100000)));ahc_xmlhttp.send(null);]]></script>
AMP驗證寫道:標籤「腳本」是不允許的,除了以特定形式。
這裏插入腳本函數:
public function appendScript($content)
{
global $post;
if(is_single() || is_page())
{
if($this->getOption('use_rapid_incrementer')==1) // use rapid incrementer
{
$incrementer_url = plugin_dir_url(__FILE__).'increment-hits.rapid.php?post_id='.$post->ID.'&t=';
}
else // use simple incrementer
{
$incrementer_url = admin_url('admin-ajax.php').'?action='.$this->plugin_alias.'-increment&post_id='.$post->ID.'&t=';
}
$content .=
'<script type="text/javascript">'.
'function ahc_getXmlHttp(){var e;try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(n){e=false}}if(!e&&typeof XMLHttpRequest!="undefined"){e=new XMLHttpRequest}return e};'.
'var ahc_xmlhttp=ahc_getXmlHttp();'.
'ahc_xmlhttp.open('.
'"GET", "'.$incrementer_url.'"+(parseInt(new Date().getTime()))+"&r="+(parseInt(Math.random()*100000))'.
');'.
'ahc_xmlhttp.send(null);'.
'</script>';
}
return $content;
}
如何從AMP頁面中刪除此腳本?