PluginProbe
Insert Html Snippet / 1.0
Insert Html Snippet v1.0
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, at editor_plugin.js.php

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