1

尽管 autop 功能似乎在我不想要它时给了我所有的地狱,我有几个带有 tinyMCE 文本区域的自定义元框。现在他们不存钱了

标签.. 他们似乎没问题 / 保存其他 html 标记。

我的一个盒子的 html 看起来像:

<div class="customEditor">
    <div class="custom_upload_buttons" class="hide-if-no-js"><?php do_action( 'media_buttons' ); ?></div>
    <?php $mb->the_field('below_content'); ?>
    <textarea rows="10" cols="50" name="<?php $mb->the_name(); ?>" rows="3"><?php $mb->the_value(); ?></textarea>
</div>

命名和东西都由 WPAlchemy 处理,因此奇怪的 $mb->the_name() 东西

功能 my_admin_print_footer_scripts() { ?>

/*

/* * 多个 TinyMCE 设置 */
设置= {模式:“特定文本区域”,宽度:“100%”,主题:“高级”,皮肤:“wp_theme”,主题高级按钮1:“粗体,斜体,删除线,下划线,|,bullist,numlist,blockquote,|,justifyleft ,justifycenter,justifyright,|,link,unlink,|,spellchecker", theme_advanced_buttons2:"formatselect,XXXforecolor,|,pastetext,pasteword,removeformat,|,outdent,indent,|,undo,redo,|,code", theme_advanced_buttons3: "", theme_advanced_buttons4:"", language:"en", spellchecker_languages:"+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,葡萄牙语=pt,西班牙语=es,瑞典语=sv", theme_advanced_toolbar_location:"top", theme_advanced_toolbar_align:"left",theme_advanced_statusbar_location:"bottom", theme_advanced_resizing:"1", theme_advanced_resize_horizo​​ntal:"", dialog_type:"modal", relative_urls:"", remove_script_host:"", convert_urls:"", apply_source_formatting:"", remove_linebreaks:"1", gecko_spellcheck :“1”,实体:“38,amp,60,lt,62,gt”,accessibility_focus:“1”,tabfocus_elements:“major-publishing-actions”,media_strict:“”,paste_remove_styles:“1”,paste_remove_spans: "1", paste_strip_class_attributes:"all", wpeditimage_disable_captions:"", plugins:"safari,inlinepopups,spellchecker,paste,wordpress,tabfocus" };

  jQuery(document).ready(function($) {


          var $ta, id, mceID;


          $('.customEditor textarea').each(function(i){
              $ta = $(this);
              id = $ta.attr('id');

              if (!id){
                  id = 'customEditor-' + i;
                  $ta.attr('id',id);
              }
              tinyMCE.settings = settings;
              tinyMCE.execCommand('mceAddControl',

假的,身份证);});

          $('.custom_upload_buttons a').each(function() {
              $(this).click(function() {
                  mceID = $(this).parent().next('textarea').attr('id');
                  window.send_to_editor = window.send_to_editor_clone;
              });

              window.send_to_editor_clone = function(html){
                  tinyMCE.execInstanceCommand(mceID, 'mceInsertContent', false, html);
                  tb_remove();
              }
          });




      });     /* ]]> */</script><?php }

// 重要:注意优先级99,js需要放在tinymce加载后 add_action('admin_print_footer_scripts','my_admin_print_footer_scripts',99);

4

3 回答 3

0

我最终解决了这个问题。事实证明,WP 不会将 p 标签保存到编辑器中。但是换行符等被转换为带有某些 WP 过滤器的 p 标签。所以解决方案是将我的文本框更改为如下所示的组合:

<textarea class="wysiwyg" rows="10" cols="50" name="<?php $mb->the_name(); ?>" rows="3"><?php echo wp_richedit_pre($mb->get_the_value()); ?></textarea>

并在输出上运行 wpautop(以及其他一些 the_content 的默认过滤器

于 2011-07-05T05:02:28.833 回答
0

好的,那我想我知道为什么您的编辑器内容没有保存。您需要调用tinyMCE.triggerSave();它会将编辑器内容写入他们为其创建的 html 元素。tinymce 编辑器由 iframe 组成,仅在 html 元素和 iframe 之间移动内容。

于 2011-05-12T07:45:56.047 回答
0

来自:https ://wordpress.stackexchange.com/questions/15394/extra-tinymce-editor-strips-p-and-br-tags/17951#17951

使用 save_post 挂钩在 TinyMCE 字段上手动运行 wpautop()。

于 2011-05-25T08:28:31.447 回答