wp_enqueue_editor()
云策文档标注
概述
wp_enqueue_editor() 函数用于输出编辑器所需的脚本、样式表和默认设置,支持在页面加载后按需初始化编辑器。
关键要点
- 函数输出编辑器的脚本、样式和默认设置,便于在需要时初始化编辑器。
- 内部调用 _WP_Editors::enqueue_default_editor() 来加载所有编辑器脚本。
- 编辑器初始化选项可参考 wp.editor.initialize() 在 wp-admin/js/editor.js 中的实现。
- 自 WordPress 4.8.0 版本引入,常用于如 WP_Widget_Text 等组件的后台脚本加载。
原文内容
Outputs the editor scripts, stylesheets, and default settings.
Description
The editor can be initialized when needed after page load.
See wp.editor.initialize() in wp-admin/js/editor.js for initialization options.
Source
function wp_enqueue_editor() {
if ( ! class_exists( '_WP_Editors', false ) ) {
require ABSPATH . WPINC . '/class-wp-editor.php';
}
_WP_Editors::enqueue_default_editor();
}
Changelog
| Version | Description |
|---|---|
| 4.8.0 | Introduced. |