Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Преобразователь
- */
- function smart_code_escape_pre( $data ) {
- preg_match('@(<code.*>)(.*)(<\/code>)@isU', $data[2], $matches );
- if( !empty( $matches ) ) {
- return $data[1] . $matches[1] . str_replace( array( '&', '<', '>' ), array( '&', '<', '>' ), $matches[2] ) . $matches[3] . $data[3];
- }
- else {
- return $data[1] . str_replace( array( '&', '<', '>' ), array( '&', '<', '>' ), $data[2] ) . $data[3];
- }
- }
- add_filter( 'the_content', 'smart_code_escape_content', 9 );
- function smart_code_escape_content( $content ) {
- $content = preg_replace_callback('@(<pre.*>)(.*)(<\/pre>)@isU', 'smart_code_escape_pre', $content );
- return $content;
- }
- //добавляю кнопки в редактор
- if( !function_exists('_add_my_quicktags') ){
- function _add_my_quicktags()
- { ?>
- <script type="text/javascript">
- QTags.addButton( 'lead', 'lead', '<p class="lead">', '</p>' );
- QTags.addButton( 'no-f', 'no-f', 'rel="nofollow"' );
- QTags.addButton( 'p', 'p', '<p>', '</p>' );
- QTags.addButton( 'h2', 'h2', '<h2>', '</h2>' );
- QTags.addButton( 'h3', 'h3', '<h3>', '</h3>' );
- QTags.addButton( 'h4', 'h4', '<h4>', '</h4>' );
- QTags.addButton( 'bq', 'bq', '<div class="bq-paragraph"><h4><i class="fa fa-exclamation-circle" style="color:#0073AA;"></i></h4><p></p></div>' );
- QTags.addButton( 'div', 'div', '<div>', '</div>' );
- QTags.addButton( 'cntr', 'cntr', 'class="text-center"' );
- QTags.addButton( 'prsm', 'prsm', '<pre><code class="language-php language-css language-markup language-js"></code></pre>' );
- QTags.addButton( 'cd', 'cd', '<span class="code">', '</span>' );
- </script>
- <?php }
- add_action('admin_print_footer_scripts', '_add_my_quicktags');
- }
- /**
- * Удаляем лишние кнопки из текстового HTML-редактора WordPress
- */
- add_filter('quicktags_settings', 'sheensay_set_minimum_buttons');
- function sheensay_set_minimum_buttons( $q ) {
- //default: strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen
- $q['buttons'] = 'em,link,code,ul,ol,li,strong';
- return $q;
- }
- //отключение расстановки тегов параграфов
- remove_filter('the_content', 'wpautop');
- remove_filter('the_excerpt', 'wpautop');
Add Comment
Please, Sign In to add comment