Advertisement
chadgames

Using wordpress editor in custom metaboxes

Sep 25th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. Current Example:
  2. ===============
  3.  
  4. echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'">'.$meta.'</textarea>';
  5.  
  6.  
  7. Replaced with the wp_editor:
  8. ===========================
  9.  
  10. $wp_editor_settings = array(
  11.     'wpautop' => false,
  12.     'media_buttons' => false,
  13.     'textarea_name' => $field['id'],
  14.     'textarea_rows' => 10,
  15.     'teeny' => true,
  16.     'tinymce' => array(
  17.         'content_css' => plugins_url('/css/editor-styles.css', __FILE__),
  18.         'theme_advanced_buttons1' => 'bold,italic,underline,|,' .
  19.         'bullist,numlist,blockquote,|,justifyleft,justifycenter' .
  20.         ',justifyright,justifyfull,|,link,unlink' )
  21.     );
  22. wp_editor( $meta, $field['id'], $wp_editor_settings );
  23.  
  24.  
  25. /* $settings:
  26.         'wpautop' => true, // use wpautop?
  27.         'media_buttons' => true, // show insert/upload button(s)
  28.         'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
  29.         'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
  30.         'tabindex' => '',
  31.         'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped".
  32.         'editor_class' => '', // add extra class(es) to the editor textarea
  33.         'teeny' => false, // output the minimal editor config used in Press This
  34.         'dfw' => false, // replace the default fullscreen with DFW (needs specific css)
  35.         'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
  36.         'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
  37. */
  38.  
  39. Links:
  40. =====
  41.  
  42. http://codex.wordpress.org/Function_Reference/wp_editor - Function Reference/wp editor
  43. http://codex.wordpress.org/TinyMCE - TinyMCE Codex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement