1

我正在尝试在一个简单的 PHP 页面(不是插件,不在管理部分)中使用 wp_editor:

  define('WP_USE_THEMES', false);
  require('wp-blog-header.php');
  $editor_id = 'mycustomeditor';
  wp_editor( "My content", $editor_id );

我得到了字段和 Visual/HTML 按钮,但仅此而已,我没有任何其他按钮或工具栏。

在调用 wp_editor 之前我需要加载其他 WP 库吗?

谢谢 !

4

1 回答 1

1

您也可以将一些设置变量传递给编辑器。如果不传递它,它将采用默认值。

我注意到的另一件事是,如果我exit();在加载页脚之前在页面中的任何位置执行此操作,它不会在工具栏中显示任何按钮,因为它会从页脚加载一些脚本。因此,如果您有exit()die()之前加载页脚,它将不会加载工具栏。

在这里,我已将它传递给我的编辑器,并且工作正常。

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 );
于 2017-10-31T13:20:09.553 回答