PluginProbe
Insert PHP Code Snippet / trunk
Insert PHP Code Snippet vtrunk
1.4.7 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 All 27 releases
insert-php-code-snippet / add_shortcode_tynimce.php

add_shortcode_tynimce.php in Insert PHP Code Snippet trunk, at add_shortcode_tynimce.php

70 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) )
3 exit;
4
5 add_action( 'admin_init', 'xyz_ips_tinymce_button' );
6
7 function xyz_ips_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_ips_register_tinymce_button' );
13 add_filter( 'mce_external_plugins', 'xyz_ips_add_tinymce_button' );
14 }
15 }
16 }
17
18 function xyz_ips_register_tinymce_button( $buttons ) {
19
20 $buttonName = 'xyz_ips_snippet_selecter';
21
22 array_push( $buttons, $buttonName);
23 return $buttons;
24 }
25
26 function xyz_ips_add_tinymce_button( $plugin_array ) {
27 $plugin_array['xyz_ips_buttons'] = get_site_url() . '/index.php?wp_ips=editor_plugin_js';
28 return $plugin_array;
29 }
30
31 /*if(!class_exists('XYZ_Insert_Php_TinyMCESelector')):
32
33 class XYZ_Insert_Php_TinyMCESelector{
34 var $buttonName = 'xyz_ips_snippet_selecter';
35 function addSelector(){
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 add_filter('mce_external_plugins', array($this, 'registerTmcePlugin'));
43 //you can use the filters mce_buttons_2, mce_buttons_3 and mce_buttons_4
44 //to add your button to other toolbars of your tinymce
45 add_filter('mce_buttons', array($this, 'registerButton'));
46 }
47 }
48
49 function registerButton($buttons){
50 array_push($buttons, "separator", $this->buttonName);
51 return $buttons;
52 }
53
54 function registerTmcePlugin($plugin_array){
55 $plugin_array[$this->buttonName] =get_site_url() . '/index.php?wp_ips=editor_plugin_js';
56 if ( get_user_option('rich_editing') == 'true')
57 //var_dump($plugin_array);
58 return $plugin_array;
59 }
60 }
61
62 endif;
63
64 if(!isset($shortcodesXYZEP)){
65 $shortcodesXYZEP = new XYZ_Insert_Php_TinyMCESelector();
66 add_action('admin_head', array($shortcodesXYZEP, 'addSelector'));
67 }*/
68
69 ?>
70