PluginProbe
Insert Html Snippet / trunk
Insert Html Snippet vtrunk
1.4.6 trunk 1.0 1.0.1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3 1.3.1 1.3.2 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 All 27 releases
← All changes | editor_plugin.js.php +69 -24 1.2trunk View file →
@@ -1,27 +1,72 @@
1 1 <?php
2 +if ( ! defined( 'ABSPATH' ) )
3 + exit;
4 +
2 5 header( 'Content-Type: text/javascript' );
3 6 if ( ! is_user_logged_in() )
4 7 die('You must be logged in to access this script.');
5 8
6 - if(!isset($shortcodesXYZEH))
7 - $shortcodesXYZEH = new XYZ_Insert_Html_TinyMCESelector();
9 +/*if(!isset($shortcodesXYZEH))
10 + $shortcodesXYZEH = new XYZ_Insert_Html_TinyMCESelector();*/
8 11
9 - global $wpdb;
12 +global $wpdb;
13 +$buttonName = 'xyz_ihs_snippet_selector';
10 14
11 -
12 -$xyz_snippets_arr=$wpdb->get_results($wpdb->prepare( "SELECT id,title FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE status=%d ORDER BY id DESC",1),ARRAY_A );
15 +$xyz_snippets_arr=$wpdb->get_results($wpdb->prepare( "SELECT id,title FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE status=%d and insertionMethod=%d ORDER BY id DESC",1,2),ARRAY_A );
13 16 // print_r($xyz_snippets_arr);
14 -if(count($xyz_snippets_arr)==0)
17 +if(empty($xyz_snippets_arr))//if(count($xyz_snippets_arr)==0)
15 18 die;
16 19
17 -if(floatval(get_bloginfo('version'))>=3.9)
20 +if(floatval(get_bloginfo('version'))>=3.9) //version 5 updation
18 21 {
19 22 ?>
23 + (function() {
24 + /* Register the buttons */
25 + tinymce.create('tinymce.plugins.xyz_ihs_snippet', {
26 + init : function(ed, url) {
27 + /**
28 + * Inserts shortcode content
29 + */
30 + ed.addButton( '<?php echo $buttonName;?>', {
31 + title: 'Insert HTML Snippet',
32 + type: 'menubutton',
33 + icon: 'icon xyz-ihs-own-icon',
34 + menu: [
35 +
36 + <?php foreach ($xyz_snippets_arr as $key=>$val) { ?>
37 + {
38 + text: '<?php echo addslashes($val['title']); ?>',
39 + value: '[xyz-ihs snippet="<?php echo addslashes($val['title']); ?>"]',
40 + onclick: function() {
41 + ed.selection.setContent(this.value());
42 + }
43 + },
44 + <?php } ?>
45 +
46 + ]
47 +
48 + });
49 +
50 +
51 + },
52 + createControl : function(n, cm) {
53 + return null;
54 + },
55 + });
56 + /* Start the buttons */
57 + tinymce.PluginManager.add( 'xyz_ihs_buttons', tinymce.plugins.xyz_ihs_snippet );
58 +})();
59 +
60 +<?php
61 +}
62 +/*else if(floatval(get_bloginfo('version'))>=3.9)
63 +{
64 +?>
20 65 (function() {
21 66
22 - tinymce.PluginManager.add('<?php echo $shortcodesXYZEH->buttonName; ?>', function( editor, url ) {
23 - editor.addButton( '<?php echo $shortcodesXYZEH->buttonName; ?>', {
67 + tinymce.PluginManager.add('<?php echo $buttonName; ?>', function( editor, url ) {
68 + editor.addButton( '<?php echo $buttonName; ?>', {
24 69 title: 'Insert HTML Snippet',
25 70 type: 'menubutton',
26 71 icon: 'icon xyz-ihs-own-icon',
27 72 menu: [
@@ -38,24 +83,24 @@
38 83 });
39 84 });
40 85
41 86 })();
42 -<?php } else {
87 +<?php }*/ else {
43 88
44 89 $xyz_snippets = array(
45 90 'title' =>'Insert HTML Snippet',
46 - 'url' => plugins_url('insert-html-snippet/images/logo.png'),
91 + 'url' => plugins_url('images/logo.png',XYZ_INSERT_HTML_PLUGIN_FILE),
47 92 'xyz_ihs_snippets' => $xyz_snippets_arr
48 93 );
49 94 ?>
50 95
51 -var tinymce_<?php echo $shortcodesXYZEH->buttonName; ?> =<?php echo json_encode($xyz_snippets) ?>;
96 +var tinymce_<?php echo $buttonName; ?> =<?php echo json_encode($xyz_snippets) ?>;
52 97
53 98
54 99 (function() {
55 100 //******* Load plugin specific language pack
56 101
57 - tinymce.create('tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>', {
102 + tinymce.create('tinymce.plugins.<?php echo $buttonName; ?>', {
58 103 /**
59 104 * Initializes the plugin, this will be executed after the plugin has been created.
60 105 * This call is done before the editor instance has finished it's initialization so use the onInit event
61 106 * of the editor instance to intercept that event.
@@ -64,11 +109,11 @@
64 109 * @param {string} url Absolute URL to where the plugin is located.
65 110 */
66 111 init : function(ed, url) {
67 112
68 - tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.insert = function(){
113 + tinymce_<?php echo $buttonName; ?>.insert = function(){
69 114 if(this.v && this.v != ''){
70 - tinymce.execCommand('mceInsertContent', false, '[xyz-ihs snippet="'+tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.xyz_ihs_snippets[this.v]['title']+'"]');
115 + tinymce.execCommand('mceInsertContent', false, '[xyz-ihs snippet="'+tinymce_<?php echo $buttonName; ?>.xyz_ihs_snippets[this.v]['title']+'"]');
71 116 }
72 117 };
73 118
74 119 },
@@ -83,13 +128,13 @@
83 128 * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
84 129 * @return {tinymce.ui.Control} New control instance or null if no control was created.
85 130 */
86 131 createControl : function(n, cm) {
87 - if(n=='<?php echo $shortcodesXYZEH->buttonName; ?>'){
88 - var c = cm.createSplitButton('<?php echo $shortcodesXYZEH->buttonName; ?>', {
89 - title : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.title,
90 - image : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.url,
91 - onclick : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.insert
132 + if(n=='<?php echo $buttonName; ?>'){
133 + var c = cm.createSplitButton('<?php echo $buttonName; ?>', {
134 + title : tinymce_<?php echo $buttonName; ?>.title,
135 + image : tinymce_<?php echo $buttonName; ?>.url,
136 + onclick : tinymce_<?php echo $buttonName; ?>.insert
92 137 });
93 138
94 139 // Add some values to the list box
95 140
@@ -94,13 +139,13 @@
94 139 // Add some values to the list box
95 140
96 141
97 142 c.onRenderMenu.add(function(c, m){
98 - for (var id in tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.xyz_ihs_snippets){
143 + for (var id in tinymce_<?php echo $buttonName; ?>.xyz_ihs_snippets){
99 144 m.add({
100 145 v : id,
101 - title : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.xyz_ihs_snippets[id]['title'],
102 - onclick : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.insert
146 + title : tinymce_<?php echo $buttonName; ?>.xyz_ihs_snippets[id]['title'],
147 + onclick : tinymce_<?php echo $buttonName; ?>.insert
103 148 });
104 149 }
105 150 });
106 151
@@ -115,8 +160,8 @@
115 160
116 161 });
117 162
118 163 // Register plugin
119 - tinymce.PluginManager.add('<?php echo $shortcodesXYZEH->buttonName; ?>', tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>);
164 + tinymce.PluginManager.add('<?php echo $buttonName; ?>', tinymce.plugins.<?php echo $buttonName; ?>);
120 165 })();
121 166
122 167 <?php } ?>