PluginProbe
Insert Html Snippet / 1.0.1
Insert Html Snippet v1.0.1
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
insert-html-snippet / editor_plugin.js.php

editor_plugin.js.php in Insert Html Snippet 1.0.1, at editor_plugin.js.php

76 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! is_user_logged_in() )
4 die('You must be logged in to access this script.');
5
6 if(!isset($shortcodesXYZEH))
7 $shortcodesXYZEH = new XYZ_Insert_Html_TinyMCESelector();
8
9 global $wpdb;
10 // $ordered_sct = array_keys($shortcode_tags);
11 // sort($ordered_sct);
12
13 $ordered_sct = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE status='1' ORDER BY id DESC" );
14 ?>
15
16 (function() {
17 //******* Load plugin specific language pack
18
19 tinymce.create('tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>', {
20 /**
21 * Initializes the plugin, this will be executed after the plugin has been created.
22 * This call is done before the editor instance has finished it's initialization so use the onInit event
23 * of the editor instance to intercept that event.
24 *
25 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
26 * @param {string} url Absolute URL to where the plugin is located.
27 */
28 init : function(ed, url) {
29
30 },
31
32 /**
33 * Creates control instances based in the incomming name. This method is normally not
34 * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
35 * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
36 * method can be used to create those.
37 *
38 * @param {String} n Name of the control to create.
39 * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
40 * @return {tinymce.ui.Control} New control instance or null if no control was created.
41 */
42 createControl : function(n, cm) {
43 if(n=='<?php echo $shortcodesXYZEH->buttonName; ?>'){
44 var mlb = cm.createListBox('<?php echo $shortcodesXYZEH->buttonName; ?>List', {
45 title : 'HTML Snippets',
46 onselect : function(v) { //Option value as parameter
47 if(v != ''){
48 if(tinyMCE.activeEditor.selection.getContent() != ''){
49 tinyMCE.activeEditor.selection.setContent('[' + v + ']' + tinyMCE.activeEditor.selection.getContent() + '[/' + v + ']');
50 }
51 else{
52 tinyMCE.activeEditor.selection.setContent('[' + v + ']');
53 }
54 }
55 }
56 });
57
58 // Add some values to the list box
59 <?php foreach($ordered_sct as $sct):?>
60 mlb.add('<?php echo $sct->title;?>', '<?php echo 'xyz-ihs snippet="'.$sct->title.'"';?>');
61 <?php endforeach;?>
62
63 // Return the new listbox instance
64 return mlb;
65 }
66
67 return null;
68 },
69
70
71 });
72
73 // Register plugin
74 tinymce.PluginManager.add('<?php echo $shortcodesXYZEH->buttonName; ?>', tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>);
75 })();
76