[英]wp_editor shows no button
I'm trying to use wp_editor in a simple PHP page (not a plugin, not in the admin section) :我试图在一个简单的 PHP 页面(不是插件,不是在管理部分)中使用 wp_editor:
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
$editor_id = 'mycustomeditor';
wp_editor( "My content", $editor_id );
I got the field and the Visual/HTML buttons but that's all, I don't have any other buttons or toolbar.我有字段和 Visual/HTML 按钮,但仅此而已,我没有任何其他按钮或工具栏。
Do I need to load other WP library before calling wp_editor ?在调用 wp_editor 之前是否需要加载其他 WP 库?
Thank you !谢谢 !
You can pass some settings variable to editor as well.您也可以将一些设置变量传递给编辑器。 Without passing it, it will take default values.
如果不传递它,它将采用默认值。
Another thing I have noticed that, If I do exit();
我注意到的另一件事是,如果我
exit();
anywhere in my page before loading footer, it will not display any buttons in toolbar as it loads some of the scripts from footer.在加载页脚之前,我页面中的任何位置都不会在工具栏中显示任何按钮,因为它会从页脚加载一些脚本。 So If you have
exit()
or die()
before loading footer it will not load the toolbar.所以如果你在加载页脚之前有
exit()
或die()
,它不会加载工具栏。
Here I have passed it to my editor and its working fine.在这里,我已将其传递给我的编辑器,并且工作正常。
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
$editor_id = 'mycustomeditor';
$settings = array(
'wpautop' => true, // use wpautop?
'media_buttons' => true, // show insert/upload button(s)
'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
'tabindex' => '',
'editor_css' => '', // extra styles for both visual and HTML editors buttons,
'editor_class' => '', // add extra class(es) to the editor textarea
'teeny' => false, // output the minimal editor config used in Press This
'dfw' => false, // replace the default fullscreen with DFW (supported on the front-end in WordPress 3.4)
'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
);
wp_editor( "My content", $editor_id, $settings );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.