结果TinyMCE有自己的autop
设置,因此,如果在排序之前杀死它,然后将其放回,您应该可以继续!
查看autop
在此代码段中设置处理:
<script>
(function($) {
// by default, wpautop will be true
var wpautop = true;
// this function wraps subsequent additions of TinyMCE
$(function() {
// save the original state of TinyMCE\'s wpautop
wpautop = tinyMCE.settings.wpautop;
// bind to our custom event that fires when a new TinyMCE is added
$(document).on( \'attachments/new\', function( event ) {
// initialize the applicable TinyMCE instances
$(\'.attachments-field-wysiwyg:not(.ready)\').init_wysiwyg();
});
// initialize the applicable TinyMCE instances
$(\'.attachments-field-wysiwyg\').init_wysiwyg();
});
// init TinyMCE
$.fn.init_wysiwyg = function() {
this.each(function() {
// a flag for this instance
$(this).addClass(\'ready\');
var input_id = $(this).attr(\'id\');
// create wysiwyg
tinyMCE.settings.theme_advanced_buttons2 += \',code\'; // add HTML button
tinyMCE.settings.wpautop = false; // force wpautop to false to preserve linebreaks
tinyMCE.execCommand(\'mceAddControl\', false, input_id); // add TinyMCE control
tinyMCE.settings.wpautop = wpautop; // reset the original wpautop setting
});
};
// bind to our custom event that fires when sorting starts
$(document).on(\'attachments/sortable_start\', function(event, ui) {
// force wpautop to be false (and by doing so preserve our line breaks)
tinyMCE.settings.wpautop = false;
$(\'.attachments-field-wysiwyg\').each(function() {
tinyMCE.execCommand(\'mceRemoveControl\', false, $(this).attr(\'id\'));
});
});
// bind to our custom event that fires when when sorting starts
$(document).on(\'attachments/sortable_stop\', function(event, ui) {
$(\'.attachments-field-wysiwyg\').each(function() {
tinyMCE.execCommand(\'mceAddControl\', false, $(this).attr(\'id\'));
});
// reset the original wpautop setting
tinyMCE.settings.wpautop = wpautop;
});
})(jQuery);
</script>
从我的WordPress插件中提取的代码片段,附件:
https://github.com/jchristopher/attachments/blob/3.3.2/classes/fields/class.field.wysiwyg.php