PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.9
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.9
2.7.9 2.7.8 2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 All 30 releases
← All changes | admin/assets/js/tinymce4.4.js +70 -34 2.0.6 → 2.7.9 View file →
@@ -1,35 +1,71 @@
1 -(function($) {
2 - $(document).on('tinymce-editor-setup', function(event, editor) {
3 -
4 - if( void 0 === wbcr_inp_shortcode_snippets ) {
5 - console.log('Unknown error.');
6 - return;
7 - }
8 -
9 - if( $.isEmptyObject(wbcr_inp_shortcode_snippets) ) {
10 - return;
11 - }
12 -
13 - editor.settings.toolbar1 += ',wbcr_insert_php_button';
14 -
15 - var menu = [];
16 -
17 - $.each(wbcr_inp_shortcode_snippets, function(index, item) {
18 - menu.push({
19 - text: item.title,
20 - value: item.id,
21 - onclick: function() {
22 - editor.selection.setContent('[wbcr_php_snippet id="' + item.id + '" title="' + item.title + '"]');
23 - }
24 - });
25 - });
26 -
27 - editor.addButton('wbcr_insert_php_button', {
28 - title: wbcr_inp_tinymce_snippets_button_title,
29 - type: 'menubutton',
30 - icon: 'icon wbcr-inp-shortcode-icon',
31 - menu: menu
32 - });
33 -
34 - });
1 +(function($) {
2 + $(document).on('tinymce-editor-setup', function(event, editor) {
3 +
4 + if( void 0 === wbcr_inp_shortcode_snippets ) {
5 + console.log('Unknown error.');
6 + return;
7 + }
8 +
9 + if( $.isEmptyObject(wbcr_inp_shortcode_snippets) ) {
10 + return;
11 + }
12 +
13 + editor.settings.toolbar1 += ',wbcr_insert_php_button';
14 +
15 + var menu = [];
16 +
17 + $.each(wbcr_inp_shortcode_snippets, function(index, item) {
18 + menu.push({
19 + text: item.title,
20 + value: item.id,
21 + onclick: function() {
22 + var content = "";
23 + var snippet_type = item.type;
24 + var snippet_name = item.name;
25 + var selected_content = editor.selection.getContent();
26 +
27 + for( var tag in item ) {
28 + if( !item.hasOwnProperty(tag) ) {
29 + continue;
30 + }
31 +
32 + if( 'type' === tag ) {
33 + snippet_type = item[tag];
34 + } else if( 'name' === tag ) {
35 + snippet_name = item[tag];
36 + } else if( tag.indexOf('snippet_tags') === -1 ) {
37 + if( !('' !== selected_content && 'content' === tag) ) {
38 + content += ' ' + tag + '="' + item[tag] + '"';
39 + }
40 + }
41 + }
42 +
43 + if( '' === snippet_name || undefined === snippet_name ) {
44 + if( 'universal' === snippet_type ) {
45 + snippet_name = "wbcr_snippet";
46 + } else {
47 + snippet_name = "wbcr_" + snippet_type + "_snippet";
48 + }
49 + }
50 +
51 + if( '' === selected_content ) {
52 + editor.selection.setContent('[' + snippet_name + content + ']');
53 + } else {
54 + editor.selection.setContent(
55 + '[' + snippet_name + content + ']' +
56 + selected_content +
57 + '[/' + snippet_name + ']');
58 + }
59 + }
60 + });
61 + });
62 +
63 + editor.addButton('wbcr_insert_php_button', {
64 + title: wbcr_inp_tinymce_snippets_button_title,
65 + type: 'menubutton',
66 + icon: 'icon wbcr-inp-shortcode-icon',
67 + menu: menu
68 + });
69 +
70 + });
35 71 })(jQuery);