Skip to content

Commit 1452710

Browse files
Merge pull request #645 from Codeinwp/development
[Fix] Insert chart button in the classic block [Fix for Pro version] Import from chart did not work
2 parents 7587317 + 8e17b77 commit 1452710

File tree

8 files changed

+49
-6
lines changed

8 files changed

+49
-6
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,23 @@ public function init() {
198198
$this->_addFilter( 'mce_external_languages', 'add_tinymce_lang', 10, 1 );
199199
$this->_addFilter( 'mce_external_plugins', 'tinymce_plugin', 10, 1 );
200200
$this->_addFilter( 'mce_buttons', 'register_mce_button', 10, 1 );
201+
$this->_addFilter( 'tiny_mce_before_init', 'get_strings_for_block', 10, 1 );
201202
}
202203
}
203204

205+
/**
206+
* Add the strings required for the TinyMCE buttons for the classic block (not the classic editor).
207+
*
208+
* @since ?
209+
* @access friendly
210+
*/
211+
function get_strings_for_block( $settings ) {
212+
$class = new Visualizer_Module_Language();
213+
$strings = $class->get_strings();
214+
$array = array( 'visualizer_tinymce_plugin' => json_encode( $strings ) );
215+
return array_merge( $settings, $array );
216+
}
217+
204218
/**
205219
* Load plugin translation for - TinyMCE API
206220
*

classes/Visualizer/Module/Chart.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,9 @@ private function handleCSVasString( $data, $editor_type ) {
898898
$source = new Visualizer_Source_Csv( $tmpfile );
899899
fclose( $handle );
900900
break;
901+
case 'table':
902+
// Import from Chart
903+
// fall-through.
901904
case 'excel':
902905
// data coming in from the excel editor.
903906
$source = apply_filters( 'visualizer_pro_handle_chart_data', $data, '' );

classes/Visualizer/Module/Language.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ public function tinymce_translation() {
6868
return $translated;
6969
}
7070

71+
/**
72+
*
73+
* The method that returns the strings array
74+
*
75+
* @since ?
76+
* @access public
77+
* @return array
78+
*/
79+
public function get_strings() {
80+
return $this->strings;
81+
}
82+
7183
}
7284

7385
$visualizerLangClass = new Visualizer_Module_Language();

classes/Visualizer/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class Visualizer_Plugin {
2929

3030
const NAME = 'visualizer';
31-
const VERSION = '3.4.0';
31+
const VERSION = '3.4.1';
3232

3333
// custom post types
3434
const CPT_VISUALIZER = 'visualizer';

css/media.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Version: 3.4.0
2+
Version: 3.4.1
33
*/
44
#visualizer-library-view {
55
padding: 30px 10px 10px 30px;

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: Visualizer: Tables and Charts for WordPress
55
Plugin URI: https://themeisle.com/plugins/visualizer-charts-and-graphs-lite/
66
Description: A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages. The plugin uses Google Visualization API to render charts, which supports cross-browser compatibility (adopting VML for older IE versions) and cross-platform portability to iOS and new Android releases.
7-
Version: 3.4.0
7+
Version: 3.4.1
88
Author: Themeisle
99
Author URI: http://themeisle.com
1010
License: GPL v2.0 or later

js/mce.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
(function($) {
44
tinymce.PluginManager.add('visualizer_mce_button', function( editor, url ) {
55
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' ),
88
icon: 'visualizer-icon',
99
onclick: function() {
1010
var frame = wp.media({
@@ -16,4 +16,18 @@
1616
});
1717
});
1818

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+
}
32+
1933
})(jQuery);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "visualizer",
3-
"version": "3.4.0",
3+
"version": "3.4.1",
44
"description": "Visualizer Lite",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)