Skip to content

Commit 35ca5a0

Browse files
Error message when publishing post with Live updating chart
1 parent 556ed88 commit 35ca5a0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

classes/Visualizer/Render.php

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

154+
/**
155+
* Checks if the request is from Gutenberg.
156+
*
157+
* @since ?
158+
*
159+
* @access protected
160+
*/
161+
protected function is_request_from_gutenberg() {
162+
global $post;
163+
require_once ABSPATH . 'wp-admin/includes/post.php';
164+
if ( $post && function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( $post ) ) {
165+
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__ );
166+
return true;
167+
}
168+
return false;
169+
}
170+
154171
}

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)