2017-01-17 23:04:04 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2019-07-18 16:21:25 +00:00
|
|
|
* UnderStrap modify editor
|
2017-01-17 23:04:04 +00:00
|
|
|
*
|
|
|
|
* @package understrap
|
|
|
|
*/
|
|
|
|
|
2019-06-20 08:57:12 +00:00
|
|
|
// Exit if accessed directly.
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
2018-09-10 21:59:04 +00:00
|
|
|
|
2018-03-29 17:39:09 +00:00
|
|
|
add_action( 'admin_init', 'understrap_wpdocs_theme_add_editor_styles' );
|
|
|
|
|
2018-11-18 23:41:38 +00:00
|
|
|
if ( ! function_exists( 'understrap_wpdocs_theme_add_editor_styles' ) ) {
|
2019-07-23 08:31:23 +00:00
|
|
|
/**
|
|
|
|
* Registers an editor stylesheet for the theme.
|
|
|
|
*/
|
2018-11-18 23:41:38 +00:00
|
|
|
function understrap_wpdocs_theme_add_editor_styles() {
|
|
|
|
add_editor_style( 'css/custom-editor-style.min.css' );
|
|
|
|
}
|
2017-11-29 10:09:11 +00:00
|
|
|
}
|
|
|
|
|
2017-01-17 23:04:04 +00:00
|
|
|
add_filter( 'mce_buttons_2', 'understrap_tiny_mce_style_formats' );
|
|
|
|
|
2018-11-18 23:41:38 +00:00
|
|
|
if ( ! function_exists( 'understrap_tiny_mce_style_formats' ) ) {
|
2019-07-23 08:31:23 +00:00
|
|
|
/**
|
|
|
|
* Reveals TinyMCE's hidden Style dropdown.
|
2020-04-19 10:08:39 +00:00
|
|
|
*
|
2019-11-03 09:45:09 +00:00
|
|
|
* @param array $buttons Array of Tiny MCE's button ids.
|
2019-07-23 08:31:23 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function understrap_tiny_mce_style_formats( $buttons ) {
|
|
|
|
array_unshift( $buttons, 'styleselect' );
|
|
|
|
return $buttons;
|
2018-11-18 23:41:38 +00:00
|
|
|
}
|
2017-01-17 23:04:04 +00:00
|
|
|
}
|
|
|
|
|
2018-03-29 17:39:09 +00:00
|
|
|
add_filter( 'tiny_mce_before_init', 'understrap_tiny_mce_before_init' );
|
|
|
|
|
2018-11-18 23:41:38 +00:00
|
|
|
if ( ! function_exists( 'understrap_tiny_mce_before_init' ) ) {
|
2019-07-23 08:31:23 +00:00
|
|
|
/**
|
|
|
|
* Adds style options to TinyMCE's Style dropdown.
|
|
|
|
*
|
|
|
|
* @param array $settings TinyMCE settings array.
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-11-18 23:41:38 +00:00
|
|
|
function understrap_tiny_mce_before_init( $settings ) {
|
2017-01-17 23:04:04 +00:00
|
|
|
|
2018-11-18 23:41:38 +00:00
|
|
|
$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',
|
|
|
|
),
|
|
|
|
);
|
2017-02-02 13:05:52 +00:00
|
|
|
|
2018-11-18 23:41:38 +00:00
|
|
|
if ( isset( $settings['style_formats'] ) ) {
|
|
|
|
$orig_style_formats = json_decode( $settings['style_formats'], true );
|
|
|
|
$style_formats = array_merge( $orig_style_formats, $style_formats );
|
|
|
|
}
|
|
|
|
|
2019-07-23 08:31:23 +00:00
|
|
|
$settings['style_formats'] = wp_json_encode( $style_formats );
|
2018-11-18 23:41:38 +00:00
|
|
|
return $settings;
|
|
|
|
}
|
2017-01-17 23:04:04 +00:00
|
|
|
}
|