默认编辑器内容pu_default_editor_content()
当用户禁用可视化编辑器时(根据您的注释),将考虑该函数。
function pu_default_editor_content( $content ) {
global $post_type;
switch( $post_type ) {
case \'post\' :
$content = \'Default content for blog posts. » » »\';
$rich_editing = get_user_option( \'rich_editing\', get_current_user_id() );
if ( \'false\' === $rich_editing ) {
$content = htmlspecialchars( $content );
}
break;
}
return $content;
}
add_filter( \'default_content\', \'pu_default_editor_content\' );
富文本编辑器禁用视图
用户拥有可视化编辑器
disabled 在“用户配置文件”下。
TinyMCE/QuickTags如果启用了可视化编辑器(这是默认设置),则需要将TinyMCE配置为显示命名实体。TinyMCE正在应用编码,但可以通过tiny_mce_before_init
钩Thanks to this answer 给小费。
将可能需要的其他实体添加到$settings[\'entities\']
一串有关格式的文档是here:
此选项包含一个逗号分隔的实体名称列表,该列表用于代替字符。奇数项是字符代码,偶数项是字符代码的名称。
// Custom configuration for TinyMCE
function wpse241282_tiny_mce_before_init( $settings, $editor_id ) {
// Used named encodings (the default setting in WordPress is raw).
// https://www.tinymce.com/docs/configure/content-filtering/#encodingtypes
$settings[\'entity_encoding\'] = \'named\';
// Default entities for TinyMCE: 38,amp,60,lt,62,gt1
// Additional entities: copy, reg, trade, service mark, euro, right angle quote, left angle quote
// The odd entires are the entity *number*, the even entries are the entity *name*. If the entity has no name,
// use the number, prefixed with a hash (for example, the service mark is "8480,#8480").
$entities = \'169,copy,174,reg,8482,trade,8480,#8480,8364,euro,187,raquo,171,laquo\';
if ( isset( $settings[\'entities\'] ) && ! empty( $settings[\'entities\'] ) ) {
$settings[\'entities\'] .= \',\' . $entities;
} else {
$settings[\'entities\'] = $entities;
}
return $settings;
}
add_filter( \'tiny_mce_before_init\', \'wpse241282_tiny_mce_before_init\', 10, 2 );
add_filter( \'quicktags_settings\', \'wpse241282_tiny_mce_before_init\', 10, 2 );
已启用可视化编辑器
用户拥有可视化编辑器
enabled 在“用户配置文件”下。