From be31ef4b659b2ccc948b13251230d96af6eec211 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 25 Jan 2014 01:20:04 +0000 Subject: [PATCH] TinyMCE: fix the compat3x plugin appending 'en.' to button titles. Set charset to UTF-8 in html_entity_decode() for translated strings. See #24067, see #26875. git-svn-id: https://develop.svn.wordpress.org/trunk@27030 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-editor.php | 2 +- src/wp-includes/js/tinymce/plugins/compat3x/plugin.js | 9 +++++++-- .../js/tinymce/plugins/compat3x/plugin.min.js | 2 +- src/wp-includes/version.php | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index b2d0f1605d..dd59239751 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -691,7 +691,7 @@ final class _WP_Editors { foreach ( $mce_translation as $key => $value ) { if ( strpos( $value, '&' ) !== false ) - $mce_translation[$key] = html_entity_decode( $value, ENT_QUOTES ); + $mce_translation[$key] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); } return "tinymce.addI18n( '$mce_locale', " . json_encode( $mce_translation ) . ");\n" . diff --git a/src/wp-includes/js/tinymce/plugins/compat3x/plugin.js b/src/wp-includes/js/tinymce/plugins/compat3x/plugin.js index d2ae391c4f..da400838d2 100644 --- a/src/wp-includes/js/tinymce/plugins/compat3x/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/compat3x/plugin.js @@ -204,7 +204,7 @@ var originalAddButton = editor.addButton; editor.addButton = function(name, settings) { - var originalOnPostRender; + var originalOnPostRender, string, translated; function patchedPostRender() { editor.controlManager.buttons[name] = this; @@ -226,7 +226,12 @@ } if ( settings.title ) { - settings.title = tinymce.i18n.translate((editor.settings.language || "en") + "." + settings.title); + string = (editor.settings.language || "en") + "." + settings.title; + translated = tinymce.i18n.translate(string); + + if ( string !== translated ) { + settings.title = translated; + } } return originalAddButton.call(this, name, settings); diff --git a/src/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js b/src/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js index a59b67fa93..c9d718a2a4 100644 --- a/src/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js +++ b/src/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js @@ -1 +1 @@ -!function(a){function b(a){!f&&window&&window.console&&(f=!0,console.log("Deprecated TinyMCE API call: "+a))}function c(a,c,d,e){return a=a||this,c?(this.add=function(f,g){function h(b){var h=[];if("string"==typeof d&&(d=d.split(" ")),d&&"function"!=typeof d)for(var i=0;i.on"+c+".add(..)"),a.on(c,h),h},this.addToTop=this.add,this.remove=function(b){return a.off(c,b)},this.dispatch=function(){return a.fire(c),!0},void 0):(this.add=this.addToTop=this.remove=this.dispatch=function(){},void 0)}function d(){}function e(e){function f(b,d){a.each(b.split(" "),function(a){e["on"+a]=new c(e,a,d)})}function g(a,b,c){return[b.level,c]}function h(a){return function(b,c){return!c.selection&&!a||c.selection==a?[c]:void 0}}function i(){function c(){return i()}var d={},e="add addMenu addSeparator collapse createMenu destroy displayColor expand focus getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex setActive setAriaProperty setColor setDisabled setSelected setState showMenu update";return b("editor.controlManager.*"),a.each(e.split(" "),function(a){d[a]=c}),d}if(!e.controlManager){e.controlManager={buttons:{},setDisabled:function(a,c){b("controlManager.setDisabled(..)"),this.buttons[a]&&this.buttons[a].disabled(c)},setActive:function(a,c){b("controlManager.setActive(..)"),this.buttons[a]&&this.buttons[a].active(c)},onAdd:new c,onPostRender:new c,add:function(a){return a},createButton:i,createColorSplitButton:i,createControl:i,createDropMenu:i,createListBox:i,createMenuButton:i,createSeparator:i,createSplitButton:i,createToolbar:i,createToolbarGroup:i,destroy:d,get:d,setControlType:i},f("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate","editor"),f("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"),f("BeforeExecCommand ExecCommand","command ui value args"),f("PreProcess PostProcess LoadContent SaveContent Change"),f("BeforeSetContent BeforeGetContent SetContent GetContent",h(!1)),f("SetProgressState","state time"),f("VisualAid","element hasVisual"),f("Undo Redo",g),f("NodeChange",function(a,b){return[e.controlManager,b.element,e.selection.isCollapsed(),b]});var j=e.addButton;e.addButton=function(b,c){function d(){return e.controlManager.buttons[b]=this,f?f.call(this):void 0}var f;for(var g in c)"onpostrender"===g.toLowerCase()&&(f=c[g],c.onPostRender=d);return f||(c.onPostRender=d),c.title&&(c.title=a.i18n.translate((e.settings.language||"en")+"."+c.title)),j.call(this,b,c)},e.on("init",function(){var a=e.undoManager,b=e.selection;a.onUndo=new c(e,"Undo",g,null,a),a.onRedo=new c(e,"Redo",g,null,a),a.onBeforeAdd=new c(e,"BeforeAddUndo",null,a),a.onAdd=new c(e,"AddUndo",null,a),b.onBeforeGetContent=new c(e,"BeforeGetContent",h(!0),b),b.onGetContent=new c(e,"GetContent",h(!0),b),b.onBeforeSetContent=new c(e,"BeforeSetContent",h(!0),b),b.onSetContent=new c(e,"SetContent",h(!0),b)}),e.on("BeforeRenderUI",function(){var d=e.windowManager;d.onOpen=new c,d.onClose=new c,d.createInstance=function(c,d,e,f,g,h){b("windowManager.createInstance(..)");var i=a.resolve(c);return new i(d,e,f,g,h)}})}}var f;a.util.Dispatcher=c,a.onBeforeUnload=new c(a,"BeforeUnload"),a.onAddEditor=new c(a,"AddEditor","editor"),a.onRemoveEditor=new c(a,"RemoveEditor","editor"),a.util.Cookie={get:d,getHash:d,remove:d,set:d,setHash:d},a.on("SetupEditor",e),a.PluginManager.add("compat3x",e),a.addI18n=function(b,c){var d=a.util.I18n,e=a.each;return"string"==typeof b&&-1===b.indexOf(".")?(d.add(b,c),void 0):(a.is(b,"string")?e(c,function(a,c){d.data[b+"."+c]=a}):e(b,function(a,b){e(a,function(a,c){e(a,function(a,e){"common"===c?d.data[b+"."+e]=a:d.data[b+"."+c+"."+e]=a})})}),void 0)}}(tinymce); \ No newline at end of file +!function(a){function b(a){!f&&window&&window.console&&(f=!0,console.log("Deprecated TinyMCE API call: "+a))}function c(a,c,d,e){return a=a||this,c?(this.add=function(f,g){function h(b){var h=[];if("string"==typeof d&&(d=d.split(" ")),d&&"function"!=typeof d)for(var i=0;i.on"+c+".add(..)"),a.on(c,h),h},this.addToTop=this.add,this.remove=function(b){return a.off(c,b)},this.dispatch=function(){return a.fire(c),!0},void 0):(this.add=this.addToTop=this.remove=this.dispatch=function(){},void 0)}function d(){}function e(e){function f(b,d){a.each(b.split(" "),function(a){e["on"+a]=new c(e,a,d)})}function g(a,b,c){return[b.level,c]}function h(a){return function(b,c){return!c.selection&&!a||c.selection==a?[c]:void 0}}function i(){function c(){return i()}var d={},e="add addMenu addSeparator collapse createMenu destroy displayColor expand focus getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex setActive setAriaProperty setColor setDisabled setSelected setState showMenu update";return b("editor.controlManager.*"),a.each(e.split(" "),function(a){d[a]=c}),d}if(!e.controlManager){e.controlManager={buttons:{},setDisabled:function(a,c){b("controlManager.setDisabled(..)"),this.buttons[a]&&this.buttons[a].disabled(c)},setActive:function(a,c){b("controlManager.setActive(..)"),this.buttons[a]&&this.buttons[a].active(c)},onAdd:new c,onPostRender:new c,add:function(a){return a},createButton:i,createColorSplitButton:i,createControl:i,createDropMenu:i,createListBox:i,createMenuButton:i,createSeparator:i,createSplitButton:i,createToolbar:i,createToolbarGroup:i,destroy:d,get:d,setControlType:i},f("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate","editor"),f("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"),f("BeforeExecCommand ExecCommand","command ui value args"),f("PreProcess PostProcess LoadContent SaveContent Change"),f("BeforeSetContent BeforeGetContent SetContent GetContent",h(!1)),f("SetProgressState","state time"),f("VisualAid","element hasVisual"),f("Undo Redo",g),f("NodeChange",function(a,b){return[e.controlManager,b.element,e.selection.isCollapsed(),b]});var j=e.addButton;e.addButton=function(b,c){function d(){return e.controlManager.buttons[b]=this,f?f.call(this):void 0}var f,g,h;for(var i in c)"onpostrender"===i.toLowerCase()&&(f=c[i],c.onPostRender=d);return f||(c.onPostRender=d),c.title&&(g=(e.settings.language||"en")+"."+c.title,h=a.i18n.translate(g),g!==h&&(c.title=h)),j.call(this,b,c)},e.on("init",function(){var a=e.undoManager,b=e.selection;a.onUndo=new c(e,"Undo",g,null,a),a.onRedo=new c(e,"Redo",g,null,a),a.onBeforeAdd=new c(e,"BeforeAddUndo",null,a),a.onAdd=new c(e,"AddUndo",null,a),b.onBeforeGetContent=new c(e,"BeforeGetContent",h(!0),b),b.onGetContent=new c(e,"GetContent",h(!0),b),b.onBeforeSetContent=new c(e,"BeforeSetContent",h(!0),b),b.onSetContent=new c(e,"SetContent",h(!0),b)}),e.on("BeforeRenderUI",function(){var d=e.windowManager;d.onOpen=new c,d.onClose=new c,d.createInstance=function(c,d,e,f,g,h){b("windowManager.createInstance(..)");var i=a.resolve(c);return new i(d,e,f,g,h)}})}}var f;a.util.Dispatcher=c,a.onBeforeUnload=new c(a,"BeforeUnload"),a.onAddEditor=new c(a,"AddEditor","editor"),a.onRemoveEditor=new c(a,"RemoveEditor","editor"),a.util.Cookie={get:d,getHash:d,remove:d,set:d,setHash:d},a.on("SetupEditor",e),a.PluginManager.add("compat3x",e),a.addI18n=function(b,c){var d=a.util.I18n,e=a.each;return"string"==typeof b&&-1===b.indexOf(".")?(d.add(b,c),void 0):(a.is(b,"string")?e(c,function(a,c){d.data[b+"."+c]=a}):e(b,function(a,b){e(a,function(a,c){e(a,function(a,e){"common"===c?d.data[b+"."+e]=a:d.data[b+"."+c+"."+e]=a})})}),void 0)}}(tinymce); \ No newline at end of file diff --git a/src/wp-includes/version.php b/src/wp-includes/version.php index 33223eea3c..bdee4baf9d 100644 --- a/src/wp-includes/version.php +++ b/src/wp-includes/version.php @@ -18,7 +18,7 @@ $wp_db_version = 26691; * * @global string $tinymce_version */ -$tinymce_version = '4012-20140121'; +$tinymce_version = '4012-20140124'; /** * Holds the required PHP version