wp_editor

函式
wp_editor ( $content, $editor_id, $settings = array() )
引數
  • (string) $content Initial content for the editor.
    Required:
  • (string) $editor_id HTML ID attribute value for the textarea and TinyMCE. Should not contain square brackets.
    Required:
  • (array) $settings See _WP_Editors::parse_settings() for description.
    Required:
    Default: array()
相關
  • _WP_Editors::editor()
  • _WP_Editors::parse_settings()
定義位置
相關方法
wp_image_editorwp_creditsthe_editorwp_redirectwp_default_editor
引入
3.3.0
棄用
-

wp_editor: 這個函式用來在WordPress網站上顯示一個富文字編輯器: 這個函式可以用來讓使用者建立和編輯具有富文字格式和媒體嵌入功能的內容。

渲染一個編輯器。

使用這個函式是輸出TinyMCE和Quicktags所有需要的元件的正確方式。_WP_Editors不應該被直接使用。見https://core.trac.wordpress.org/ticket/17144。

注意:一旦初始化,TinyMCE編輯器就不能在DOM中安全移動。由於這個原因,在meta box裡面執行wp_editor()不是一個好主意,除非只使用Quicktags。在文章編輯介面,有幾個動作可以用來包括包含TinyMCE的額外編輯器:’edit_page_form’, ‘edit_form_advanced’ 和 ‘dbx_post_sidebar’。

更多資訊見https://core.trac.wordpress.org/ticket/19173。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_editor( $content, $editor_id, $settings = array() ) {
if ( ! class_exists( '_WP_Editors', false ) ) {
require ABSPATH . WPINC . '/class-wp-editor.php';
}
_WP_Editors::editor( $content, $editor_id, $settings );
}
function wp_editor( $content, $editor_id, $settings = array() ) { if ( ! class_exists( '_WP_Editors', false ) ) { require ABSPATH . WPINC . '/class-wp-editor.php'; } _WP_Editors::editor( $content, $editor_id, $settings ); }
function wp_editor( $content, $editor_id, $settings = array() ) {
	if ( ! class_exists( '_WP_Editors', false ) ) {
		require ABSPATH . WPINC . '/class-wp-editor.php';
	}
	_WP_Editors::editor( $content, $editor_id, $settings );
}

常見問題

FAQs
檢視更多 >