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
This commit is contained in:
Andrew Ozz 2014-01-25 01:20:04 +00:00
parent 48d24f6bf5
commit be31ef4b65
4 changed files with 10 additions and 5 deletions

View File

@ -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" .

View File

@ -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);

View File

@ -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<d.length;i++)h.push(b[d[i]]);("function"!=typeof d||(h=d(c,b,a)))&&(d||(h=[b]),h.unshift(e||a),f.apply(g||e||a,h)===!1&&b.stopImmediatePropagation())}return b("<target>.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);
!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<d.length;i++)h.push(b[d[i]]);("function"!=typeof d||(h=d(c,b,a)))&&(d||(h=[b]),h.unshift(e||a),f.apply(g||e||a,h)===!1&&b.stopImmediatePropagation())}return b("<target>.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);

View File

@ -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