Created
May 17, 2012 04:44
-
-
Save imjjss/2716433 to your computer and use it in GitHub Desktop.
Front-end editor in WordPress 3.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
//syntax: | |
wp_editor( $content, $editor_id, $settings = array() ); | |
// default settings | |
$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' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped". | |
'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 (needs specific css) | |
'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() | |
); | |
//simple example | |
echo '<form action="" method="post" target="_blank">'; | |
wp_editor('<p>Some content</p>', 'textarea01' ); | |
echo '<input type="submit" value="Submit" /></form>' | |
// more control example | |
$settings = array( | |
'wpautop' => true, | |
'media_buttons' => false, | |
'tinymce' => array( | |
'theme_advanced_buttons1' => 'bold,italic,underline,blockquote,|,undo,redo,|,fullscreen', | |
'theme_advanced_buttons2' => '', | |
'theme_advanced_buttons3' => '', | |
'theme_advanced_buttons4' => '' | |
), | |
'quicktags' => array( | |
'buttons' => 'b,i,ul,ol,li,link,close' | |
) | |
); | |
echo '<form action="" method="post" target="_blank">'; | |
wp_editor('<p>Some more content</p>', 'textarea02', $settings ); | |
echo '<input type="submit" value="Submit" /></form>'; | |
//Don’t want the quick tags?: | |
$settings = array( | |
'wpautop' => true, | |
'media_buttons' => false, | |
'tinymce' => array( | |
'theme_advanced_buttons1' => 'bold,italic,underline,blockquote,|,undo,redo,|,fullscreen', | |
'theme_advanced_buttons2' => '', | |
'theme_advanced_buttons3' => '', | |
'theme_advanced_buttons4' => '' | |
), | |
'quicktags' => false | |
); | |
echo '<form action="" method="post" target="_blank">'; | |
wp_editor('<p>Some more content</p>', 'textarea02', $settings ); | |
echo '<input type="submit" value="Submit" /></form>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment