Indonesian (Bahasa Indonesia) translation by Muhamad Zulfiqor (you can also view the original English article)
Dalam tip ini kita akan menemukan apa yang wp_editor
baik untuk!
Apa itu wp_editor
?

Itu adalah fungsi WordPress yang menciptakan sebuah visual (WYSIWYG) editor seperti yang terdapat di WordPress admin ketika membuat posting atau halaman. Fungsi kecil ini berguna telah tersedia sejak WordPress v3.3.
Ada halaman Codex rinci tentang wp_editor
, jika Anda memerlukan informasi lebih lanjut. Menggunakan WordPress versi khusus dari TinyMCE editor, yang dapat ditemukan di sini. Untuk memeriksa file silakan lihat wp-termasuk/js/tinymce
dalam direktori instalasi WordPress Anda.



Editor biasa di admin
Mengapa kita perlu ini?
Karena kita dapat menggunakan fitur ini dalam tema dan plugin juga! Kandungan yang kaya akan datang berguna pada beberapa kesempatan, bukan hanya dalam posting. Kami dapat menggunakan beberapa editor pada subhalaman satu, hanya menggunakan konten dan variabel ID yang tepat.
Contoh

Bagian ini mengasumsikan Anda tahu setidaknya beberapa dasar pemrograman PHP. Variabel $content dan $editor_id wajib, mereka harus menetapkan setiap saat. $settings variabel adalah sebuah array yang fitur satu editor dapat beralih on / off.
Harap dicatat bahwa sebagian besar penjelasan ada di komentar, baca juga!
Kode berikut (1, 2, 3 dan 4) menunjukkan bagaimana untuk menggunakan fungsi.
/** * Mandatory variables */ wp_editor( $content, $editor_id ); /** * Basic syntax */ wp_editor( $content, $editor_id, $settings = array() ); /** * 1. * The first variable will set the content to show in the box, * the second one holds the HTML id attribute of the editor * (must be lowercase letters and no underscores or hyphens). */ wp_editor( 'Hello World! This is our first test! Enjoy!', 'ourmaineditor' ); /** * 2. * This code renders an editor box and a submit button. * The box will have 15 rows, the quicktags won't load * and the PressThis configuration is used. */ $args = array( 'textarea_rows' => 15, 'teeny' => true, 'quicktags' => false ); wp_editor( 'This is the default text!', 'editor', $args ); submit_button( 'Save content' ); /** * 3. * We can recreate the post editor with the get_post function, * which retrieves an existing post (in this case number 117) * from the database. */ $post = get_post( 117, 'OBJECT' ); wp_editor( $post, 'editor' ); /** * 4. * Custom buttons for the editor. * This is a list separated with a comma after each feature * eg. link, unlink, bold, ... */ $settings = array( 'textarea_name' => 'content', 'media_buttons' => false, 'tinymce' => array( 'theme_advanced_buttons1' => 'formatselect,|,bold,italic,underline,|,' . 'bullist,blockquote,|,justifyleft,justifycenter' . ',justifyright,justifyfull,|,link,unlink,|' . ',spellchecker,wp_fullscreen,wp_adv' ) ); wp_editor( '', 'content', $settings );
Menyesuaikan Editor

Kita dapat menyesuaikan fitur editor dengan bantuan ini deskripsi dalam Codex. Untuk menggali lebih dalam Anda juga dapat memeriksa kelas-wp-editor.php di bawah wp-termasuk dalam instalasi WordPress Anda.