Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <?php
  2. // Add custom button for styles
  3. function customStylesButton($buttons) {
  4. array_unshift($buttons, 'styleselect');
  5. return $buttons;
  6. }
  7. add_filter('mce_buttons_2', 'customStylesButton');
  8.  
  9. //Add custom styles to the WordPress editor
  10. function my_custom_styles( $init_array ) {
  11.  
  12. $style_formats = array(
  13. // These are the custom styles
  14. array(
  15. 'title' => 'Hero - H1',
  16. 'block' => 'h1',
  17. 'styles' => array(
  18. 'fontWeight' => 'bold',
  19. 'marginBottom' => '0',
  20. )
  21. ),
  22. array(
  23. 'title' => 'Hero - H3',
  24. 'block' => 'h3',
  25. 'styles' => array(
  26. 'marginTop' => '0',
  27. 'fontWeight' => 'lighter',
  28. )
  29. ),
  30. array(
  31. 'title' => 'Form - H1',
  32. 'block' => 'h1',
  33. 'styles' => array(
  34. 'fontSize' => '40px',
  35. 'margin' => '0',
  36. 'color' => '#2a628e',
  37. )
  38. ),
  39. array(
  40. 'title' => 'Form - H3',
  41. 'block' => 'h3',
  42. 'styles' => array(
  43. 'fontSize' => '18px',
  44. 'margin' => '0',
  45. 'color' => '#7a7774',
  46. 'fontWeight' => 'lighter',
  47. )
  48. ),
  49. array(
  50. 'title' => 'Form - Paragraph',
  51. 'block' => 'p',
  52. 'styles' => array(
  53. 'fontWeight' => 'lighter',
  54. )
  55. ),
  56. array(
  57. 'title' => 'Boxes Area',
  58. 'block' => 'h4',
  59. 'styles' => array(
  60. 'fontSize' => '21px',
  61. 'fontWeight' => 'lighter',
  62. 'color' => '#2a628e',
  63. )
  64. ),
  65. array(
  66. 'title' => 'Second Image Area',
  67. 'block' => 'span',
  68. 'classes' => 'thirdText',
  69. ),
  70. array(
  71. 'title' => 'Orange Button',
  72. 'block' => 'span',
  73. 'classes' => 'orangeButton',
  74. 'styles' => array(
  75. 'color' => '#fff',
  76. 'background' => '#e59c0f',
  77. 'textDecoration' => 'none',
  78. )
  79. ),
  80. );
  81. // Insert the array, JSON ENCODED, into 'style_formats'
  82. $init_array['style_formats'] = json_encode( $style_formats );
  83. return $init_array;
  84. }
  85. add_filter( 'tiny_mce_before_init', 'my_custom_styles' );
  86.  
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement