使用WP 4.0。我认为html5模式应该在默认情况下打开。这意味着单击B(粗体)按钮将生成<b>
标记,而不是<strong>
标记(具有不同的语义)。单击I按钮获取<i>
标记而不是<em>
. 我怎样才能让编辑这样做?
WP POST编辑器B(粗体)按钮是否应该在HTML5中插入<b>标记而不是<strong>?
3 个回复
SO网友:buckthorn
这是我想到的。到目前为止,它似乎没有损坏任何东西:
add_filter(\'tiny_mce_before_init\', \'modify_formats\');
function modify_formats($settings){
$formats = array(
\'bold\' => array(\'inline\' => \'b\'),
\'italic\' => array(\'inline\' => \'i\')
);
$settings[\'formats\'] = json_encode( $formats );
return $settings;
}
在这里可以很容易地使用plus类,但考虑到html5下规范的变化,大多数情况下似乎都可以接受。(我不认为将这些标记从表象转换为结构标记的情况非常有说服力,但在这一点上可能不值得争论)。任何想要并且可能应该添加必要按钮并将其应用于适当位置的人。SO网友:Gufran Hasan
是的,您可以在TinyMCE编辑器中进行更改formats
作为:
tinymce.init({
selector: \'textarea\',
formats: {
// Changes the default format for the bold button to produce a span with a bold class
bold: { inline: \'b\', classes: \'bold\' }
}
});
Content formatting options
in TinyMCE Editor 如果您在WordPress上,那么本文将对您有所帮助https://tfrommen.de/using-custom-formats-in-tinymce/
SO网友:skim-
i和b标记是完全有效的HTML(5)。
否则(未测试,仅在作为b标记保存到DB的输出上):
function change_b_to_strong($content){
str_replace(\'<b>\', \'<strong>\', $content);
str_replace(\'</b>\', \'</strong>\', $content);
return $content;
}
add_filter( \'the_content\', \'change_b_to_strong\' );
结束