| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | /* jshint unused:false */ |
| 3 | 3 | (function($) { |
| 4 | 4 | tinymce.PluginManager.add('visualizer_mce_button', function( editor, url ) { |
| 5 | 5 | editor.addButton( 'visualizer_mce_button', { |
| 6 | - title: editor.getLang( 'visualizer_tinymce_plugin.plugin_label' ), | |
| 7 | - label: editor.getLang( 'visualizer_tinymce_plugin.plugin_label' ), | |
| 6 | + title: getTranslation( editor, 'plugin_label' ), | |
| 7 | + label: getTranslation( editor, 'plugin_label' ), | |
| 8 | 8 | icon: 'visualizer-icon', |
| 9 | 9 | onclick: function() { |
| 10 | 10 | var frame = wp.media({ |
| 11 | 11 | frame:'post', |
| @@ -14,6 +14,20 @@ | ||
| 14 | 14 | frame.open( ); |
| 15 | 15 | } |
| 16 | 16 | }); |
| 17 | 17 | }); |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Gets the translation from the editor (when classic editor is enabled) | |
| 21 | + * OR | |
| 22 | + * from the settings array inside the editor (when classic block inside gutenberg) | |
| 23 | + */ | |
| 24 | + function getTranslation(editor, slug){ | |
| 25 | + var string = editor.getLang('visualizer_tinymce_plugin.' + slug); | |
| 26 | + // if the string is the same as the slug being requested for, look in the settings. | |
| 27 | + if(string === '{#visualizer_tinymce_plugin.' + slug + '}'){ | |
| 28 | + string = editor.settings.visualizer_tinymce_plugin[slug]; | |
| 29 | + } | |
| 30 | + return string; | |
| 31 | + } | |
| 18 | 32 | |
| 19 | 33 | })(jQuery); |