| @@ -37,8 +37,11 @@ | ||
| 37 | 37 | * |
| 38 | 38 | * @access protected |
| 39 | 39 | */ |
| 40 | 40 | protected function _toHTML() { |
| 41 | + if ( $this->is_request_from_gutenberg() ) { | |
| 42 | + return; | |
| 43 | + } | |
| 41 | 44 | echo '<!DOCTYPE html>'; |
| 42 | 45 | echo '<html>'; |
| 43 | 46 | echo '<head>'; |
| 44 | 47 | echo '<script type="text/javascript">'; |
| @@ -47,13 +50,20 @@ | ||
| 47 | 50 | echo 'var win = window.dialogArguments || opener || parent || top;'; |
| 48 | 51 | echo 'if (win.visualizer) {'; |
| 49 | 52 | echo 'win.visualizer.charts.canvas.series = ', $this->series, ';'; |
| 50 | 53 | echo 'win.visualizer.charts.canvas.data = ', $this->data, ';'; |
| 51 | - echo 'win.visualizer.render();'; | |
| 54 | + if ( $this->settings ) { | |
| 55 | + echo 'win.visualizer.charts.canvas.settings = ', $this->settings, ';'; | |
| 56 | + } | |
| 57 | + echo 'win.vizUpdateChartPreview();'; | |
| 58 | + | |
| 59 | + echo $this->updateEditorAndSettings(); | |
| 60 | + | |
| 52 | 61 | echo '}'; |
| 53 | 62 | |
| 54 | - // added by Ash/Upwork | |
| 55 | - if ( VISUALIZER_PRO ) { | |
| 63 | + do_action( 'visualizer_add_update_hook', $this->series, $this->data ); | |
| 64 | + | |
| 65 | + if ( Visualizer_Module::is_pro() && Visualizer_Module::is_pro_older_than( '1.9.0' ) ) { | |
| 56 | 66 | global $Visualizer_Pro; |
| 57 | 67 | $Visualizer_Pro->_addUpdateHook( $this->series, $this->data ); |
| 58 | 68 | } |
| 59 | 69 | } else { |
| @@ -63,7 +73,24 @@ | ||
| 63 | 73 | echo '</script>'; |
| 64 | 74 | echo '</head>'; |
| 65 | 75 | echo '<body></body>'; |
| 66 | 76 | echo '</html>'; |
| 77 | + } | |
| 78 | + | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Update the hidden content in the LHS and the advanced settings | |
| 82 | + */ | |
| 83 | + private function updateEditorAndSettings() { | |
| 84 | + $editor = ''; | |
| 85 | + if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { | |
| 86 | + ob_start(); | |
| 87 | + Visualizer_Render_Layout::show( 'simple-editor-screen', $this->id ); | |
| 88 | + $editor = ob_get_clean(); | |
| 89 | + } | |
| 90 | + | |
| 91 | + $sidebar = apply_filters( 'visualizer_get_sidebar', '', $this->id ); | |
| 92 | + | |
| 93 | + return 'win.vizUpdateHTML(' . json_encode( array( 'html' => $editor ) ) . ', ' . json_encode( array( 'html' => $sidebar ) ) . ');'; | |
| 67 | 94 | } |
| 68 | 95 | |
| 69 | 96 | } |