Created
December 22, 2014 06:19
-
-
Save sky4git/7bd61ee9c43c3661e57c to your computer and use it in GitHub Desktop.
Add button(s) to TinyMCE 4.x in Wordpress 4.x
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
/* | |
--------------- Adding shortcode buttons to editor ----------------------*/ | |
add_action('admin_init', 'dq_shortcode_button'); | |
function dq_shortcode_button() | |
{ | |
if( current_user_can('edit_posts') && current_user_can('edit_pages') ) | |
{ | |
add_filter( 'mce_external_plugins', 'dq_add_buttons'); | |
add_filter( 'mce_buttons', 'dq_register_buttons' ); | |
} | |
} | |
function dq_add_buttons( $plugin_array ) | |
{ | |
$plugin_array['dqshortcodes'] = get_stylesheet_directory_uri(). '/js/add_buttons_to_tinymce.js'; | |
return $plugin_array; | |
} | |
function dq_register_buttons( $buttons ) | |
{ | |
array_push( $buttons, 'showrecent'); | |
var_dump($buttons); | |
return $buttons; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment