| 1 |
<?php |
| 2 |
|
| 3 |
// Add Shortcode buttons in TinyMCE |
| 4 |
$elements = array( |
| 5 |
'toggles', |
| 6 |
'tabs', |
| 7 |
'lists', |
| 8 |
'buttons', |
| 9 |
'notifications', |
| 10 |
'wpcolumns', |
| 11 |
'tables', |
| 12 |
'tooltip', |
| 13 |
'iconhead', |
| 14 |
'panel', |
| 15 |
'popover', |
| 16 |
'dropdown', |
| 17 |
'labels', |
| 18 |
'well', |
| 19 |
'thumbnail', |
| 20 |
'icon', |
| 21 |
'image', |
| 22 |
'progressbar' |
| 23 |
); |
| 24 |
|
| 25 |
foreach ($elements as $element) { |
| 26 |
include( $element . '/plugin_shortcode.php'); |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
// -------------------------------------------------------------------------------------------------------------- |
| 31 |
|
| 32 |
add_action('init', 'add_custom_button'); |
| 33 |
|
| 34 |
function add_custom_button() { |
| 35 |
//global $elements; |
| 36 |
// Don't bother doing this stuff if the current user lacks permissions |
| 37 |
if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) |
| 38 |
return; |
| 39 |
|
| 40 |
// Add only in Rich Editor mode |
| 41 |
if (get_user_option('rich_editing') == 'true') { |
| 42 |
|
| 43 |
add_filter("mce_external_plugins", "add_custom_plugin"); |
| 44 |
add_filter('mce_buttons_3', 'register_custom_button'); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
function register_custom_button($buttons) { |
| 49 |
|
| 50 |
global $elements; |
| 51 |
foreach ($elements as $element) { |
| 52 |
$buttons[] = 'oscitas' . $element; |
| 53 |
} |
| 54 |
return $buttons; |
| 55 |
} |
| 56 |
|
| 57 |
// Load the TinyMCE plugin : editor_plugin.js (wp2.5) |
| 58 |
function add_custom_plugin($plugin_array) { |
| 59 |
//print_r($elements); exit; |
| 60 |
global $elements; |
| 61 |
foreach ($elements as $element) { |
| 62 |
$plugin_array['oscitas' . $element] = plugins_url('', __FILE__) . '/' . $element . '/' . $element . '_plugin.js'; |
| 63 |
} |
| 64 |
/// return $buttons; |
| 65 |
return $plugin_array; |
| 66 |
} |
| 67 |
|
| 68 |
?> |
| 69 |
|