- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
Function Reference/wp editor
提供: WordPress Codex 日本語版
< Function Reference
2015年5月1日 (金) 14:40時点におけるShizumi (トーク | 投稿記録)による版 (en:Function_Reference/wp_editor 05:31, 16 February 2015 Mfrerebeau 版)
目次
Description
This function renders an editor in a page in the typical fashion used in Posts and Pages.
Usage
<?php wp_editor( $content, $editor_id, $settings = array() ); ?>
Parameters
- $content
- (string) (必須) Initial content for the editor.
- 初期値: なし
- $editor_id
- (string) (必須) HTML id attribute value for the textarea and TinyMCE. (may only contain lowercase letters and underscores...hyphens will cause editor to not display properly)
- 初期値: なし
- $settings
- (array) (optional) An array of arguments.
- 初期値: array()
Arguments
- wpautop
- (boolean) (optional) Whether to use wpautop for adding in paragraphs. Note that the paragraphs are added automatically when wpautop is false.
- 初期値: true
- media_buttons
- (boolean) (optional) Whether to display media insert/upload buttons
- 初期値: true
- textarea_name
- (string) (optional) The name assigned to the generated textarea and passed parameter when the form is submitted. (may include [] to pass data as array)
- 初期値: $editor_id
- textarea_rows
- (integer) (optional) The number of rows to display for the textarea
- 初期値: get_option('default_post_edit_rows', 10)
- tabindex
- (integer) (optional) The tabindex value used for the form field
- 初期値: なし
- editor_css
- (string) (optional) Additional CSS styling applied for both visual and HTML editors buttons, needs to include <style> tags, can use "scoped"
- 初期値: なし
- editor_class
- (string) (optional) Any extra CSS Classes to append to the Editor textarea
- 初期値: Empty string
- teeny
- (boolean) (optional) Whether to output the minimal editor configuration used in PressThis
- 初期値: false
- dfw
- (boolean) (optional) Whether to replace the default fullscreen editor with DFW (needs specific DOM elements and CSS)
- 初期値: false
- tinymce
- (array) (optional) Load TinyMCE, can be used to pass settings directly to TinyMCE using an array
- 初期値: true
- quicktags
- (array) (optional) Load Quicktags, can be used to pass settings directly to Quicktags using an array. Set to false to remove your editor's Visual and Text tabs.
- 初期値: true
- drag_drop_upload
- (boolean) (optional) Enable Drag & Drop Upload Support (since WordPress 3.9)
- 初期値: false
Return Values
This function does not return a value.
Examples
Display an empty editor using the default settings:
<?php $content = ''; $editor_id = 'mycustomeditor'; wp_editor( $content, $editor_id ); ?>
Fill an editor with the content for a particular post:
<?php $post_id = 51; $post = get_post( $post_id, OBJECT, 'edit' ); $content = $post->post_content; $editor_id = 'editpost'; wp_editor( $content, $editor_id ); ?>
We can also pass an array of one or more settings if the defaults don't suit our needs. For example, if we wanted to hide the insert media buttons, we would do this:
<?php $settings = array( 'media_buttons' => false ); wp_editor( $content, $editor_id, $settings ); ?>
Notes
- Note that the ID that is passed to the wp_editor() function can only be composed of lower-case letters. No underscores, no hyphens. Anything else will cause the WYSIWYG editor to malfunction. (As of 3.6.1 you can use underscores in the ID.)
- Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page. Instead use 'edit_page_form' (for pages) or 'edit_form_advanced' (for other post types):
add_action( 'edit_page_form', 'my_second_editor' ); function my_second_editor() { // get and set $content somehow... wp_editor( $content, 'mysecondeditor' ); }
Change Log
- Since 3.3
Source Code
wp_editor()
is located in wp-includes/general-template.php
Related
エディター関数: wp_editor(), the_editor() / en, wp_default_editor() / en, user_can_richedit() / en