functions.php:
function add_shortcode_button() {
echo '<a href="#" id="add_shortcode_button" class="button"> <span class="dashicons dashicons-editor-code" style="padding-top: 4px; padding-right: 4px;"></span> My Shortcode</a>';
}
function include_shortcode_button_files() {
wp_enqueue_script('shortcode_js', get_template_directory_uri() . '/shortcodes.js', array('jquery'), '1.0', true);
wp_enqueue_style('shortcode_css', get_template_directory_uri() . '/shortcodes.css', false, '1.0');
}
if ( current_user_can('edit_posts') && current_user_can('edit_pages') ) {
add_action('media_buttons', 'add_shortcode_button', 15);
add_action('wp_enqueue_media', 'include_shortcode_button_files');
}
function shortcode_popup() {
?>
<div id="shortcode_window"> Bla Bla Bla... </div>
<?php
}
add_action( 'admin_footer', 'shortcode_popup' );
shortcodes.js:
jQuery(document).ready(function($) {
$("#add_shortcode_button").click(function() {
$("#shortcode_window").show();
});
});
shortcodes.css:
#shortcode_window {
display: none;
}