Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2.  
  3. $row_items = 'styleselect,|,removeformat,|,bullist,numlist,|,link,unlink,|,undo,redo';
  4.  
  5. function tiny_mce_elements($initArray) {
  6.  
  7. global $row_items;
  8.  
  9. $initArray['toolbar1'] = $row_items;
  10. $initArray['toolbar2'] = '';
  11. $initArray['relative_urls'] = true;
  12.  
  13. $style_formats = array(
  14.  
  15. // Top level item
  16. array(
  17. 'title' => 'Subhead',
  18. 'block' => 'p',
  19. 'classes' => 'subhead',
  20. ),
  21.  
  22. array(
  23. 'title' => 'Bold',
  24. 'block' => 'p',
  25. 'classes' => 'bold',
  26. ),
  27.  
  28.  
  29. );
  30.  
  31. $initArray['style_formats'] = json_encode( $style_formats );
  32. // $initArray['theme_advanced_blockformats'] = 'p,h1,h2,h3';
  33. // $initArray['theme_advanced_styles'] = 'Heading=intro, Subhead=h2, Feature Link=feature-link';
  34. return $initArray;
  35. }
  36. add_filter('tiny_mce_before_init', 'tiny_mce_elements');
  37.  
  38.  
  39. function my_toolbars( $toolbars ) {
  40.  
  41. global $row_items;
  42.  
  43. // unset existing formats
  44. unset($toolbars['Basic']);
  45. unset($toolbars['Full']);
  46.  
  47. $row_1 = str_replace('|', '', $row_items);
  48. $row_1 = explode(',', $row_1);
  49. $toolbars['Full'][1] = $row_1;
  50.  
  51. // return $toolbars - IMPORTANT!
  52. return $toolbars;
  53.  
  54. }
  55. add_filter('acf/fields/wysiwyg/toolbars', 'my_toolbars');
  56.  
  57.  
  58. function tiny_css($wp) {
  59. $wp .= ',' . TDIR . '/assets/css/styles.min.css';
  60. return $wp;
  61. }
  62.  
  63. add_filter( 'mce_css', 'tiny_css' );
  64.  
  65.  
  66.  
  67. // format the content
  68. function format_output($content) {
  69. $content = preg_replace('/<p>\\s*?(<iframe.*?><\/iframe>)?\\s*<\\/p>/s', '<div class="iframe">$1</div>', $content);
  70. return $content;
  71. }
  72. add_filter( 'the_content', 'format_output', 10 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement