wordpress extended_valid_elements用于脚本标记?

Joh*_*ohn 5 wordpress tinymce

有人能告诉我如何告诉Wordpress的tinymce编辑器不要删除脚本标签吗?我看了看wp-admin/includes/post.php并补充道

'extended_valid_elements'=>'script[charset|defer|language|src|type]',
Run Code Online (Sandbox Code Playgroud)

到了$initArray.

当我在CMS帖子编辑器上执行查看源代码时,我发现它确实显示如下:

<script type="text/javascript">
/* <![CDATA[ */
tinyMCEPreInit = {
    base : "http://dev.esolar.ca/wp-includes/js/tinymce",
    suffix : "",
    query : "ver=327-1235",
    mceInit : {
        mode:"specific_textareas", 
        editor_selector:"theEditor", 
        width:"100%", 
        theme:"advanced", 
        skin:"wp_theme",
        theme_advanced_buttons1:"bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,wp_more,|,spellchecker,fullscreen,wp_adv", 
        theme_advanced_buttons2:"formatselect,underline,justifyfull,forecolor,|,pastetext,pasteword,removeformat,|,charmap,|,outdent,indent,|,undo,redo,wp_help", 
        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,Portuguese=pt,Spanish=es,Swedish=sv",
        theme_advanced_toolbar_location:"top", 
        theme_advanced_toolbar_align:"left",           
        theme_advanced_statusbar_location:"bottom", 
        theme_advanced_resizing:"1", 
        theme_advanced_resize_horizontal:"", 
        dialog_type:"modal", 
        relative_urls:"", 
        remove_script_host:"", 
        convert_urls:"", 
        apply_source_formatting:"", 
        remove_linebreaks:"1", 
        gecko_spellcheck:"1", 
        entities:"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,media,fullscreen,wpeditimage,wpgallery,tabfocus"
    },
    load_ext : function(url,lang){
        var sl=tinymce.ScriptLoader;
        sl.markDone(url+'/langs/'+lang+'.js');
        sl.markDone(url+'/langs/'+lang+'_dlg.js');
    }
};
/* ]]> */
</script>
Run Code Online (Sandbox Code Playgroud)

但出于某种原因,我的编辑仍然没有保存<script>标签.我究竟做错了什么?

The*_*dic 5

在您的帖子保存在数据库中之前,这取决于KSES过滤.

在你的主题的functions.php中,全局化变量$allowedpostags,然后添加你想要允许的标签;

 global $allowedposttags;
 $allowedposttags['script'] = array(
     'type' => array(),
     'src' => array()
 );
Run Code Online (Sandbox Code Playgroud)

请注意数组的结构,以及您必须指定允许的属性的事实.


Joh*_*ohn 0

我对 iframe 也有类似的问题。我认为,而不是<script attributes>,它可能是[script attributes]。你必须查找语法