-
-
Save mike-zarandona/6c2697ed52415eeb67a2a16ef1e9c5ca to your computer and use it in GitHub Desktop.
TinyMCE Advanced Custom Formats / Styles / Shortcode Buttons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* step 1: load this in editor-style.css in the theme folder */ | |
/* step 2: activate function "Create CSS classes menu" in tinymce advanced */ | |
/* this gets shown automatically in the formats dropdown */ | |
.MY-CUSTOM-CLASS { | |
background-color:red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tinymce_add_mce_button() { | |
// check user permissions | |
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) { | |
return; | |
} | |
// check if editor is enabled | |
if ( 'true' == get_user_option( 'rich_editing' ) ) { | |
add_filter( 'mce_external_plugins', 'tinymce_add_tinymce_plugin' ); | |
add_filter( 'mce_buttons', 'tinymce_register_mce_button' ); | |
} | |
} | |
function tinymce_add_tinymce_plugin( $plugin_array ) { | |
$plugin_array['mce_buttons'] = get_stylesheet_directory_uri() .'/mce-button.js'; | |
return $plugin_array; | |
} | |
function tinymce_register_mce_button( $buttons ) { | |
array_push( $buttons, 'mce_button_1' ); | |
array_push( $buttons, 'mce_button_2' ); | |
return $buttons; | |
} | |
add_action('admin_head', 'tinymce_add_mce_button'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment