Mat*_*iby 2 html javascript wordpress
我把它添加到我的WordPress 页面
if (script.readyState && script.onload!==null){
script.onreadystatechange= function () {
if (this.readyState == 'complete') mce_preload_check();
}
}
Run Code Online (Sandbox Code Playgroud)
和&&正在被关到
if (script.readyState && script.onload!==null){
Run Code Online (Sandbox Code Playgroud)
我在WordPress HTML视图中粘贴了这个,我确定这很好,但WordPress一直在显示它.怎么解决这个问题?
您需要禁用WP的自动格式化.即使在html编辑器中,WP也会自动格式化,空格和换行符会破坏你的javascript.
使用此插件http://wordpress.org/extend/plugins/wp-no-format/
2015年4月8日更新:插件已过时但仍适用于我.
这也有效:将插件直接添加到functions.php并将您的javascript <!-- noformat on -->和<!-- noformat off -->标签括起来
添加到functions.php文件:
function newautop($text)
{
$newtext = "";
$pos = 0;
$tags = array('<!-- noformat on -->', '<!-- noformat off -->');
$status = 0;
while (!(($newpos = strpos($text, $tags[$status], $pos)) === FALSE))
{
$sub = substr($text, $pos, $newpos-$pos);
if ($status)
$newtext .= $sub;
else
$newtext .= convert_chars(wptexturize(wpautop($sub))); //Apply both functions (faster)
$pos = $newpos+strlen($tags[$status]);
$status = $status?0:1;
}
$sub = substr($text, $pos, strlen($text)-$pos);
if ($status)
$newtext .= $sub;
else
$newtext .= convert_chars(wptexturize(wpautop($sub))); //Apply both functions (faster)
//To remove the tags
$newtext = str_replace($tags[0], "", $newtext);
$newtext = str_replace($tags[1], "", $newtext);
return $newtext;
}
function newtexturize($text)
{
return $text;
}
function new_convert_chars($text)
{
return $text;
}
remove_filter('the_content', 'wpautop');
add_filter('the_content', 'newautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'newtexturize');
remove_filter('the_content', 'convert_chars');
add_filter('the_content', 'new_convert_chars');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1817 次 |
| 最近记录: |