Guest User

Untitled

a guest
Jan 17th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. /**
  2. * Преобразователь
  3. */
  4. function smart_code_escape_pre( $data ) {
  5. preg_match('@(<code.*>)(.*)(<\/code>)@isU', $data[2], $matches );
  6. if( !empty( $matches ) ) {
  7. return $data[1] . $matches[1] . str_replace( array( '&', '<', '>' ), array( '&', '<', '>' ), $matches[2] ) . $matches[3] . $data[3];
  8. }
  9. else {
  10. return $data[1] . str_replace( array( '&', '<', '>' ), array( '&', '<', '>' ), $data[2] ) . $data[3];
  11. }
  12. }
  13. add_filter( 'the_content', 'smart_code_escape_content', 9 );
  14. function smart_code_escape_content( $content ) {
  15. $content = preg_replace_callback('@(<pre.*>)(.*)(<\/pre>)@isU', 'smart_code_escape_pre', $content );
  16. return $content;
  17. }
  18.  
  19. //добавляю кнопки в редактор
  20. if( !function_exists('_add_my_quicktags') ){
  21. function _add_my_quicktags()
  22. { ?>
  23. <script type="text/javascript">
  24. QTags.addButton( 'lead', 'lead', '<p class="lead">', '</p>' );
  25. QTags.addButton( 'no-f', 'no-f', 'rel="nofollow"' );
  26. QTags.addButton( 'p', 'p', '<p>', '</p>' );
  27. QTags.addButton( 'h2', 'h2', '<h2>', '</h2>' );
  28. QTags.addButton( 'h3', 'h3', '<h3>', '</h3>' );
  29. QTags.addButton( 'h4', 'h4', '<h4>', '</h4>' );
  30. QTags.addButton( 'bq', 'bq', '<div class="bq-paragraph"><h4><i class="fa fa-exclamation-circle" style="color:#0073AA;"></i></h4><p></p></div>' );
  31. QTags.addButton( 'div', 'div', '<div>', '</div>' );
  32. QTags.addButton( 'cntr', 'cntr', 'class="text-center"' );
  33. QTags.addButton( 'prsm', 'prsm', '<pre><code class="language-php language-css language-markup language-js"></code></pre>' );
  34. QTags.addButton( 'cd', 'cd', '<span class="code">', '</span>' );
  35.  
  36. </script>
  37. <?php }
  38. add_action('admin_print_footer_scripts', '_add_my_quicktags');
  39. }
  40.  
  41. /**
  42. * Удаляем лишние кнопки из текстового HTML-редактора WordPress
  43. */
  44. add_filter('quicktags_settings', 'sheensay_set_minimum_buttons');
  45. function sheensay_set_minimum_buttons( $q ) {
  46. //default: strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen
  47. $q['buttons'] = 'em,link,code,ul,ol,li,strong';
  48. return $q;
  49. }
  50.  
  51. //отключение расстановки тегов параграфов
  52. remove_filter('the_content', 'wpautop');
  53. remove_filter('the_excerpt', 'wpautop');
Add Comment
Please, Sign In to add comment