Php Wordpress可视化编辑器中的自定义样式赢得';不将类应用于链接元素
因此,我为可视化编辑器设置了自定义样式,如下所示:Php Wordpress可视化编辑器中的自定义样式赢得';不将类应用于链接元素,php,wordpress,styles,tinymce,wordpress-theming,Php,Wordpress,Styles,Tinymce,Wordpress Theming,因此,我为可视化编辑器设置了自定义样式,如下所示: // Registers an editor stylesheet for the theme. function wpdocs_theme_add_editor_styles() { add_editor_style( 'editor-styles.css' ); } add_action( 'admin_init', 'wpdocs_theme_add_editor_styles' ); // Callback function
// Registers an editor stylesheet for the theme.
function wpdocs_theme_add_editor_styles() {
add_editor_style( 'editor-styles.css' );
}
add_action( 'admin_init', 'wpdocs_theme_add_editor_styles' );
// Callback function to insert 'styleselect' into the $buttons array
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
// Register our callback to the appropriate filter
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
// Callback function to filter the MCE settings
function my_mce_before_init_insert_formats( $init_array ) {
// Define the style_formats array
$style_formats = array(
// Each array child is a format with it's own settings
array(
'title' => 'Button',
'classes' => 'button',
'wrapper' => true,
),
);
// Insert the array, JSON ENCODED, into 'style_formats'
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
// Attach callback to 'tiny_mce_before_init'
add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
问题1
为什么这种样式不将“button”类添加到链接“a”元素中?它可以与“inline=>'span'”参数配合使用,但将类直接应用于link元素更为简洁。我不想把我的代码和span类混在一起
问题2
当我选择“mce_buttons_1”而不是“mce_buttons_2”时,下拉列表不会显示在第一行。因为本机下拉列表,我不能选择第一行吗
问题#3
实际上,我希望将自定义样式添加到本机下拉列表中。可能吗?我找不到任何关于如何做到这一点的资源
谢谢!
/Jeppe我找到了一种方法,您应该首先将自定义样式应用于简单文本,然后添加带有链接btn的链接,编辑器将保留您的类。我找到了一种方法,您应该首先将自定义样式应用于简单文本,然后添加带有链接btn的链接,编辑器将保留您的类