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

93 lines 3.6 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
11 $xyz_snippets = array(
12 'title' =>'Insert HTML Snippet',
13 'url' => plugins_url('insert-html-snippet/images/logo.png'),
14 'xyz_ihs_snippets' => $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 );
16
17 if(count($xyz_snippets[ 'xyz_ihs_snippets'])==0)
18 die;
19
20 ?>
21
22 var tinymce_<?php echo $shortcodesXYZEH->buttonName; ?> =<?php echo json_encode($xyz_snippets) ?>;
23
24
25 (function() {
26 //******* Load plugin specific language pack
27
28 tinymce.create('tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>', {
29 /**
30 * Initializes the plugin, this will be executed after the plugin has been created.
31 * This call is done before the editor instance has finished it's initialization so use the onInit event
32 * of the editor instance to intercept that event.
33 *
34 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
35 * @param {string} url Absolute URL to where the plugin is located.
36 */
37 init : function(ed, url) {
38
39 tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.insert = function(){
40 if(this.v != ''){
41 tinymce.execCommand('mceInsertContent', false, '[xyz-ihs snippet="'+tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.xyz_ihs_snippets[this.v]['title']+'"]');
42 }
43 };
44
45 },
46
47 /**
48 * Creates control instances based in the incomming name. This method is normally not
49 * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
50 * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
51 * method can be used to create those.
52 *
53 * @param {String} n Name of the control to create.
54 * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
55 * @return {tinymce.ui.Control} New control instance or null if no control was created.
56 */
57 createControl : function(n, cm) {
58 if(n=='<?php echo $shortcodesXYZEH->buttonName; ?>'){
59 var c = cm.createSplitButton('<?php echo $shortcodesXYZEH->buttonName; ?>', {
60 title : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.title,
61 image : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.url,
62 onclick : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.insert
63 });
64
65 // Add some values to the list box
66
67
68 c.onRenderMenu.add(function(c, m){
69 for (var id in tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.xyz_ihs_snippets){
70 m.add({
71 v : id,
72 title : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.xyz_ihs_snippets[id]['title'],
73 onclick : tinymce_<?php echo $shortcodesXYZEH->buttonName; ?>.insert
74 });
75 }
76 });
77
78
79 // Return the new listbox instance
80 return c;
81 }
82
83 return null;
84 },
85
86
87 });
88
89 // Register plugin
90 tinymce.PluginManager.add('<?php echo $shortcodesXYZEH->buttonName; ?>', tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>);
91 })();
92
93