下面的代码对我很有用,它添加了一个选项页面,并向该页面添加了一个所见即所得框,其中只有3个快速标记:link、img和close,而没有其他标记。
注意,我打开了tinyMCE,并将设置数组(其中包含另一个用于quicktag设置的数组)传递给wp\\U编辑器。
通过传入textarea字段的唯一id,它只会影响插件选项页上的正确框
// add admin page
function my_admin_add_page() {
global $my_admin_page;
$my_admin_page = add_options_page(__(\'My Admin Page\', \'map\'), __(\'My Admin Page\', \'map\'), \'manage_options\', \'map\', \'my_admin_page\');
}
add_action(\'admin_menu\', \'my_admin_add_page\');
// render admin page
function my_admin_page() {
// global editor id (not necesary, but we may need it elsewhere)
global $myPluginEditorID;
$myPluginEditorID = "myPluginEditorUniqueID";
// settings to pass to wp_editor, disables the upload button, and sets minimal quicktags and turns off tinymce
$settings = array(
\'media_buttons\' => false,
\'quicktags\' => array("buttons"=>"link,img,close"),
\'textarea_name\' => "input_{$myPluginEditorID}",
\'tinymce\' => false,
);
// output the wysiwyg editor
wp_editor( "Content Here", $myPluginEditorID,$settings);
}