Black Studio TinyMCE Widget - Version 1.3.0

Version Description

  • Added support for smilies conversion (based on the general Wordpress option)
  • Updated styling to match the new default Wordpress editor appearence
  • Refactoring of PHP and JS code to be compliant with Wordpress coding standard
  • Fixed compatibility issue with Wordpress 3.9 alpha and TinyMCE 4.0
  • Fixed compatibility issue with Jetpack / After the Deadline plugin
  • Fixed editor behavior on widget title clicks
  • Fixed CSS issue affecting Firefox on Wordpress 3.8
  • Added finnish translation (Contributor: Timo Leini)
  • Better handling of "More tag" button
  • Included JS dev version
Download this release

Release Info

Developer marcochiesi
Plugin Icon 128x128 Black Studio TinyMCE Widget
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.0 to 1.3.0

black-studio-tinymce-widget-legacy.dev.js ADDED
@@ -0,0 +1,131 @@
1
+ // TinyMCE initialization parameters
2
+ var tinyMCEPreInit;
3
+ // Current editor (backward compatibility)
4
+ var edCanvas;
5
+ // Current editor
6
+ var wpActiveEditor;
7
+
8
+ (function($) {
9
+ // Activate visual editor
10
+ function black_studio_activate_visual_editor(id) {
11
+ $('#'+id).addClass("mceEditor");
12
+ if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
13
+ black_studio_deactivate_visual_editor(id);
14
+ if (typeof (tinyMCEPreInit.mceInit['black-studio-tinymce-widget']) == "object") { // WP 3.3+
15
+ tinyMCEPreInit.mceInit[id] = tinyMCEPreInit.mceInit['black-studio-tinymce-widget'];
16
+ tinyMCEPreInit.mceInit[id]["elements"] = id;
17
+ try {
18
+ // Instantiate new TinyMCE editor
19
+ tinymce.init(tinymce.extend( {}, tinyMCEPreInit.mceInit['black-studio-tinymce-widget'], tinyMCEPreInit.mceInit[id] ));
20
+ } catch(e){
21
+ alert(e);
22
+ }
23
+ }
24
+ else { // WP 3.2
25
+ tinyMCE.execCommand("mceAddControl", false, id);
26
+ }
27
+ }
28
+ }
29
+ // Deactivate visual editor
30
+ function black_studio_deactivate_visual_editor(id) {
31
+ if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
32
+ if (typeof(tinyMCE.get(id)) == "object") {
33
+ var content = tinyMCE.get(id).getContent();
34
+ tinyMCE.execCommand("mceRemoveControl", false, id);
35
+ $('textarea#'+id).val(content);
36
+ }
37
+ }
38
+ }
39
+ // Activate editor deferred (used upon opening the widget)
40
+ function black_studio_open_deferred_activate_visual_editor(id) {
41
+ $('div.widget-inside:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]').each(function() {
42
+ // If textarea is visible and animation/ajax has completed (or in accessibility mode) then trigger a click to Visual button and enable the editor
43
+ if ($('div.widget:has(#' + id + ') :animated').size() == 0 && typeof(tinyMCE.get(id)) != "object" && $('#' + id).is(':visible')) {
44
+ $('a[id^=widget-black-studio-tinymce][id$=visual]', $(this).closest('div.widget-inside')).click();
45
+ }
46
+ // Otherwise wait and retry later (animation ongoing)
47
+ else if (typeof(tinyMCE.get(id)) != "object") {
48
+ setTimeout(function(){black_studio_open_deferred_activate_visual_editor(id);id=null;}, 100);
49
+ }
50
+ // If editor instance is already existing (i.e. dragged from another sidebar) just activate it
51
+ else {
52
+ $('a[id^=widget-black-studio-tinymce][id$=visual]', $(this).closest('div.widget-inside')).click();
53
+ }
54
+ });
55
+ }
56
+
57
+ // Activate editor deferred (used upon ajax requests)
58
+ function black_studio_ajax_deferred_activate_visual_editor(id) {
59
+ $('div.widget-inside:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]').each(function() {
60
+ // If textarea is visible and animation/ajax has completed then trigger a click to Visual button and enable the editor
61
+ if ($.active == 0 && typeof(tinyMCE.get(id)) != "object" && $('#' + id).is(':visible')) {
62
+ $('a[id^=widget-black-studio-tinymce][id$=visual]', $(this).closest('div.widget-inside')).click();
63
+ }
64
+ // Otherwise wait and retry later (animation ongoing)
65
+ else if ($('div.widget:has(#' + id + ') div.widget-inside').is(':visible') && typeof(tinyMCE.get(id)) != "object") {
66
+ setTimeout(function(){black_studio_ajax_deferred_activate_visual_editor(id);id=null;}, 100);
67
+ }
68
+ });
69
+ }
70
+
71
+
72
+ // Document ready stuff
73
+ $(document).ready(function(){
74
+ // Event handler for widget opening button
75
+ $('div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action').live('click', function(event){
76
+ event.preventDefault();
77
+ var $widget = $(this).closest('div.widget');
78
+ var $text_area = $('textarea[id^=widget-black-studio-tinymce]', $widget);
79
+ $('#wpbody-content').css('overflow', 'visible'); // needed for small screens
80
+ $widget.css('position', 'relative').css('z-index', '100'); // needed for small screens
81
+ black_studio_open_deferred_activate_visual_editor($text_area.attr('id'));
82
+ });
83
+ // Force BS handler of opening button to be executed before the one coming with Wordpress
84
+ $(document).data("events").click.unshift($(document).data("events").click.pop());
85
+ // Event handler for widget saving button
86
+ $('div.widget[id*=black-studio-tinymce] input[name=savewidget]').live('click', function(event){
87
+ event.preventDefault();
88
+ var $widget = $(this).closest('div.widget')
89
+ var $text_area = $('textarea[id^=widget-black-studio-tinymce]', $widget);
90
+ if (typeof(tinyMCE.get($text_area.attr('id'))) == "object") {
91
+ black_studio_deactivate_visual_editor($text_area.attr('id'));
92
+ }
93
+ // Event handler for ajax complete
94
+ $(this).unbind('ajaxSuccess').ajaxSuccess(function(event, xhr, settings) {
95
+ var $text_area = $('textarea[id^=widget-black-studio-tinymce]', $(this).closest('div.widget-inside'));
96
+ black_studio_ajax_deferred_activate_visual_editor($text_area.attr('id'));
97
+ });
98
+ });
99
+ // Force BS handler of save button to be executed before the one coming with Wordpress
100
+ $(document).data("events").click.unshift($(document).data("events").click.pop());
101
+ // Event handler for visual switch button
102
+ $('a[id^=widget-black-studio-tinymce][id$=visual]').live('click', function(event){
103
+ event.preventDefault();
104
+ var $widget_inside = $(this).closest('div.widget-inside')
105
+ $('input[id^=widget-black-studio-tinymce][id$=type]', $widget_inside).val('visual');
106
+ $(this).addClass('active');
107
+ $('a[id^=widget-black-studio-tinymce][id$=html]', $widget_inside).removeClass('active');
108
+ black_studio_activate_visual_editor($('textarea[id^=widget-black-studio-tinymce]', $widget_inside).attr('id'));
109
+ });
110
+ // Event handler for html switch button
111
+ $('a[id^=widget-black-studio-tinymce][id$=html]').live('click', function(event){
112
+ event.preventDefault();
113
+ var $widget_inside = $(this).closest('div.widget-inside')
114
+ $('input[id^=widget-black-studio-tinymce][id$=type]', $widget_inside).val('html');
115
+ $(this).addClass('active');
116
+ $('a[id^=widget-black-studio-tinymce][id$=visual]', $widget_inside).removeClass('active');
117
+ black_studio_deactivate_visual_editor($('textarea[id^=widget-black-studio-tinymce]', $widget_inside).attr('id'));
118
+ });
119
+ // Set edCanvas/wpActiveEditor variables used when adding media from media library dialog
120
+ $('.editor_media_buttons a').live('click', function(){
121
+ var $widget_inside = $(this).closest('div.widget-inside')
122
+ edCanvas = $('textarea[id^=widget-black-studio-tinymce]', $widget_inside).get();
123
+ wpActiveEditor = $('textarea[id^=widget-black-studio-tinymce]', $widget_inside).attr('id');
124
+ });
125
+ // Activate editor when in accessibility mode
126
+ if($('body.widgets_access').size() > 0) {
127
+ var $text_area = $('textarea[id^=widget-black-studio-tinymce]');
128
+ black_studio_open_deferred_activate_visual_editor($text_area.attr('id'));
129
+ }
130
+ });
131
+ })(jQuery); // end self-invoked wrapper function
black-studio-tinymce-widget-legacy.js CHANGED
@@ -1 +1 @@
1
- eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('8 y;8 U;8 W;(6(c){6 d(g){c("#"+g).Q("18");q(p(9)=="u"&&p(9.I)=="6"){b(g);q(p(y.A["5-4-3-1"])=="u"){y.A[g]=y.A["5-4-3-1"];y.A[g]["1q"]=g;1r{3.1t(3.1k({},y.A["5-4-3-1"],y.A[g]))}1f(f){1l(f)}}M{9.I("1m",X,g)}}}6 b(g){q(p(9)=="u"&&p(9.I)=="6"){q(p(9.x(g))=="u"){8 f=9.x(g).1s();9.I("1n",X,g);c("r#"+g).P(f)}}}6 a(f){c("7.1-s:B(#"+f+") F[2^=1-5-4-3][2$=K][13=v]").14(6(){q(c("7.1:B(#"+f+") :1e").11()==0&&p(9.x(f))!="u"&&c("#"+f).O(":J")){c("a[2^=1-5-4-3][2$=v]",c(n).t("7.1-s")).o()}M{q(p(9.x(f))!="u"){Z(6(){a(f);f=Y},N)}M{c("a[2^=1-5-4-3][2$=v]",c(n).t("7.1-s")).o()}}})}6 e(f){c("7.1-s:B(#"+f+") F[2^=1-5-4-3][2$=K][13=v]").14(6(){q(c.C==0&&p(9.x(f))!="u"&&c("#"+f).O(":J")){c("a[2^=1-5-4-3][2$=v]",c(n).t("7.1-s")).o()}M{q(c("7.1:B(#"+f+") 7.1-s").O(":J")&&p(9.x(f))!="u"){Z(6(){e(f);f=Y},N)}}})}c(E).17(6(){c("7.1:B(r[2^=1-5-4-3]) a.1-19").D("o",6(g){g.G();8 i=c(n).t("7.1");8 h=c("r[2^=1-5-4-3]",i);c("#1a-1b").S("1c","J");i.S("15","16").S("z-1u","N");a(h.w("2"))});c(E).L("H").o.V(c(E).L("H").o.12());c("7.1[2*=5-4-3] F[1p=1o]").D("o",6(g){g.G();8 i=c(n).t("7.1");8 h=c("r[2^=1-5-4-3]",i);q(p(9.x(h.w("2")))=="u"){b(h.w("2"))}c(n).1d("T").T(6(k,l,j){8 m=c("r[2^=1-5-4-3]",c(n).t("7.1-s"));e(m.w("2"))})});c(E).L("H").o.V(c(E).L("H").o.12());c("a[2^=1-5-4-3][2$=v]").D("o",6(g){g.G();8 h=c(n).t("7.1-s");c("F[2^=1-5-4-3][2$=K]",h).P("v");c(n).Q("C");c("a[2^=1-5-4-3][2$=R]",h).10("C");d(c("r[2^=1-5-4-3]",h).w("2"))});c("a[2^=1-5-4-3][2$=R]").D("o",6(g){g.G();8 h=c(n).t("7.1-s");c("F[2^=1-5-4-3][2$=K]",h).P("R");c(n).Q("C");c("a[2^=1-5-4-3][2$=v]",h).10("C");b(c("r[2^=1-5-4-3]",h).w("2"))});c(".1j a").D("o",6(){8 g=c(n).t("7.1-s");U=c("r[2^=1-5-4-3]",g).x();W=c("r[2^=1-5-4-3]",g).w("2")});q(c("1i.1h").11()>0){8 f=c("r[2^=1-5-4-3]");a(f.w("2"))}})})(1g);',62,93,'|widget|id|tinymce|studio|black|function|div|var|tinyMCE||||||||||||||this|click|typeof|if|textarea|inside|closest|object|visual|attr|get|tinyMCEPreInit||mceInit|has|active|live|document|input|preventDefault|events|execCommand|visible|type|data|else|100|is|val|addClass|html|css|ajaxSuccess|edCanvas|unshift|wpActiveEditor|false|null|setTimeout|removeClass|size|pop|value|each|position|relative|ready|mceEditor|action|wpbody|content|overflow|unbind|animated|catch|jQuery|widgets_access|body|editor_media_buttons|extend|alert|mceAddControl|mceRemoveControl|savewidget|name|elements|try|getContent|init|index'.split('|'),0,{}))
1
+ var tinyMCEPreInit;var edCanvas;var wpActiveEditor;(function(c){function d(g){c("#"+g).addClass("mceEditor");if(typeof(tinyMCE)=="object"&&typeof(tinyMCE.execCommand)=="function"){b(g);if(typeof(tinyMCEPreInit.mceInit["black-studio-tinymce-widget"])=="object"){tinyMCEPreInit.mceInit[g]=tinyMCEPreInit.mceInit["black-studio-tinymce-widget"];tinyMCEPreInit.mceInit[g]["elements"]=g;try{tinymce.init(tinymce.extend({},tinyMCEPreInit.mceInit["black-studio-tinymce-widget"],tinyMCEPreInit.mceInit[g]))}catch(f){alert(f)}}else{tinyMCE.execCommand("mceAddControl",false,g)}}}function b(g){if(typeof(tinyMCE)=="object"&&typeof(tinyMCE.execCommand)=="function"){if(typeof(tinyMCE.get(g))=="object"){var f=tinyMCE.get(g).getContent();tinyMCE.execCommand("mceRemoveControl",false,g);c("textarea#"+g).val(f)}}}function a(f){c("div.widget-inside:has(#"+f+") input[id^=widget-black-studio-tinymce][id$=type][value=visual]").each(function(){if(c("div.widget:has(#"+f+") :animated").size()==0&&typeof(tinyMCE.get(f))!="object"&&c("#"+f).is(":visible")){c("a[id^=widget-black-studio-tinymce][id$=visual]",c(this).closest("div.widget-inside")).click()}else{if(typeof(tinyMCE.get(f))!="object"){setTimeout(function(){a(f);f=null},100)}else{c("a[id^=widget-black-studio-tinymce][id$=visual]",c(this).closest("div.widget-inside")).click()}}})}function e(f){c("div.widget-inside:has(#"+f+") input[id^=widget-black-studio-tinymce][id$=type][value=visual]").each(function(){if(c.active==0&&typeof(tinyMCE.get(f))!="object"&&c("#"+f).is(":visible")){c("a[id^=widget-black-studio-tinymce][id$=visual]",c(this).closest("div.widget-inside")).click()}else{if(c("div.widget:has(#"+f+") div.widget-inside").is(":visible")&&typeof(tinyMCE.get(f))!="object"){setTimeout(function(){e(f);f=null},100)}}})}c(document).ready(function(){c("div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action").live("click",function(g){g.preventDefault();var i=c(this).closest("div.widget");var h=c("textarea[id^=widget-black-studio-tinymce]",i);c("#wpbody-content").css("overflow","visible");i.css("position","relative").css("z-index","100");a(h.attr("id"))});c(document).data("events").click.unshift(c(document).data("events").click.pop());c("div.widget[id*=black-studio-tinymce] input[name=savewidget]").live("click",function(g){g.preventDefault();var i=c(this).closest("div.widget");var h=c("textarea[id^=widget-black-studio-tinymce]",i);if(typeof(tinyMCE.get(h.attr("id")))=="object"){b(h.attr("id"))}c(this).unbind("ajaxSuccess").ajaxSuccess(function(k,l,j){var m=c("textarea[id^=widget-black-studio-tinymce]",c(this).closest("div.widget-inside"));e(m.attr("id"))})});c(document).data("events").click.unshift(c(document).data("events").click.pop());c("a[id^=widget-black-studio-tinymce][id$=visual]").live("click",function(g){g.preventDefault();var h=c(this).closest("div.widget-inside");c("input[id^=widget-black-studio-tinymce][id$=type]",h).val("visual");c(this).addClass("active");c("a[id^=widget-black-studio-tinymce][id$=html]",h).removeClass("active");d(c("textarea[id^=widget-black-studio-tinymce]",h).attr("id"))});c("a[id^=widget-black-studio-tinymce][id$=html]").live("click",function(g){g.preventDefault();var h=c(this).closest("div.widget-inside");c("input[id^=widget-black-studio-tinymce][id$=type]",h).val("html");c(this).addClass("active");c("a[id^=widget-black-studio-tinymce][id$=visual]",h).removeClass("active");b(c("textarea[id^=widget-black-studio-tinymce]",h).attr("id"))});c(".editor_media_buttons a").live("click",function(){var g=c(this).closest("div.widget-inside");edCanvas=c("textarea[id^=widget-black-studio-tinymce]",g).get();wpActiveEditor=c("textarea[id^=widget-black-studio-tinymce]",g).attr("id")});if(c("body.widgets_access").size()>0){var f=c("textarea[id^=widget-black-studio-tinymce]");a(f.attr("id"))}})})(jQuery);
black-studio-tinymce-widget.css CHANGED
@@ -10,47 +10,37 @@
10
11
.editor_container {
12
background-color: #FFF;
13
- border-color: #CCC #CCC #DFDFDF;
14
border-style: solid;
15
border-width: 1px;
16
border-collapse: separate;
17
- -moz-border-radius: 3px 3px 0 0;
18
- -webkit-border-top-right-radius: 3px;
19
- -webkit-border-top-left-radius: 3px;
20
- -khtml-border-top-right-radius: 3px;
21
- -khtml-border-top-left-radius: 3px;
22
border-top-right-radius: 3px;
23
border-top-left-radius: 3px;
24
}
25
.editor_toggle_buttons {
26
- height: 30px;
27
margin-right: 15px;
28
margin-top: 8px;
29
float: right;
30
}
31
.editor_toggle_buttons a {
32
- height: 18px;
33
- margin: 5px 5px 0 0;
34
- padding: 4px 5px 2px;
35
- float: right;
36
- cursor: pointer;
37
- border-width: 1px;
38
- border-style: solid;
39
- -moz-border-radius: 3px 3px 0 0;
40
- -webkit-border-top-right-radius: 3px;
41
- -webkit-border-top-left-radius: 3px;
42
- -khtml-border-top-right-radius: 3px;
43
- -khtml-border-top-left-radius: 3px;
44
- border-top-right-radius: 3px;
45
- border-top-left-radius: 3px;
46
- background-color: #F1F1F1;
47
- border-color: #DFDFDF #DFDFDF #CCC;
48
- color: #999;
49
}
50
.editor_toggle_buttons a.active {
51
- border-color: #CCC #CCC #F4F4F4;
52
- background-color: #F4F4F4;
53
- color: #333;
54
}
55
.editor_toggle_buttons_legacy a.active {
56
border-color: #CCC #CCC #E9E9E9;
10
11
.editor_container {
12
background-color: #FFF;
13
+ border-color: #DEDEDE;
14
border-style: solid;
15
border-width: 1px;
16
border-collapse: separate;
17
border-top-right-radius: 3px;
18
border-top-left-radius: 3px;
19
+ padding: 0 1px 1px 1px;
20
+ clear: both;
21
}
22
.editor_toggle_buttons {
23
margin-right: 15px;
24
margin-top: 8px;
25
float: right;
26
}
27
.editor_toggle_buttons a {
28
+ background: none repeat scroll 0 0 #EBEBEB;
29
+ border: 1px solid #DEDEDE;
30
+ color: #777777;
31
+ cursor: pointer;
32
+ float: right;
33
+ font: 13px/19px "Open Sans",sans-serif;
34
+ margin: 5px 0 0 5px;
35
+ padding: 3px 8px 4px;
36
+ position: relative;
37
+ top: 1px;
38
}
39
.editor_toggle_buttons a.active {
40
+ background: none repeat scroll 0 0 #F5F5F5;
41
+ border-bottom: 0 none;
42
+ color: #555555;
43
+ height: 20px;
44
}
45
.editor_toggle_buttons_legacy a.active {
46
border-color: #CCC #CCC #E9E9E9;
black-studio-tinymce-widget.dev.js ADDED
@@ -0,0 +1,141 @@
1
+ // TinyMCE initialization parameters
2
+ var tinyMCEPreInit;
3
+ // Current editor
4
+ var wpActiveEditor;
5
+
6
+ (function( $ ) {
7
+ // Activate visual editor
8
+ function black_studio_activate_visual_editor(id) {
9
+ $( '#' + id ).addClass( 'mceEditor' );
10
+ if ( typeof tinyMCE == 'object' && typeof tinyMCE.execCommand == 'function' ) {
11
+ black_studio_deactivate_visual_editor( id );
12
+ tinyMCEPreInit.mceInit[id] = tinyMCEPreInit.mceInit['black-studio-tinymce-widget'];
13
+ tinyMCEPreInit.mceInit[id]['selector'] = '#' + id;
14
+ try {
15
+ // Instantiate new TinyMCE editor
16
+ tinymce.init( tinymce.extend( {}, tinyMCEPreInit.mceInit['black-studio-tinymce-widget'], tinyMCEPreInit.mceInit[id] ) );
17
+ tinyMCE.execCommand( 'mceAddControl', false, id );
18
+ } catch( e ) {
19
+ alert( e );
20
+ }
21
+ }
22
+ }
23
+ // Deactivate visual editor
24
+ function black_studio_deactivate_visual_editor( id ) {
25
+ if ( typeof tinyMCE == 'object' && typeof tinyMCE.execCommand == 'function' ) {
26
+ if ( typeof tinyMCE.get( id ) == 'object' && typeof tinyMCE.get( id ).getContent == 'function' ) {
27
+ var content = tinyMCE.get( id ).getContent();
28
+ // tinyMCE.execCommand('mceRemoveControl', false, id);
29
+ tinyMCE.get( id ).remove();
30
+ $( 'textarea#' + id ).val( content );
31
+ }
32
+ }
33
+ }
34
+ // Activate editor deferred (used upon opening the widget)
35
+ function black_studio_open_deferred_activate_visual_editor( id ) {
36
+ $( 'div.widget-inside:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]' ).each(function() {
37
+ // If textarea is visible and animation/ajax has completed (or in accessibility mode) then trigger a click to Visual button and enable the editor
38
+ if ( $('div.widget:has(#' + id + ') :animated' ).size() == 0 && typeof tinyMCE.get( id ) != 'object' && $( '#' + id ).is( ':visible' ) ) {
39
+ $( 'a[id^=widget-black-studio-tinymce][id$=visual]', $( this ).closest( 'div.widget-inside' ) ).click();
40
+ }
41
+ // Otherwise wait and retry later (animation ongoing)
42
+ else if ( typeof tinyMCE.get( id ) != 'object' ) {
43
+ setTimeout(function() {
44
+ black_studio_open_deferred_activate_visual_editor( id );
45
+ id = null;
46
+ }, 100 );
47
+ }
48
+ // If editor instance is already existing (i.e. dragged from another sidebar) just activate it
49
+ else {
50
+ $( 'a[id^=widget-black-studio-tinymce][id$=visual]', $( this ).closest( 'div.widget-inside' ) ).click();
51
+ }
52
+ });
53
+ }
54
+
55
+ // Activate editor deferred (used upon ajax requests)
56
+ function black_studio_ajax_deferred_activate_visual_editor( id ) {
57
+ $( 'div.widget-inside:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]' ).each(function() {
58
+ // If textarea is visible and animation/ajax has completed then trigger a click to Visual button and enable the editor
59
+ if ( $.active == 0 && typeof tinyMCE.get( id ) != 'object' && $( '#' + id ).is( ':visible' ) ) {
60
+ $( 'a[id^=widget-black-studio-tinymce][id$=visual]', $( this ).closest( 'div.widget-inside' ) ).click();
61
+ }
62
+ // Otherwise wait and retry later (animation ongoing)
63
+ else if ( $( 'div.widget:has(#' + id + ') div.widget-inside' ).is( ':visible' ) && typeof tinyMCE.get( id ) != 'object') {
64
+ setTimeout(function() {
65
+ black_studio_ajax_deferred_activate_visual_editor( id );
66
+ id=null;
67
+ }, 100 );
68
+ }
69
+ });
70
+ }
71
+
72
+
73
+
74
+ // Document ready stuff
75
+ $( document ).ready(function() {
76
+ // Event handler for widget opening button
77
+ $( document ).on( 'click', 'div.widget:has(textarea[id^=widget-black-studio-tinymce]) .widget-title, div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action', function( event ) {
78
+ //event.preventDefault();
79
+ var $widget = $( this ).closest( 'div.widget' );
80
+ var $text_area = $( 'textarea[id^=widget-black-studio-tinymce]', $widget );
81
+ // Event handler for widget saving button (for new instances)
82
+ $( 'input[name=savewidget]', $widget ).on( 'click', function( event ) {
83
+ var $widget = $( this ).closest( 'div.widget' )
84
+ var $text_area = $( 'textarea[id^=widget-black-studio-tinymce]', $widget );
85
+ if ( typeof tinyMCE.get( $text_area.attr( 'id' ) ) == 'object') {
86
+ black_studio_deactivate_visual_editor( $text_area.attr( 'id' ) );
87
+ }
88
+ // Event handler for ajax complete
89
+ $( this ).unbind( 'ajaxSuccess' ).ajaxSuccess( function( event, xhr, settings ) {
90
+ var $text_area = $( 'textarea[id^=widget-black-studio-tinymce]', $( this ).closest( 'div.widget-inside') );
91
+ black_studio_ajax_deferred_activate_visual_editor( $text_area.attr( 'id' ) );
92
+ });
93
+ });
94
+ $( '#wpbody-content' ).css( 'overflow', 'visible' ); // needed for small screens
95
+ $widget.css( 'position', 'relative' ).css( 'z-index', '100' ); // needed for small screens
96
+ black_studio_open_deferred_activate_visual_editor( $text_area.attr( 'id' ) );
97
+ $( '.insert-media', $widget ).data( 'editor', $text_area.attr( 'id' ) );
98
+ });
99
+ // Event handler for widget saving button (for existing instances)
100
+ $( 'div.widget[id*=black-studio-tinymce] input[name=savewidget]').on( 'click', function( event ) {
101
+ var $widget = $( this ).closest( 'div.widget' )
102
+ var $text_area = $( 'textarea[id^=widget-black-studio-tinymce]', $widget );
103
+ if ( typeof tinyMCE.get( $text_area.attr( 'id' ) ) == 'object') {
104
+ black_studio_deactivate_visual_editor( $text_area.attr( 'id' ) );
105
+ }
106
+ // Event handler for ajax complete
107
+ $( this ).unbind( 'ajaxSuccess' ).ajaxSuccess( function( event, xhr, settings ) {
108
+ var $text_area = $( 'textarea[id^=widget-black-studio-tinymce]', $( this ).closest( 'div.widget-inside' ) );
109
+ black_studio_ajax_deferred_activate_visual_editor( $text_area.attr( 'id' ) );
110
+ });
111
+ });
112
+ // Event handler for visual switch button
113
+ $( document ).on( 'click', 'a[id^=widget-black-studio-tinymce][id$=visual]', function( event ) {
114
+ //event.preventDefault();
115
+ var $widget_inside = $( this ).closest( 'div.widget-inside,div.panel-dialog' );
116
+ $( 'input[id^=widget-black-studio-tinymce][id$=type]', $widget_inside ).val( 'visual' );
117
+ $( this ).addClass( 'active' );
118
+ $( 'a[id^=widget-black-studio-tinymce][id$=html]', $widget_inside ).removeClass( 'active' );
119
+ black_studio_activate_visual_editor( $( 'textarea[id^=widget-black-studio-tinymce]', $widget_inside ).attr( 'id' ) );
120
+ });
121
+ // Event handler for html switch button
122
+ $( document ).on( 'click', 'a[id^=widget-black-studio-tinymce][id$=html]', function( event ) {
123
+ //event.preventDefault();
124
+ var $widget_inside = $( this ).closest( 'div.widget-inside,div.panel-dialog' );
125
+ $( 'input[id^=widget-black-studio-tinymce][id$=type]', $widget_inside ).val( 'html' );
126
+ $( this ).addClass( 'active' );
127
+ $( 'a[id^=widget-black-studio-tinymce][id$=visual]', $widget_inside ).removeClass( 'active' );
128
+ black_studio_deactivate_visual_editor( $( 'textarea[id^=widget-black-studio-tinymce]', $widget_inside ).attr( 'id' ) );
129
+ });
130
+ // Set wpActiveEditor variables used when adding media from media library dialog
131
+ $( document ).on( 'click', '.editor_media_buttons a', function() {
132
+ var $widget_inside = $( this ).closest( 'div.widget-inside' );
133
+ wpActiveEditor = $( 'textarea[id^=widget-black-studio-tinymce]', $widget_inside ).attr( 'id' );
134
+ });
135
+ // Activate editor when in accessibility mode
136
+ if ( $( 'body.widgets_access' ).size() > 0) {
137
+ var $text_area = $( 'textarea[id^=widget-black-studio-tinymce]' );
138
+ black_studio_open_deferred_activate_visual_editor( $text_area.attr( 'id' ) );
139
+ }
140
+ });
141
+ })( jQuery ); // end self-invoked wrapper function
black-studio-tinymce-widget.js CHANGED
@@ -1 +1 @@
1
- eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('8 D;8 12;(6(c){6 d(g){c("#"+g).T("15");w(u(q)=="y"&&u(q.R)=="6"){b(g);D.I[g]=D.I["4-5-3-2"];D.I[g]["1a"]=g;18{3.1j(3.1b({},D.I["4-5-3-2"],D.I[g]))}1h(f){1e(f)}}}6 b(g){w(u(q)=="y"&&u(q.R)=="6"){w(u(q.A(g))=="y"){8 f=q.A(g).1d();q.R("1f",1g,g);c("t#"+g).Q(f)}}}6 a(f){c("7.2-v:F(#"+f+") C[1^=2-4-5-3][1$=K][10=B]").U(6(){w(c("7.2:F(#"+f+") :1i").V()==0&&u(q.A(f))!="y"&&c("#"+f).O(":J")){c("a[1^=2-4-5-3][1$=B]",c(9).s("7.2-v")).x()}N{w(u(q.A(f))!="y"){Z(6(){a(f);f=Y},P)}N{c("a[1^=2-4-5-3][1$=B]",c(9).s("7.2-v")).x()}}})}6 e(f){c("7.2-v:F(#"+f+") C[1^=2-4-5-3][1$=K][10=B]").U(6(){w(c.G==0&&u(q.A(f))!="y"&&c("#"+f).O(":J")){c("a[1^=2-4-5-3][1$=B]",c(9).s("7.2-v")).x()}N{w(c("7.2:F(#"+f+") 7.2-v").O(":J")&&u(q.A(f))!="y"){Z(6(){e(f);f=Y},P)}}})}c(H).17(6(){c(H).E("x","7.2:F(t[1^=2-4-5-3]) a.2-19",6(g){8 i=c(9).s("7.2");8 h=c("t[1^=2-4-5-3]",i);c("C[X=W]",i).E("x",6(j){8 l=c(9).s("7.2");8 k=c("t[1^=2-4-5-3]",l);w(u(q.A(k.r("1")))=="y"){b(k.r("1"))}c(9).11("L").L(6(n,o,m){8 p=c("t[1^=2-4-5-3]",c(9).s("7.2-v"));e(p.r("1"))})});c("#16-14").M("1c","J");i.M("1n","1u").M("z-1t","P");a(h.r("1"));c(".1r-1k",i).1m("1l",h.r("1"))});c("7.2[1*=4-5-3] C[X=W]").E("x",6(g){8 i=c(9).s("7.2");8 h=c("t[1^=2-4-5-3]",i);w(u(q.A(h.r("1")))=="y"){b(h.r("1"))}c(9).11("L").L(6(k,l,j){8 m=c("t[1^=2-4-5-3]",c(9).s("7.2-v"));e(m.r("1"))})});c(H).E("x","a[1^=2-4-5-3][1$=B]",6(g){8 h=c(9).s("7.2-v");c("C[1^=2-4-5-3][1$=K]",h).Q("B");c(9).T("G");c("a[1^=2-4-5-3][1$=S]",h).13("G");d(c("t[1^=2-4-5-3]",h).r("1"))});c(H).E("x","a[1^=2-4-5-3][1$=S]",6(g){8 h=c(9).s("7.2-v");c("C[1^=2-4-5-3][1$=K]",h).Q("S");c(9).T("G");c("a[1^=2-4-5-3][1$=B]",h).13("G");b(c("t[1^=2-4-5-3]",h).r("1"))});c(H).E("x",".1o a",6(){8 g=c(9).s("7.2-v");12=c("t[1^=2-4-5-3]",g).r("1")});w(c("1p.1q").V()>0){8 f=c("t[1^=2-4-5-3]");a(f.r("1"))}})})(1s);',62,93,'|id|widget|tinymce|black|studio|function|div|var|this|||||||||||||||||tinyMCE|attr|closest|textarea|typeof|inside|if|click|object||get|visual|input|tinyMCEPreInit|on|has|active|document|mceInit|visible|type|ajaxSuccess|css|else|is|100|val|execCommand|html|addClass|each|size|savewidget|name|null|setTimeout|value|unbind|wpActiveEditor|removeClass|content|mceEditor|wpbody|ready|try|action|elements|extend|overflow|getContent|alert|mceRemoveControl|false|catch|animated|init|media|editor|data|position|editor_media_buttons|body|widgets_access|insert|jQuery|index|relative'.split('|'),0,{}))
1
+ var tinyMCEPreInit;var wpActiveEditor;(function(c){function d(g){c("#"+g).addClass("mceEditor");if(typeof tinyMCE=="object"&&typeof tinyMCE.execCommand=="function"){b(g);tinyMCEPreInit.mceInit[g]=tinyMCEPreInit.mceInit["black-studio-tinymce-widget"];tinyMCEPreInit.mceInit[g]["selector"]="#"+g;try{tinymce.init(tinymce.extend({},tinyMCEPreInit.mceInit["black-studio-tinymce-widget"],tinyMCEPreInit.mceInit[g]));tinyMCE.execCommand("mceAddControl",false,g)}catch(f){alert(f)}}}function b(g){if(typeof tinyMCE=="object"&&typeof tinyMCE.execCommand=="function"){if(typeof tinyMCE.get(g)=="object"&&typeof tinyMCE.get(g).getContent=="function"){var f=tinyMCE.get(g).getContent();tinyMCE.get(g).remove();c("textarea#"+g).val(f)}}}function a(f){c("div.widget-inside:has(#"+f+") input[id^=widget-black-studio-tinymce][id$=type][value=visual]").each(function(){if(c("div.widget:has(#"+f+") :animated").size()==0&&typeof tinyMCE.get(f)!="object"&&c("#"+f).is(":visible")){c("a[id^=widget-black-studio-tinymce][id$=visual]",c(this).closest("div.widget-inside")).click()}else{if(typeof tinyMCE.get(f)!="object"){setTimeout(function(){a(f);f=null},100)}else{c("a[id^=widget-black-studio-tinymce][id$=visual]",c(this).closest("div.widget-inside")).click()}}})}function e(f){c("div.widget-inside:has(#"+f+") input[id^=widget-black-studio-tinymce][id$=type][value=visual]").each(function(){if(c.active==0&&typeof tinyMCE.get(f)!="object"&&c("#"+f).is(":visible")){c("a[id^=widget-black-studio-tinymce][id$=visual]",c(this).closest("div.widget-inside")).click()}else{if(c("div.widget:has(#"+f+") div.widget-inside").is(":visible")&&typeof tinyMCE.get(f)!="object"){setTimeout(function(){e(f);f=null},100)}}})}c(document).ready(function(){c(document).on("click","div.widget:has(textarea[id^=widget-black-studio-tinymce]) .widget-title, div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action",function(g){var i=c(this).closest("div.widget");var h=c("textarea[id^=widget-black-studio-tinymce]",i);c("input[name=savewidget]",i).on("click",function(j){var l=c(this).closest("div.widget");var k=c("textarea[id^=widget-black-studio-tinymce]",l);if(typeof tinyMCE.get(k.attr("id"))=="object"){b(k.attr("id"))}c(this).unbind("ajaxSuccess").ajaxSuccess(function(n,o,m){var p=c("textarea[id^=widget-black-studio-tinymce]",c(this).closest("div.widget-inside"));e(p.attr("id"))})});c("#wpbody-content").css("overflow","visible");i.css("position","relative").css("z-index","100");a(h.attr("id"));c(".insert-media",i).data("editor",h.attr("id"))});c("div.widget[id*=black-studio-tinymce] input[name=savewidget]").on("click",function(g){var i=c(this).closest("div.widget");var h=c("textarea[id^=widget-black-studio-tinymce]",i);if(typeof tinyMCE.get(h.attr("id"))=="object"){b(h.attr("id"))}c(this).unbind("ajaxSuccess").ajaxSuccess(function(k,l,j){var m=c("textarea[id^=widget-black-studio-tinymce]",c(this).closest("div.widget-inside"));e(m.attr("id"))})});c(document).on("click","a[id^=widget-black-studio-tinymce][id$=visual]",function(g){var h=c(this).closest("div.widget-inside,div.panel-dialog");c("input[id^=widget-black-studio-tinymce][id$=type]",h).val("visual");c(this).addClass("active");c("a[id^=widget-black-studio-tinymce][id$=html]",h).removeClass("active");d(c("textarea[id^=widget-black-studio-tinymce]",h).attr("id"))});c(document).on("click","a[id^=widget-black-studio-tinymce][id$=html]",function(g){var h=c(this).closest("div.widget-inside,div.panel-dialog");c("input[id^=widget-black-studio-tinymce][id$=type]",h).val("html");c(this).addClass("active");c("a[id^=widget-black-studio-tinymce][id$=visual]",h).removeClass("active");b(c("textarea[id^=widget-black-studio-tinymce]",h).attr("id"))});c(document).on("click",".editor_media_buttons a",function(){var g=c(this).closest("div.widget-inside");wpActiveEditor=c("textarea[id^=widget-black-studio-tinymce]",g).attr("id")});if(c("body.widgets_access").size()>0){var f=c("textarea[id^=widget-black-studio-tinymce]");a(f.attr("id"))}})})(jQuery);
black-studio-tinymce-widget.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Black Studio TinyMCE Widget
4
Plugin URI: http://wordpress.org/extend/plugins/black-studio-tinymce-widget/
5
Description: Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
6
- Version: 1.2.0
7
Author: Black Studio
8
Author URI: http://www.blackstudio.it
9
License: GPL2
@@ -11,65 +11,70 @@ License: GPL2
11
12
global $black_studio_tinymce_widget_version;
13
global $black_studio_tinymce_widget_dev_mode;
14
- $black_studio_tinymce_widget_version = "1.2.0"; // This is used internally - should be the same reported on the plugin header
15
$black_studio_tinymce_widget_dev_mode = false;
16
17
/* Widget class */
18
class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
19
20
function __construct() {
21
- $widget_ops = array('classname' => 'widget_black_studio_tinymce', 'description' => __('Arbitrary text or HTML with visual editor', 'black-studio-tinymce-widget'));
22
- $control_ops = array('width' => 800, 'height' => 800);
23
- parent::__construct('black-studio-tinymce', __('Black Studio TinyMCE', 'black-studio-tinymce-widget'), $widget_ops, $control_ops);
24
}
25
26
function widget( $args, $instance ) {
27
- if ( get_option('embed_autourls') ) {
28
$wp_embed = $GLOBALS['wp_embed'];
29
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
30
add_filter( 'widget_text', array( $wp_embed, 'autoembed' ), 8 );
31
}
32
- extract($args);
33
- $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
34
$text = apply_filters( 'widget_text', $instance['text'], $instance );
35
- if( function_exists( 'icl_t' )) {
36
$title = icl_t( "Widgets", 'widget title - ' . md5 ( $title ), $title );
37
$text = icl_t( "Widgets", 'widget body - ' . $this->id_base . '-' . $this->number, $text );
38
}
39
$text = do_shortcode( $text );
40
echo $before_widget;
41
- if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
42
<div class="textwidget"><?php echo $text; ?></div>
43
- <?php
44
echo $after_widget;
45
}
46
47
function update( $new_instance, $old_instance ) {
48
$instance = $old_instance;
49
- $instance['title'] = strip_tags($new_instance['title']);
50
- if ( current_user_can('unfiltered_html') )
51
$instance['text'] = $new_instance['text'];
52
- else
53
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
54
- $instance['type'] = strip_tags($new_instance['type']);
55
- if( function_exists( 'icl_register_string' )) {
56
- //icl_register_string( "Widgets", 'widget title - ' . $this->id_base . '-' . $this->number /* md5 ( apply_filters( 'widget_title', $instance['title'] ))*/, apply_filters( 'widget_title', $instance['title'] )); // This is handled automatically by WPML
57
- icl_register_string( "Widgets", 'widget body - ' . $this->id_base . '-' . $this->number /* md5 ( apply_filters( 'widget_text', $instance['text'] ))*/, apply_filters( 'widget_text', $instance['text'] ));
58
}
59
return $instance;
60
}
61
62
function form( $instance ) {
63
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'type' => 'visual' ) );
64
- $title = strip_tags($instance['title']);
65
- if (function_exists('esc_textarea')) {
66
- $text = esc_textarea($instance['text']);
67
}
68
else {
69
$text = stripslashes( wp_filter_post_kses( addslashes( $instance['text'] ) ) );
70
}
71
- $type = esc_attr($instance['type']);
72
- if (get_bloginfo('version') < "3.5") {
73
$toggle_buttons_extra_class = "editor_toggle_buttons_legacy";
74
$media_buttons_extra_class = "editor_media_buttons_legacy";
75
}
@@ -78,89 +83,90 @@ class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
78
$media_buttons_extra_class = "wp-media-buttons";
79
}
80
?>
81
- <input id="<?php echo $this->get_field_id('type'); ?>" name="<?php echo $this->get_field_name('type'); ?>" type="hidden" value="<?php echo esc_attr($type); ?>" />
82
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
83
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
84
- <div class="editor_toggle_buttons hide-if-no-js <?php echo $toggle_buttons_extra_class; ?>">
85
- <a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-html"<?php if ($type == 'html') {?> class="active"<?php }?>><?php _e('HTML'); ?></a>
86
- <a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-visual"<?php if($type == 'visual') {?> class="active"<?php }?>><?php _e('Visual'); ?></a>
87
- </div>
88
<div class="editor_media_buttons hide-if-no-js <?php echo $media_buttons_extra_class; ?>">
89
<?php do_action( 'media_buttons' ); ?>
90
</div>
91
<div class="editor_container">
92
- <textarea class="widefat" rows="20" cols="40" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
93
- </div>
94
- <div class="editor_links"><a href="http://www.blackstudio.it/en/wordpress-plugins/black-studio-tinymce-widget/" target="_blank"><?php echo __('Donate', 'black-studio-tinymce-widget'); ?></a> | <a href="http://wordpress.org/support/plugin/black-studio-tinymce-widget" target="_blank"><?php echo __('Support', 'black-studio-tinymce-widget'); ?></a> | <a href="https://twitter.com/blackstudioita" target="_blank"><?php echo __('Follow', 'black-studio-tinymce-widget'); ?></a></div>
95
- <?php
96
}
97
}
98
99
/* Load localization */
100
- load_plugin_textdomain('black-studio-tinymce-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
101
102
/* Widget initialization */
103
- add_action('widgets_init', 'black_studio_tinymce_widgets_init');
104
function black_studio_tinymce_widgets_init() {
105
- if ( !is_blog_installed() )
106
return;
107
- register_widget('WP_Widget_Black_Studio_TinyMCE');
108
}
109
110
/* Add actions and filters (only in widgets admin page) */
111
- add_action('admin_init', 'black_studio_tinymce_admin_init');
112
function black_studio_tinymce_admin_init() {
113
global $pagenow;
114
$load_editor = false;
115
- if ($pagenow == "widgets.php") {
116
$load_editor = true;
117
}
118
// Compatibility for WP Page Widget plugin
119
- if (is_plugin_active('wp-page-widget/wp-page-widgets.php') && (
120
- (in_array($pagenow, array('post-new.php', 'post.php'))) ||
121
- (in_array($pagenow, array('edit-tags.php')) && isset($_GET['action']) && $_GET['action'] == 'edit') ||
122
- (in_array($pagenow, array('admin.php')) && isset($_GET['page']) && in_array($_GET['page'], array('pw-front-page', 'pw-search-page')))
123
- )) {
124
$load_editor = true;
125
}
126
- if ($load_editor) {
127
- add_action( 'admin_head', 'black_studio_tinymce_load_tiny_mce');
128
- add_filter( 'tiny_mce_before_init', 'black_studio_tinymce_init_editor', 20);
129
- add_action( 'admin_print_scripts', 'black_studio_tinymce_scripts');
130
- add_action( 'admin_print_styles', 'black_studio_tinymce_styles');
131
- add_action( 'admin_print_footer_scripts', 'black_studio_tinymce_footer_scripts');
132
}
133
}
134
135
/* Instantiate tinyMCE editor */
136
function black_studio_tinymce_load_tiny_mce() {
137
// Remove filters added from "After the deadline" plugin, to avoid conflicts
138
- remove_filter( 'mce_external_plugins', 'add_AtD_tinymce_plugin' );
139
- remove_filter( 'mce_buttons', 'register_AtD_button' );
140
- remove_filter( 'tiny_mce_before_init', 'AtD_change_mce_settings' );
141
// Add support for thickbox media dialog
142
add_thickbox();
143
// New media modal dialog (WP 3.5+)
144
- if (function_exists('wp_enqueue_media')) {
145
wp_enqueue_media();
146
}
147
}
148
149
/* TinyMCE setup customization */
150
- function black_studio_tinymce_init_editor($initArray) {
151
// Remove WP fullscreen mode and set the native tinyMCE fullscreen mode
152
- if (get_bloginfo('version') < "3.3") {
153
$plugins = explode(',', $initArray['plugins']);
154
- if (isset($plugins['wpfullscreen'])) {
155
- unset($plugins['wpfullscreen']);
156
}
157
- if (!isset($plugins['fullscreen'])) {
158
$plugins[] = 'fullscreen';
159
}
160
- $initArray['plugins'] = implode(',', $plugins);
161
}
162
- // Remove the "More" toolbar button
163
- $initArray['theme_advanced_buttons1'] = str_replace(',wp_more', '', $initArray['theme_advanced_buttons1']);
164
// Do not remove linebreaks
165
$initArray['remove_linebreaks'] = false;
166
// Convert newline characters to BR tags
@@ -183,72 +189,81 @@ function black_studio_tinymce_init_editor($initArray) {
183
function black_studio_tinymce_scripts() {
184
global $black_studio_tinymce_widget_version, $black_studio_tinymce_widget_dev_mode;
185
wp_enqueue_script('media-upload');
186
- if (get_bloginfo('version') >= "3.3") {
187
- wp_enqueue_script('wplink');
188
- wp_enqueue_script('wpdialogs-popup');
189
- wp_enqueue_script('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget'.($black_studio_tinymce_widget_dev_mode?'.dev':'').'.js', __FILE__), array('jquery'), $black_studio_tinymce_widget_version);
190
}
191
else {
192
- wp_enqueue_script('black-studio-tinymce-widget-legacy', plugins_url('black-studio-tinymce-widget-legacy'.($black_studio_tinymce_widget_dev_mode?'.dev':'').'.js', __FILE__), array('jquery'), $black_studio_tinymce_widget_version);
193
}
194
}
195
196
/* Widget css loading */
197
function black_studio_tinymce_styles() {
198
global $black_studio_tinymce_widget_version;
199
- if (get_bloginfo('version') < "3.3") {
200
- wp_enqueue_style('thickbox');
201
}
202
else {
203
- wp_enqueue_style('wp-jquery-ui-dialog');
204
}
205
- wp_print_styles('editor-buttons');
206
- wp_enqueue_style('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget.css', __FILE__), array(), $black_studio_tinymce_widget_version);
207
}
208
209
210
/* Footer script */
211
function black_studio_tinymce_footer_scripts() {
212
// Setup for WP 3.1 and previous versions
213
- if (get_bloginfo('version') < "3.2") {
214
- if (function_exists('wp_tiny_mce')) {
215
- wp_tiny_mce(false, array());
216
}
217
- if(function_exists('wp_tiny_mce_preload_dialogs')) {
218
wp_tiny_mce_preload_dialogs();
219
}
220
}
221
// Setup for WP 3.2.x
222
- else if (get_bloginfo('version') < "3.3") {
223
- if (function_exists('wp_tiny_mce')) {
224
- wp_tiny_mce(false, array());
225
}
226
- if(function_exists('wp_preload_dialogs')) {
227
wp_preload_dialogs( array( 'plugins' => 'wpdialogs,wplink,wpfullscreen' ) );
228
}
229
}
230
// Setup for WP 3.3 - New Editor API
231
else {
232
- wp_editor('', 'black-studio-tinymce-widget');
233
}
234
}
235
236
/* Hack needed to enable full media options when adding content form media library */
237
/* (this is done excluding post_id parameter in Thickbox iframe url) */
238
- add_filter('_upload_iframe_src', 'black_studio_tinymce_upload_iframe_src');
239
- function black_studio_tinymce_upload_iframe_src ($upload_iframe_src) {
240
global $pagenow;
241
- if ($pagenow == "widgets.php" || ($pagenow == "admin-ajax.php" && isset ($_POST['id_base']) && $_POST['id_base'] == "black-studio-tinymce") ) {
242
- $upload_iframe_src = str_replace('post_id=0', '', $upload_iframe_src);
243
}
244
return $upload_iframe_src;
245
}
246
247
/* Hack for widgets accessibility mode */
248
- add_filter('wp_default_editor', 'black_studio_tinymce_editor_accessibility_mode');
249
function black_studio_tinymce_editor_accessibility_mode($editor) {
250
global $pagenow;
251
- if ($pagenow == "widgets.php" && isset($_GET['editwidget']) && strpos($_GET['editwidget'], 'black-studio-tinymce') === 0 ) {
252
$editor = 'html';
253
}
254
return $editor;
3
Plugin Name: Black Studio TinyMCE Widget
4
Plugin URI: http://wordpress.org/extend/plugins/black-studio-tinymce-widget/
5
Description: Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
6
+ Version: 1.3.0
7
Author: Black Studio
8
Author URI: http://www.blackstudio.it
9
License: GPL2
11
12
global $black_studio_tinymce_widget_version;
13
global $black_studio_tinymce_widget_dev_mode;
14
+ $black_studio_tinymce_widget_version = "1.3.0"; // This is used internally - should be the same reported on the plugin header
15
$black_studio_tinymce_widget_dev_mode = false;
16
17
/* Widget class */
18
class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
19
20
function __construct() {
21
+ $widget_ops = array( 'classname' => 'widget_black_studio_tinymce', 'description' => __( 'Arbitrary text or HTML with visual editor', 'black-studio-tinymce-widget' ) );
22
+ $control_ops = array( 'width' => 800, 'height' => 800 );
23
+ parent::__construct( 'black-studio-tinymce', __( 'Black Studio TinyMCE', 'black-studio-tinymce-widget' ), $widget_ops, $control_ops );
24
}
25
26
function widget( $args, $instance ) {
27
+ if ( get_option( 'embed_autourls' ) ) {
28
$wp_embed = $GLOBALS['wp_embed'];
29
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
30
add_filter( 'widget_text', array( $wp_embed, 'autoembed' ), 8 );
31
}
32
+ extract( $args );
33
+ $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base );
34
$text = apply_filters( 'widget_text', $instance['text'], $instance );
35
+ if ( function_exists( 'icl_t' ) ) {
36
$title = icl_t( "Widgets", 'widget title - ' . md5 ( $title ), $title );
37
$text = icl_t( "Widgets", 'widget body - ' . $this->id_base . '-' . $this->number, $text );
38
}
39
$text = do_shortcode( $text );
40
echo $before_widget;
41
+ if ( ! empty( $title ) ) {
42
+ echo $before_title . $title . $after_title;
43
+ }
44
+ ?>
45
<div class="textwidget"><?php echo $text; ?></div>
46
+ <?php
47
echo $after_widget;
48
}
49
50
function update( $new_instance, $old_instance ) {
51
$instance = $old_instance;
52
+ $instance['title'] = strip_tags( $new_instance['title'] );
53
+ if ( current_user_can('unfiltered_html') ) {
54
$instance['text'] = $new_instance['text'];
55
+ }
56
+ else {
57
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
58
+ }
59
+ $instance['type'] = strip_tags( $new_instance['type'] );
60
+ if ( function_exists( 'icl_register_string' )) {
61
+ //icl_register_string( "Widgets", 'widget title - ' . $this->id_base . '-' . $this->number /* md5 ( apply_filters( 'widget_title', $instance['title'] ))*/, apply_filters( 'widget_title', $instance['title'] ) ); // This is handled automatically by WPML
62
+ icl_register_string( "Widgets", 'widget body - ' . $this->id_base . '-' . $this->number, apply_filters( 'widget_text', $instance['text'] ) );
63
}
64
return $instance;
65
}
66
67
function form( $instance ) {
68
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'type' => 'visual' ) );
69
+ $title = strip_tags( $instance['title'] );
70
+ if ( function_exists( 'esc_textarea' ) ) {
71
+ $text = esc_textarea( $instance['text'] );
72
}
73
else {
74
$text = stripslashes( wp_filter_post_kses( addslashes( $instance['text'] ) ) );
75
}
76
+ $type = esc_attr( $instance['type'] );
77
+ if ( get_bloginfo( 'version' ) < "3.5" ) {
78
$toggle_buttons_extra_class = "editor_toggle_buttons_legacy";
79
$media_buttons_extra_class = "editor_media_buttons_legacy";
80
}
83
$media_buttons_extra_class = "wp-media-buttons";
84
}
85
?>
86
+ <input id="<?php echo $this->get_field_id( 'type' ); ?>" name="<?php echo $this->get_field_name( 'type' ); ?>" type="hidden" value="<?php echo esc_attr( $type ); ?>" />
87
+ <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
88
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
89
+ <div class="editor_toggle_buttons hide-if-no-js <?php echo $toggle_buttons_extra_class; ?>">
90
+ <a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-html"<?php if ( $type == 'html' ) {?> class="active"<?php }?>><?php _e( 'HTML' ); ?></a>
91
+ <a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-visual"<?php if ( $type == 'visual' ) {?> class="active"<?php }?>><?php _e(' Visual' ); ?></a>
92
+ </div>
93
<div class="editor_media_buttons hide-if-no-js <?php echo $media_buttons_extra_class; ?>">
94
<?php do_action( 'media_buttons' ); ?>
95
</div>
96
<div class="editor_container">
97
+ <textarea class="widefat" rows="20" cols="40" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
98
+ </div>
99
+ <div class="editor_links"><a href="http://www.blackstudio.it/en/wordpress-plugins/black-studio-tinymce-widget/" target="_blank"><?php echo __( 'Donate', 'black-studio-tinymce-widget' ); ?></a> | <a href="http://wordpress.org/support/plugin/black-studio-tinymce-widget" target="_blank"><?php echo __( 'Support', 'black-studio-tinymce-widget' ); ?></a> | <a href="https://twitter.com/blackstudioita" target="_blank"><?php echo __( 'Follow', 'black-studio-tinymce-widget' ); ?></a></div>
100
+ <?php
101
}
102
}
103
104
/* Load localization */
105
+ load_plugin_textdomain( 'black-studio-tinymce-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
106
107
/* Widget initialization */
108
+ add_action( 'widgets_init', 'black_studio_tinymce_widgets_init' );
109
function black_studio_tinymce_widgets_init() {
110
+ if ( ! is_blog_installed() )
111
return;
112
+ register_widget( 'WP_Widget_Black_Studio_TinyMCE' );
113
}
114
115
/* Add actions and filters (only in widgets admin page) */
116
+ add_action( 'admin_init', 'black_studio_tinymce_admin_init' );
117
function black_studio_tinymce_admin_init() {
118
global $pagenow;
119
$load_editor = false;
120
+ if ( $pagenow == "widgets.php" ) {
121
$load_editor = true;
122
}
123
// Compatibility for WP Page Widget plugin
124
+ if ( is_plugin_active('wp-page-widget/wp-page-widgets.php' ) && (
125
+ ( in_array( $pagenow, array( 'post-new.php', 'post.php') ) ) ||
126
+ ( in_array( $pagenow, array( 'edit-tags.php' ) ) && isset( $_GET['action'] ) && $_GET['action'] == 'edit' ) ||
127
+ ( in_array( $pagenow, array( 'admin.php' ) ) && isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'pw-front-page', 'pw-search-page' ) ) )
128
+ ) ) {
129
$load_editor = true;
130
}
131
+ if ( $load_editor ) {
132
+ add_action( 'admin_head', 'black_studio_tinymce_load_tiny_mce' );
133
+ add_filter( 'tiny_mce_before_init', 'black_studio_tinymce_init_editor', 20 );
134
+ add_action( 'admin_print_scripts', 'black_studio_tinymce_scripts' );
135
+ add_action( 'admin_print_styles', 'black_studio_tinymce_styles' );
136
+ add_action( 'admin_print_footer_scripts', 'black_studio_tinymce_footer_scripts' );
137
+ add_filter( 'atd_load_scripts', '__return_true'); // Compatibility with Jetpack After the deadline
138
}
139
}
140
141
/* Instantiate tinyMCE editor */
142
function black_studio_tinymce_load_tiny_mce() {
143
// Remove filters added from "After the deadline" plugin, to avoid conflicts
144
// Add support for thickbox media dialog
145
add_thickbox();
146
// New media modal dialog (WP 3.5+)
147
+ if ( function_exists( 'wp_enqueue_media' ) ) {
148
wp_enqueue_media();
149
}
150
}
151
152
/* TinyMCE setup customization */
153
+ function black_studio_tinymce_init_editor( $initArray ) {
154
+ global $pagenow;
155
// Remove WP fullscreen mode and set the native tinyMCE fullscreen mode
156
+ if ( get_bloginfo( 'version' ) < "3.3" ) {
157
$plugins = explode(',', $initArray['plugins']);
158
+ if ( isset( $plugins['wpfullscreen'] ) ) {
159
+ unset( $plugins['wpfullscreen'] );
160
}
161
+ if ( ! isset( $plugins['fullscreen'] ) ) {
162
$plugins[] = 'fullscreen';
163
}
164
+ $initArray['plugins'] = implode( ',', $plugins );
165
+ }
166
+ // Remove the "More" toolbar button (only in widget screen)
167
+ if ( $pagenow == "widgets.php" ) {
168
+ $initArray['theme_advanced_buttons1'] = str_replace( ',wp_more', '', $initArray['theme_advanced_buttons1'] );
169
}
170
// Do not remove linebreaks
171
$initArray['remove_linebreaks'] = false;
172
// Convert newline characters to BR tags
189
function black_studio_tinymce_scripts() {
190
global $black_studio_tinymce_widget_version, $black_studio_tinymce_widget_dev_mode;
191
wp_enqueue_script('media-upload');
192
+ if ( get_bloginfo( 'version' ) >= "3.3" ) {
193
+ wp_enqueue_script( 'wplink' );
194
+ wp_enqueue_script( 'wpdialogs-popup' );
195
+ wp_enqueue_script( 'black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget' . ($black_studio_tinymce_widget_dev_mode ? '.dev' : '' ) . '.js', __FILE__ ), array( 'jquery' ), $black_studio_tinymce_widget_version );
196
}
197
else {
198
+ wp_enqueue_script( 'black-studio-tinymce-widget-legacy', plugins_url('black-studio-tinymce-widget-legacy' . ($black_studio_tinymce_widget_dev_mode? '.dev' : '' ) . '.js', __FILE__ ), array( 'jquery' ), $black_studio_tinymce_widget_version );
199
}
200
}
201
202
/* Widget css loading */
203
function black_studio_tinymce_styles() {
204
global $black_studio_tinymce_widget_version;
205
+ if ( get_bloginfo( 'version' ) < "3.3" ) {
206
+ wp_enqueue_style( 'thickbox' );
207
}
208
else {
209
+ wp_enqueue_style( 'wp-jquery-ui-dialog' );
210
}
211
+ wp_print_styles( 'editor-buttons' );
212
+ wp_enqueue_style( 'black-studio-tinymce-widget', plugins_url( 'black-studio-tinymce-widget.css', __FILE__ ), array(), $black_studio_tinymce_widget_version );
213
}
214
215
216
/* Footer script */
217
function black_studio_tinymce_footer_scripts() {
218
// Setup for WP 3.1 and previous versions
219
+ if ( get_bloginfo( 'version' ) < "3.2" ) {
220
+ if ( function_exists( 'wp_tiny_mce' ) ) {
221
+ wp_tiny_mce( false, array() );
222
}
223
+ if ( function_exists( 'wp_tiny_mce_preload_dialogs' ) ) {
224
wp_tiny_mce_preload_dialogs();
225
}
226
}
227
// Setup for WP 3.2.x
228
+ else if ( get_bloginfo( 'version' ) < "3.3" ) {
229
+ if ( function_exists( 'wp_tiny_mce' ) ) {
230
+ wp_tiny_mce( false, array() );
231
}
232
+ if ( function_exists( 'wp_preload_dialogs') ) {
233
wp_preload_dialogs( array( 'plugins' => 'wpdialogs,wplink,wpfullscreen' ) );
234
}
235
}
236
// Setup for WP 3.3 - New Editor API
237
else {
238
+ wp_editor( '', 'black-studio-tinymce-widget' );
239
+ }
240
+ }
241
+
242
+ /* Support for Smilies */
243
+ add_filter( 'widget_text', 'black_studio_tinymce_apply_smilies_to_widget_text' );
244
+ function black_studio_tinymce_apply_smilies_to_widget_text( $text ) {
245
+ if ( get_option( 'use_smilies' ) ) {
246
+ $text = convert_smilies( $text );
247
}
248
+ return $text;
249
}
250
251
/* Hack needed to enable full media options when adding content form media library */
252
/* (this is done excluding post_id parameter in Thickbox iframe url) */
253
+ add_filter( '_upload_iframe_src', 'black_studio_tinymce_upload_iframe_src' );
254
+ function black_studio_tinymce_upload_iframe_src ( $upload_iframe_src ) {
255
global $pagenow;
256
+ if ( $pagenow == "widgets.php" || ( $pagenow == "admin-ajax.php" && isset ( $_POST['id_base'] ) && $_POST['id_base'] == "black-studio-tinymce" ) ) {
257
+ $upload_iframe_src = str_replace( 'post_id=0', '', $upload_iframe_src );
258
}
259
return $upload_iframe_src;
260
}
261
262
/* Hack for widgets accessibility mode */
263
+ add_filter( 'wp_default_editor', 'black_studio_tinymce_editor_accessibility_mode' );
264
function black_studio_tinymce_editor_accessibility_mode($editor) {
265
global $pagenow;
266
+ if ( $pagenow == "widgets.php" && isset( $_GET['editwidget'] ) && strpos( $_GET['editwidget'], 'black-studio-tinymce' ) === 0 ) {
267
$editor = 'html';
268
}
269
return $editor;
languages/black-studio-tinymce-widget-fi_FI.mo ADDED
Binary file
languages/black-studio-tinymce-widget-fi_FI.po ADDED
@@ -0,0 +1,37 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Black Studio TinyMCE Widget\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-07-31 10:19+0100\n"
6
+ "PO-Revision-Date: 2013-07-23 22:34+0200\n"
7
+ "Last-Translator: Marco <marco@blackstudio.it>\n"
8
+ "Language-Team: Timo Leiniö <timo@wpopas.fi>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "Language: fi\n"
16
+ "X-Generator: Poedit 1.5.7\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: black-studio-tinymce-widget.php:19
20
+ msgid "Arbitrary text or HTML with visual editor"
21
+ msgstr "Lisää sisältöä visuaalisella editorilla"
22
+
23
+ #: black-studio-tinymce-widget.php:21
24
+ msgid "Black Studio TinyMCE"
25
+ msgstr "Black Studio TinyMCE"
26
+
27
+ #: black-studio-tinymce-widget.php:79
28
+ msgid "Donate"
29
+ msgstr "Lahjoita"
30
+
31
+ #: black-studio-tinymce-widget.php:79
32
+ msgid "Support"
33
+ msgstr "Tue"
34
+
35
+ #: black-studio-tinymce-widget.php:79
36
+ msgid "Follow"
37
+ msgstr "Seuraa"
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: marcochiesi, thedarkmist
3
Donate link: http://www.blackstudio.it/en/wordpress-plugins/black-studio-tinymce-widget/
4
Tags: wysiwyg, widget, tinymce, editor, image, media, rich text, rich text editor, visual editor, wysiwyg editor, tinymce editor, widget editor, html editor, wysiwyg widget, html widget, editor widget, text widget, rich text widget, enhanced text widget, tinymce widget, visual widget, image widget, media widget
5
Requires at least: 3.0
6
- Tested up to: 3.6
7
- Stable tag: 1.2.0
8
9
Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
10
@@ -68,6 +68,18 @@ Alternatively, if you don't want to use `[embed]` shortcode, ensure that the URL
68
69
== Changelog ==
70
71
= 1.2.0 =
72
* Fixed issue with Wordpress widgets accessibility mode
73
* Fixed compatibility issue with WPML plugin generating an error in debug mode
@@ -129,7 +141,7 @@ Alternatively, if you don't want to use `[embed]` shortcode, ensure that the URL
129
* Forced TinyMCE editor to not automatically add/remove paragraph tags when switching to HTML mode (you may need to re-edit your widgets to adjust linebreaks, if you were using multiple paragraphs)
130
131
= 0.6.4 =
132
- * Fixed compatibility issue with "Jetpack / After the Deadline" plugin
133
* Optimization of javascript/css loading
134
135
= 0.6.3 =
3
Donate link: http://www.blackstudio.it/en/wordpress-plugins/black-studio-tinymce-widget/
4
Tags: wysiwyg, widget, tinymce, editor, image, media, rich text, rich text editor, visual editor, wysiwyg editor, tinymce editor, widget editor, html editor, wysiwyg widget, html widget, editor widget, text widget, rich text widget, enhanced text widget, tinymce widget, visual widget, image widget, media widget
5
Requires at least: 3.0
6
+ Tested up to: 3.9
7
+ Stable tag: 1.3.0
8
9
Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
10
68
69
== Changelog ==
70
71
+ = 1.3.0 =
72
+ * Added support for smilies conversion (based on the general Wordpress option)
73
+ * Updated styling to match the new default Wordpress editor appearence
74
+ * Refactoring of PHP and JS code to be compliant with Wordpress coding standard
75
+ * Fixed compatibility issue with Wordpress 3.9 alpha and TinyMCE 4.0
76
+ * Fixed compatibility issue with Jetpack / After the Deadline plugin
77
+ * Fixed editor behavior on widget title clicks
78
+ * Fixed CSS issue affecting Firefox on Wordpress 3.8
79
+ * Added finnish translation (Contributor: Timo Leiniö)
80
+ * Better handling of "More tag" button
81
+ * Included JS dev version
82
+
83
= 1.2.0 =
84
* Fixed issue with Wordpress widgets accessibility mode
85
* Fixed compatibility issue with WPML plugin generating an error in debug mode
141
* Forced TinyMCE editor to not automatically add/remove paragraph tags when switching to HTML mode (you may need to re-edit your widgets to adjust linebreaks, if you were using multiple paragraphs)
142
143
= 0.6.4 =
144
+ * Fixed compatibility issue with Jetpack / After the Deadline plugin
145
* Optimization of javascript/css loading
146
147
= 0.6.3 =