Guest User

Untitled

a guest
May 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. /* adding green text formatting to mce editor */
  2.  
  3. function wpb_mce_buttons_2($buttons) {
  4. array_unshift($buttons, 'styleselect');
  5. return $buttons;
  6. }
  7. add_filter('mce_buttons_2', 'wpb_mce_buttons_2');
  8.  
  9.  
  10. /*
  11. * Callback function to filter the MCE settings
  12. */
  13.  
  14. function my_mce_before_init_insert_formats( $init_array ) {
  15.  
  16. // Define the style_formats array
  17.  
  18. $style_formats = array(
  19. /*
  20. * Each array child is a format with it's own settings
  21. * Notice that each array has title, block, classes, and wrapper arguments
  22. * Title is the label which will be visible in Formats menu
  23. * Block defines whether it is a span, div, selector, or inline style
  24. * Classes allows you to define CSS classes
  25. * Wrapper whether or not to add a new block-level element around any selected elements
  26. */
  27. array (
  28. 'title' => 'Light Green Text',
  29. 'inline' => 'span',
  30. 'classes' => 'lightgreen',
  31. 'wrapper' => true,
  32. ),
  33. array (
  34. 'title' => 'Dark Green Text',
  35. 'inline' => 'span',
  36. 'classes' => 'darkgreen',
  37. 'wrapper' => true,
  38. )
  39. );
  40. // Insert the array, JSON ENCODED, into 'style_formats'
  41. $init_array['style_formats'] = json_encode( $style_formats );
  42.  
  43. return $init_array;
  44.  
  45. }
  46. // Attach callback to 'tiny_mce_before_init'
  47. add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
Add Comment
Please, Sign In to add comment