| @@ -1,42 +1,69 @@ | ||
| 1 | -<?php | |
| 2 | -if ( ! defined( 'ABSPATH' ) ) | |
| 3 | - exit; | |
| 4 | - | |
| 5 | -if(!class_exists('XYZ_Insert_Html_TinyMCESelector')): | |
| 6 | - | |
| 7 | -class XYZ_Insert_Html_TinyMCESelector{ | |
| 8 | - var $buttonName = 'xyz_ihs_snippet_selector'; | |
| 9 | - function addSelector(){ | |
| 10 | - // Don't bother doing this stuff if the current user lacks permissions | |
| 11 | - if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) | |
| 12 | - return; | |
| 13 | - | |
| 14 | - // Add only in Rich Editor mode | |
| 15 | - if ( get_user_option('rich_editing') == 'true') { | |
| 16 | - add_filter('mce_external_plugins', array($this, 'registerTmcePlugin')); | |
| 17 | - //you can use the filters mce_buttons_2, mce_buttons_3 and mce_buttons_4 | |
| 18 | - //to add your button to other toolbars of your tinymce | |
| 19 | - add_filter('mce_buttons', array($this, 'registerButton')); | |
| 20 | - } | |
| 21 | - } | |
| 22 | - | |
| 23 | - function registerButton($buttons){ | |
| 24 | - array_push($buttons, "separator", $this->buttonName); | |
| 25 | - return $buttons; | |
| 26 | - } | |
| 27 | - | |
| 28 | - function registerTmcePlugin($plugin_array){ | |
| 29 | - $plugin_array[$this->buttonName] =get_site_url() . '/index.php?wp_ihs=editor_plugin_js'; | |
| 30 | - if ( get_user_option('rich_editing') == 'true') | |
| 31 | - //var_dump($plugin_array); | |
| 32 | - return $plugin_array; | |
| 33 | - } | |
| 34 | -} | |
| 35 | - | |
| 36 | -endif; | |
| 37 | - | |
| 38 | -if(!isset($shortcodesXYZEH)){ | |
| 39 | - $shortcodesXYZEH = new XYZ_Insert_Html_TinyMCESelector(); | |
| 40 | - add_action('admin_head', array($shortcodesXYZEH, 'addSelector')); | |
| 41 | -} | |
| 1 | +<?php | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) | |
| 3 | + exit; | |
| 4 | + | |
| 5 | +add_action( 'admin_init', 'xyz_ihs_tinymce_button' ); | |
| 6 | + | |
| 7 | +function xyz_ihs_tinymce_button() { | |
| 8 | + if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { | |
| 9 | + | |
| 10 | + if ( get_user_option('rich_editing') == 'true') { | |
| 11 | + | |
| 12 | + add_filter( 'mce_buttons', 'xyz_ihs_register_tinymce_button' ); | |
| 13 | + add_filter( 'mce_external_plugins', 'xyz_ihs_add_tinymce_button' ); | |
| 14 | + } | |
| 15 | + } | |
| 16 | +} | |
| 17 | + | |
| 18 | +function xyz_ihs_register_tinymce_button( $buttons ) { | |
| 19 | + | |
| 20 | + $buttonName = 'xyz_ihs_snippet_selector'; | |
| 21 | + | |
| 22 | + array_push( $buttons, $buttonName); | |
| 23 | + return $buttons; | |
| 24 | +} | |
| 25 | + | |
| 26 | +function xyz_ihs_add_tinymce_button( $plugin_array ) { | |
| 27 | + $plugin_array['xyz_ihs_buttons'] = get_site_url() . '/index.php?wp_ihs=editor_plugin_js'; | |
| 28 | + return $plugin_array; | |
| 29 | +} | |
| 30 | + | |
| 31 | + | |
| 32 | +/*if(!class_exists('XYZ_Insert_Html_TinyMCESelector')): | |
| 33 | + | |
| 34 | +class XYZ_Insert_Html_TinyMCESelector{ | |
| 35 | + var $buttonName = 'xyz_ihs_snippet_selector'; | |
| 36 | + function addSelector(){ | |
| 37 | + // Don't bother doing this stuff if the current user lacks permissions | |
| 38 | + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) | |
| 39 | + return; | |
| 40 | + | |
| 41 | + // Add only in Rich Editor mode | |
| 42 | + if ( get_user_option('rich_editing') == 'true') { | |
| 43 | + add_filter('mce_external_plugins', array($this, 'registerTmcePlugin')); | |
| 44 | + //you can use the filters mce_buttons_2, mce_buttons_3 and mce_buttons_4 | |
| 45 | + //to add your button to other toolbars of your tinymce | |
| 46 | + add_filter('mce_buttons', array($this, 'registerButton')); | |
| 47 | + } | |
| 48 | + } | |
| 49 | + | |
| 50 | + function registerButton($buttons){ | |
| 51 | + array_push($buttons, "separator", $this->buttonName); | |
| 52 | + return $buttons; | |
| 53 | + } | |
| 54 | + | |
| 55 | + function registerTmcePlugin($plugin_array){ | |
| 56 | + $plugin_array[$this->buttonName] =get_site_url() . '/index.php?wp_ihs=editor_plugin_js'; | |
| 57 | + if ( get_user_option('rich_editing') == 'true') | |
| 58 | + //var_dump($plugin_array); | |
| 59 | + return $plugin_array; | |
| 60 | + } | |
| 61 | +} | |
| 62 | + | |
| 63 | +endif; | |
| 64 | + | |
| 65 | +if(!isset($shortcodesXYZEH)){ | |
| 66 | + $shortcodesXYZEH = new XYZ_Insert_Html_TinyMCESelector(); | |
| 67 | + add_action('admin_head', array($shortcodesXYZEH, 'addSelector')); | |
| 68 | +}*/ | |
| 42 | 69 | ?> |