| 1 |
<?php |
| 2 |
|
| 3 |
if(!class_exists('XYZ_Insert_Html_TinyMCESelector')): |
| 4 |
|
| 5 |
class XYZ_Insert_Html_TinyMCESelector{ |
| 6 |
var $buttonName = 'xyz_ihs_snippet_selecter'; |
| 7 |
function addSelector(){ |
| 8 |
// Don't bother doing this stuff if the current user lacks permissions |
| 9 |
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) |
| 10 |
return; |
| 11 |
|
| 12 |
// Add only in Rich Editor mode |
| 13 |
if ( get_user_option('rich_editing') == 'true') { |
| 14 |
add_filter('mce_external_plugins', array($this, 'registerTmcePlugin')); |
| 15 |
//you can use the filters mce_buttons_2, mce_buttons_3 and mce_buttons_4 |
| 16 |
//to add your button to other toolbars of your tinymce |
| 17 |
add_filter('mce_buttons', array($this, 'registerButton')); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
function registerButton($buttons){ |
| 22 |
array_push($buttons, "separator", $this->buttonName); |
| 23 |
return $buttons; |
| 24 |
} |
| 25 |
|
| 26 |
function registerTmcePlugin($plugin_array){ |
| 27 |
$plugin_array[$this->buttonName] = plugins_url() . '/insert-html-snippet/editor_plugin.js.php'; |
| 28 |
|
| 29 |
if ( get_user_option('rich_editing') == 'true') |
| 30 |
//var_dump($plugin_array); |
| 31 |
return $plugin_array; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
endif; |
| 36 |
|
| 37 |
if(!isset($shortcodesXYZEH)){ |
| 38 |
$shortcodesXYZEH = new XYZ_Insert_Html_TinyMCESelector(); |
| 39 |
add_action('admin_head', array($shortcodesXYZEH, 'addSelector')); |
| 40 |
} |
| 41 |
|
| 42 |
|