我正在尝试为我的主题添加一些选项,并且我添加了一个所见即所得的文本区域,并且该文本区域的值将进入选项表(wp-options)。
所以这是我使用的代码:
$settings = array(
'textarea_name' => 'options[content]',
'quicktags' => true,
'tinymce'=> true,
);
wp_editor( get_option('content','default_value'), 'content', $settings );
Run Code Online (Sandbox Code Playgroud)
这项工作非常好,但这显然<p>从内容中删除了所有标签,我完全不知道为什么..
例如,当我写这样的东西时:
Level 1 title
Level 2 title
a paragraph
another paragraph
Run Code Online (Sandbox Code Playgroud)
这是发送到名为“内容”的数据库的代码:
<h1>Level 1 title</h1>
<h2>Level 2 title</h2>
a paragraph another paragraph
Run Code Online (Sandbox Code Playgroud)
而不是这个:
<h1>Level 1 title</h1>
<h2>Level 2 title</h2>
<p>a paragraph</p>
<p>another paragraph</p>
Run Code Online (Sandbox Code Playgroud)
你知道我可以做些什么来获得所有标签不变的价值吗?
ps:当我<p>手动将标签添加到文本侧时,它会一直工作,直到我回到可视侧并重新保存。
谢谢你的帮助
我试图在每个具有.smoothScroll类的按钮上添加smoothScroll动画.
所以我这样做了:
// SmoothSCroll
var smoothScroll = document.querySelectorAll('.smoothScroll');
[].forEach.call(smoothScroll, function (el) {
el.addEventListener('click', function() {
var offset = $(this.hash).offset().top;
$('html, body').stop().animate({
scrollTop: offset - (window.innerHeight/2) + ($(this.hash).innerHeight()/2)
}, 400 );
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
https://jsfiddle.net/jt2jo3pt/2/
我不知道你是否注意到发生了什么,但是当点击触发时有一点闪光(滚动条在光滑滚动之前下降了一点)
但当我尝试像这样的完整Jquery:
$('.smoothScroll').click(function(e){
var offset = $(this.hash).offset().top;
$('html, body').stop().animate({
scrollTop: offset - (window.innerHeight/2) + ($(this.hash).innerHeight()/2)
}, 400 );
return false;
});
Run Code Online (Sandbox Code Playgroud)
我没有这种冒泡效果:https://jsfiddle.net/34w72v1v/
您是否知道querySelectorAll方法可能导致此问题的原因是什么?
我尝试不使用jQuery所以我需要知道发生了什么才能学习:)
谢谢你的时间.