| 1 |
<?php |
| 2 |
// registers the buttons for use |
| 3 |
function register_accua_fancy_buttons($buttons) { |
| 4 |
// inserts a separator between existing buttons and our new one |
| 5 |
// "accua_fancy_button" is the ID of our button |
| 6 |
array_push($buttons, "|", "accua_fancy_button"); |
| 7 |
return $buttons; |
| 8 |
} |
| 9 |
|
| 10 |
// filters the tinyMCE buttons and adds our custom buttons |
| 11 |
function accua_shortcode_buttons() { |
| 12 |
// Don't bother doing this stuff if the current user lacks permissions |
| 13 |
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) |
| 14 |
return; |
| 15 |
|
| 16 |
// Add only in Rich Editor mode |
| 17 |
if ( get_user_option('rich_editing') == 'true') { |
| 18 |
// filter the tinyMCE buttons and add our own |
| 19 |
add_filter("mce_external_plugins", "add_accua_tinymce_plugin"); |
| 20 |
add_filter('mce_buttons', 'register_accua_fancy_buttons'); |
| 21 |
} |
| 22 |
} |
| 23 |
// init process for button control |
| 24 |
add_action('init', 'accua_shortcode_buttons'); |
| 25 |
|
| 26 |
// add the button to the tinyMCE bar |
| 27 |
function add_accua_tinymce_plugin($plugin_array) { |
| 28 |
$plugin_array['accua_fancy_button'] = plugins_url('accua-shortcode-button.js?v='.ACCUA_FORMS_JS_VERSION, ACCUA_FORMS_FILE); |
| 29 |
return $plugin_array; |
| 30 |
} |
| 31 |
|
| 32 |
add_action('wp_ajax_accua_shortcode_button_popup', 'accua_shortcode_buttons_popup'); |
| 33 |
function accua_shortcode_buttons_popup() { |
| 34 |
require_once('accua-shortcode-button-popup.php'); |
| 35 |
die(''); |
| 36 |
} |
| 37 |
|