Skip to content

Commit 3f28e5c

Browse files
Merge pull request #652 from contactashish13/issue-247-pro
Error message when publishing post with Live updating chart
2 parents b67e7bc + 7354a32 commit 3f28e5c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

classes/Visualizer/Render.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,24 @@ public function render() {
151151
$this->_toHTML();
152152
}
153153

154+
/**
155+
* Checks if the request is from Gutenberg.
156+
*
157+
* This happens when the chart is being added to a gutenberg block by inserting a visualizer block.
158+
*
159+
* @since ?
160+
*
161+
* @access protected
162+
* @return bool
163+
*/
164+
protected function is_request_from_gutenberg() {
165+
global $post;
166+
require_once ABSPATH . 'wp-admin/includes/post.php';
167+
if ( $post && function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( $post ) ) {
168+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'This request appears to be from Gutenberg block. Ignoring for chart %d', $post->ID ), 'debug', __FILE__, __LINE__ );
169+
return true;
170+
}
171+
return false;
172+
}
173+
154174
}

classes/Visualizer/Render/Page/Update.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class Visualizer_Render_Page_Update extends Visualizer_Render_Page {
3838
* @access protected
3939
*/
4040
protected function _toHTML() {
41+
if ( $this->is_request_from_gutenberg() ) {
42+
return;
43+
}
4144
echo '<!DOCTYPE html>';
4245
echo '<html>';
4346
echo '<head>';

0 commit comments

Comments
 (0)