在自定义元框中,每次单击按钮时,我都需要生成一个微小的wysiwyg wp\\U编辑器。。我为此做了很多努力,但没能实现。
The js
$.ajax({
url: ajaxurl,
data: formData,
dataType: \'html\',
cache: false,
contentType: false,
processData: false,
type: \'POST\',
error: function(jqXHR, textStatus, errorThrown) {
console.log(\'FATAL ERROR: \' + JSON.stringify(jqXHR) + \' \' + textStatus + \' \' + errorThrown);
},
success: function(data, textStatus, jqXHR) {
clone.find(\'.content\').append(data);
// Insert new section at the bottom
$(clone).appendTo($(\'#nwac_accordion_plus_signs_container\'));
}
});
The php
// WP Editor
$content = \'Plus sign content here\';
$editor_id = \'nwac_plus_signs_\' . $_POST[\'plus_sign_id\'] . \'_template\';
$settings = array(
\'media_buttons\' => false,
\'teeny\' => true,
\'editor_class\' => \'plus_sign_editor\',
\'textarea_rows\' => 5
);
// Return editor
wp_editor($content, $editor_id, $settings);
\\_WP_Editors::enqueue_scripts();
print_footer_scripts();
\\_WP_Editors::editor_js();
die();
使用上面的代码,我把编辑器弄得一团糟!
SO网友:numediaweb
忘记在这种情况下使用wp\\U编辑器。。相反,使用核心tinymce,类似于;
tinymce.init({
//selector: \'customEditor-\' + nextPlusSignId,
editor_selector: \'nwac_editor_\' + nextPlusSignId,
mode: "specific_textareas",
media_buttons: false,
menubar: false,
content_css: nw.baseurl + \'/skins/wordpress/wp-content.css\',
body_class: \'mce-content-body nwac_plus_signs_\' + nextPlusSignId + \'_template post-type-products post-status-publish mceContentBody webkit wp-editor wp-autoresize html4-captions has-focus\',
});