diff options
| author | Max | 2018-10-15 23:46:42 +0200 |
|---|---|---|
| committer | Max | 2018-10-15 23:46:42 +0200 |
| commit | 00c9709fd9763542e848f6278db8ba26af5c9886 (patch) | |
| tree | 92cb1c1ee4c467118e1e5a4c7e233d3feac6efa8 /inc/editor.php | |
| download | fuselkoenig_de-00c9709fd9763542e848f6278db8ba26af5c9886.tar.gz | |
Initial commit.
Diffstat (limited to 'inc/editor.php')
| -rw-r--r-- | inc/editor.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/inc/editor.php b/inc/editor.php new file mode 100644 index 0000000..4b71ee9 --- /dev/null +++ b/inc/editor.php @@ -0,0 +1,78 @@ +<?php +/** + * Understrap modify editor + * + * @package understrap + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly. +} + +/** + * Registers an editor stylesheet for the theme. + */ + +add_action( 'admin_init', 'understrap_wpdocs_theme_add_editor_styles' ); + +if ( ! function_exists ( 'understrap_wpdocs_theme_add_editor_styles' ) ) { + function understrap_wpdocs_theme_add_editor_styles() { + add_editor_style( 'css/custom-editor-style.min.css' ); + } +} + +// Add TinyMCE style formats. +add_filter( 'mce_buttons_2', 'understrap_tiny_mce_style_formats' ); + +if ( ! function_exists ( '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' ); + +if ( ! function_exists ( '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' + ) + ); + + if ( isset( $settings['style_formats'] ) ) { + $orig_style_formats = json_decode($settings['style_formats'],true); + $style_formats = array_merge($orig_style_formats,$style_formats); + } + + $settings['style_formats'] = json_encode( $style_formats ); + return $settings; + } +} |
