如何在编辑器中添加嵌套的快捷码?

时间:2013-09-03 作者:user37549

我想为wordpress创建一个手风琴快捷码,html代码如下:

<ul class="acordian">
 <li>
  <h2>sadegh</h2>
  <p>To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.</p>
 </li>
 <li>
   <h2>sadegh</h2>
   <p>To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.</p>
 </li>
 <li>
  <h2>sadegh</h2>
  <p>To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.</p>
 </li>
 <li>
   <h2>sadegh</h2>
   <p>To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.</p>
</li>
<li>
  <h2>sadegh</h2>
  <p>To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.</p>
</li>
</ul>
为此,我创建了一个嵌套的短代码:

function Acot($params, $content= null){
    return \'<h2>\'.$content.\'</h2>\';
}
add_shortcode(\'acot\',\'Acot\');
function Acotext($params, $content= null){
    return\'<p>\'.$content.\'</p>\';
 }
 add_shortcode(\'acotext\',\'Acotext\');
 function Aco($params, $content=null){
return\'<ul class="acordian">\'.do_shortcode($content).\'</ul>\';
 }
 add_shortcode(\'aco\',\'Aco\');
 function Acol($params, $content= null){
return\'<li>\'.do_shortcode($content).\'</li>\';
  }
 add_shortcode(\'acol\',\'Acol\');
我想用一个按钮将嵌套的短代码添加到编辑器中。是否有可能做到这一点,如果有,我如何做到这一点?

1 个回复
SO网友:cybmeta

您可以开发一个TinyMCE插件并使用mce\\u external\\u插件挂钩加载它。该键位于TinyMCE插件的javascript文件中,该插件将负责将嵌套的短代码传递到编辑器文本区域。你可以看看this article (中间部分显示了如何在编辑器中添加快捷键的示例)或this one.

结束

相关推荐

如何覆盖Shortcodes.php核心文件?

我想覆盖/更新核心短代码。php文件。构建一个数组并向其他函数发送不同的数据,但我的问题是如何在不编辑核心文件的情况下做到这一点?是否有覆盖核心文件和/或函数的最佳做法?