如果有相同的问题,可以确认这似乎是jQuery的问题。我正在尝试使一个时事通讯插件再次可行,而原作者不再支持该插件。tinymce编辑器在更新到5.6之后也失败了。也许我会发布代码的详细信息。我们找到了原因。
第一部分:
function plugins_loaded() {
global $builder_id, $email_newsletter, $wp_customize;
if(isset($wp_customize)) {
$customizer_theme = $this->get_customizer_theme();
$builder_theme = $this->get_builder_theme();
if($builder_id && $customizer_theme == $builder_theme) {
//Behebung bekannter Kompatibilitätsprobleme
add_action( \'init\', array( &$this, \'cleanup_customizer\'), 1 );
add_action( \'setup_theme\' , array( &$this, \'setup_builder_header_footer\' ), 999 );
add_filter( \'wp_default_editor\', array( &$this, \'force_default_editor\' ) );
add_filter( \'user_can_richedit\', array( &$this, \'force_richedit\' ) );
add_action( \'admin_head\', array( &$this, \'prepare_tinymce\' ), 999 );
add_action( \'template_redirect\', array( &$this, \'enable_customizer\') );
}
}
第2部分
function prepare_tinymce() {
global $enewsletter_tinymce;
ob_start();
$tinymce_options = array(
\'teeny\' => false,
\'media_buttons\' => true,
\'quicktags\' => false,
\'textarea_rows\' => 25,
\'drag_drop_upload\' => true,
\'tinymce\' => array(
\'wp_skip_init\' => false,
\'theme_advanced_disable\' => \'\',
\'theme_advanced_buttons1_add\' => \'code\',
\'theme_advanced_resize_horizontal\' => true,
\'add_unload_trigger\' => false,
\'resize\' => \'both\'
),
\'editor_css\' => \'<style type="text/css">body { background: #000; }</style>\',
);
$email_content = $this->get_builder_email_content(\'\');
wp_editor($email_content, \'content_tinymce\', $tinymce_options);
$enewsletter_tinymce = ob_get_clean();
第3部分
public function render_content() {
global $enewsletter_tinymce;
?>
<span class="customize-control-title"><?php echo $this->label; ?></span>
<textarea id="<?php echo $this->id; ?>" style="display:none" <?php echo $this->link(); ?>><?php echo esc_textarea($this->value()); ?></textarea>
<?php
echo $enewsletter_tinymce;
?>
<script type="text/javascript">
jQuery(document).ready( function() {
var content = 0;
// Unsere tinyMCE-Funktion feuert bei jeder Änderung
tinymce_check_changes = setInterval(function() {
var check_content = tinyMCE.activeEditor.getContent({format : \'raw\'});
if(check_content != content && check_content != \'<p><br data-mce-bogus="1"></p>\') {
content = check_content;
jQuery(\'#<?php echo $this->id; ?>\').val(content).trigger(\'change\');
}
}, 2000);
//enables resizing of email content box
var resize;
var prev_emce_width = 0;
jQuery(\'#accordion-section-builder_email_content\').on(\'mousedown\', \'.mce-i-resize, #content_tinymce_resize\', function(){
resize_start();
});
jQuery(\'#accordion-section-builder_email_content h3\').click(function(){
resize_start();
});
jQuery("body").mouseup(function() {
clearInterval(resize);
});
function resize_start() {
resize = setInterval(function() {
emce_width = jQuery(\'#content_tinymce_ifr\').width()+65;
if(emce_width >= \'490\' && emce_width != prev_emce_width) {
jQuery(\'#customize-controls\').css("-webkit-animation", "none");
jQuery(\'#customize-controls\').css("-moz-animation", "none");
jQuery(\'#customize-controls\').css("-ms-animation", "none");
jQuery(\'#customize-controls\').css("animation", "none");
prev_emce_width = emce_width;
jQuery(\'#customize-controls, #customize-footer-actions\').css("width", emce_width+"px");
jQuery(\'.wp-full-overlay\').css("margin-left", emce_width+"px");
jQuery(\'.wp-full-overlay-sidebar\').css("margin-left", "-"+emce_width+"px");
}
},50);
}
});
</script>
<?php
}
在调试中,我可以看到:UncaughtTypeError:无法读取null的属性“getContent”
我认为tinymce在最新的jQuery版本中有一个问题,即proberty和value之间存在差异。