Merge pull request #218 from ZXCVLuke/master - Thx @ZXCVLuke

Add BS typography styles to editor
This commit is contained in:
Holger 2017-01-18 07:47:20 +01:00 committed by GitHub
commit 430706f4b0
2 changed files with 69 additions and 1 deletions

View File

@ -65,4 +65,9 @@ require get_template_directory() . '/inc/bootstrap-wp-navwalker.php';
/**
* Load WooCommerce functions.
*/
require get_template_directory() . '/inc/woocommerce.php';
require get_template_directory() . '/inc/woocommerce.php';
/**
* Load Editor functions.
*/
require get_template_directory() . '/inc/editor.php';

63
inc/editor.php Normal file
View File

@ -0,0 +1,63 @@
<?php
/**
* Understrap modify editor
*
* @package understrap
*/
// Remove h1 from block formats dropdown
add_filter('tiny_mce_before_init', 'understrap_tiny_mce_remove_h1_format' );
function understrap_tiny_mce_remove_h1_format($init) {
$init['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Pre=pre';
return $init;
}
// Add TinyMCE style formats
add_filter( 'mce_buttons_2', 'understrap_tiny_mce_style_formats' );
function understrap_tiny_mce_style_formats( $styles ) {
array_unshift( $styles, 'styleselect' );
return $styles;
}
add_filter( 'tiny_mce_before_init', 'understrap_tiny_mce_before_init' );
function understrap_tiny_mce_before_init( $settings ) {
$style_formats = array(
array(
'title' => 'Lead Paragraph',
'selector' => 'p',
'classes' => 'lead',
'wrapper' => true
),
array(
'title' => 'Small',
'inline' => 'small'
),
array(
'title' => 'Blockquote',
'block' => 'blockquote',
'classes' => 'blockquote',
'wrapper' => true
),
array(
'title' => 'Blockquote Footer',
'block' => 'footer',
'classes' => 'blockquote-footer',
'wrapper' => true
),
array(
'title' => 'Cite',
'inline' => 'cite'
)
);
$settings['style_formats'] = json_encode( $style_formats );
return $settings;
}