Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Last active August 1, 2017 16:36
Show Gist options
  • Save stephanieleary/f1e034e121a8276929d250fcfa773d3c to your computer and use it in GitHub Desktop.
Save stephanieleary/f1e034e121a8276929d250fcfa773d3c to your computer and use it in GitHub Desktop.
Blockquote + Cite TinyMCE button PHP
<?php
function scl_pullquote_mce_button() {
// check if WYSIWYG is enabled
if ( 'true' == get_user_option( 'rich_editing' ) ) {
add_filter( 'mce_external_plugins', 'scl_pullquote_add_tinymce_plugin' );
add_filter( 'mce_buttons', 'scl_pullquote_register_mce_button' );
// enforce Dashicon font
echo '<style>
.dashicons-testimonial::before {
font-family: dashicons,tinymce;
}
</style>';
}
}
add_action('admin_head', 'scl_pullquote_mce_button');
// Declare script for new button
// cf. https://gist.github.com/sillybean/68d53b9b729804737e9d9774bc1d0a60
function scl_pullquote_add_tinymce_plugin( $plugin_array ) {
$plugin_array['blockquote_cite'] = get_stylesheet_directory_uri() .'/js/mce-buttons.js';
return $plugin_array;
}
// Register new button in the editor
function scl_pullquote_register_mce_button( $buttons ) {
$first = array_slice( $buttons, 0, 6 );
array_push( $first, 'blockquote_cite' );
$buttons = array_splice( $buttons, 6, count( $buttons ) );
return array_merge( $first, $buttons );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment