从WP编辑器TinyMCE中删除特定按钮 [英] Remove Specific Buttons from WP Editor TinyMCE
问题描述
我试图弄清楚如何从TinyMCE编辑器中删除特定的按钮.我已经研究了法典中的参数,但是对于TinyMCE来说,它只是说数组,并且不确定是否可以在参数中包含显示或隐藏哪些按钮的参数?
I am trying to figure out how to remove specific buttons from the TinyMCE editor. I have researched the arguments in the codex but for TinyMCE is just says array and not sure if I can include some paramters in my arguments of which buttons to show/hide?
我正在以重力形式使用编辑器,到目前为止,我的代码如下
I am using the editor in a gravity form and my code is as follows so far
add_action( 'gform_field_input', 'gforms_wp_editor', 10, 5 );
function gforms_wp_editor( $input, $field, $value, $lead_id, $form_id ) {
if( $field["cssClass"] == 'richtext' ) {
ob_start();
wp_editor( $value, "input_{$form_id}_{$field['id']}",
array(
'media_buttons' => false,
'quicktags' => false,
'textarea_name' => "input_{$field['id']}"
) );
$input = ob_get_clean();
}
return $input;
}
我已将quicktags
设置为false,从而删除了HTML选项卡,因此希望我可以做一些类似于从编辑器中删除按钮的操作.
I have removed the HTML tab using the quicktags
to false, so hoping I can do something similar to strip out buttons from the editor.
按钮如下所示
注意:现在,我需要'teeny'编辑器,以防万一有人建议
Note: 'teeny' editor is now what I need, just in case someone suggests
谢谢
推荐答案
tinymce
参数允许您将配置选项直接传递给TinyMCE-请参阅 theme_advanced_disable 和按钮参考.
The tinymce
parameter allows you to pass configuration options directly to TinyMCE - see the docs for theme_advanced_buttons and theme_advanced_disable, and the button reference.
仅显示粗体,斜体和下划线按钮:
To show only the bold, italic and underline buttons:
wp_editor($value, "input...", array(
'tinymce' => array(
'theme_advanced_buttons1' => 'bold,italic,underline',
'theme_advanced_buttons2' => '',
'theme_advanced_buttons3' => ''
)
));
或者,要显示除 之外的所有内容,粗体,斜体和下划线按钮:
Or, to show everything except the bold, italic and underline buttons:
wp_editor($value, "input...", array(
'tinymce' => array(
'theme_advanced_disable' => 'bold,italic,underline'
)
));
根据要求,您的代码已修改:
As requested, your code modified:
add_action( 'gform_field_input', 'gforms_wp_editor', 10, 5 );
function gforms_wp_editor( $input, $field, $value, $lead_id, $form_id ) {
if( $field["cssClass"] == 'richtext' ) {
ob_start();
wp_editor( $value, "input_{$form_id}_{$field['id']}",
array(
'media_buttons' => false,
'quicktags' => false,
'textarea_name' => "input_{$field['id']}",
'tinymce' => array(
'theme_advanced_disable' => 'bold,italic,underline'
)
)
);
$input = ob_get_clean();
}
return $input;
}
这篇关于从WP编辑器TinyMCE中删除特定按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!