Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
Created January 13, 2016 19:44
Show Gist options
  • Save bryanwillis/0139b3535dca04ef980e to your computer and use it in GitHub Desktop.
Save bryanwillis/0139b3535dca04ef980e to your computer and use it in GitHub Desktop.
<?php
/* STYLES IN EDITOR - Multiple stylesheets
================================================== */
function child_load_editor_mce_css( $mce_css ) {
if ( ! empty( $mce_css ) ) {
$mce_css .= ',';
}
$mce_css .= BW_CHILD_URL_DIST . '/bootstrap/css/bootstrap.css';
$mce_css .= ',';
$mce_css .= BW_CHILD_URL_DIST . '/assets/css/editor.css';
return $mce_css;
}
add_filter( 'mce_css', 'child_load_editor_mce_css' );
/* STYLES IN EDITOR - Single Stylesheet
================================================== */
function twbsg_mce_css( $mce_css ) {
if ( ! empty( $mce_css ) ) {
$mce_css .= ',';
}
$mce_css .= plugins_url('bootstrap/css/bootstrap.min.css', __DIR__); // path to file
return $mce_css;
}
add_filter( 'mce_css', 'twbsg_mce_css' );
<?php
function mce_html5_formatting( $init ) {
$init['block_formats'] = 'Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;';
$style_formats = array(
array(
'title' => 'Headers',
'items' => array(
array(
'title' => 'Header 1',
'block' => 'h1'
),
array(
'title' => 'Header 2',
'block' => 'h2'
),
array(
'title' => 'Header 3',
'block' => 'h3'
),
array(
'title' => 'Header 4',
'block' => 'h4'
),
array(
'title' => 'Header 5',
'block' => 'h5'
),
array(
'title' => 'Header 6',
'block' => 'h6'
)
)
),
array(
'title' => 'Blocks',
'items' => array(
array(
'title' => 'Paragraph <p>',
'block' => 'p'
),
array(
'title' => 'Arbitrary Division <div>',
'block' => 'div'
),
array(
'title' => 'Preformatted Text <pre>',
'block' => 'pre'
)
)
),
array(
'title' => 'Containers',
'items' => array(
array(
'title' => 'Section',
'block' => 'section',
'wrapper' => 'true',
'merge_siblings' => 'false'
),
array(
'title' => 'Blockquote',
'block' => 'blockquote',
'wrapper' => 'true',
'icon' => 'blockquote'
),
array(
'title' => 'Figure',
'block' => 'figure',
'wrapper' => 'true'
)
)
)
);
$init['style_formats'] = json_encode( $style_formats );
$init['style_formats_merge'] = false;
$init['content_style'] = "#tinymce {margin: 10px 15px!important;}";
return $init;
}
add_filter('tiny_mce_before_init', 'mce_html5_formatting');
function mce_add_buttons_styleselect( $buttons ){
array_splice( $buttons, 1, 0, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'mce_add_buttons_styleselect' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment