| @@ -150,5 +150,25 @@ | ||
| 150 | 150 | public function render() { |
| 151 | 151 | $this->_toHTML(); |
| 152 | 152 | } |
| 153 | 153 | |
| 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 | + | |
| 154 | 174 | } |