PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 4.0.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v4.0.8
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | classes/Visualizer/Gutenberg/Block.php +22 -2 4.0.34.0.8 View file →
@@ -201,10 +201,27 @@
201 201 /**
202 202 * Hook server side rendering into render callback
203 203 */
204 204 public function register_block_type() {
205 + $asset_path = VISUALIZER_ABSPATH . '/classes/Visualizer/Gutenberg/build/index.asset.php';
206 + $version = $this->version;
207 + if ( file_exists( $asset_path ) ) {
208 + // @phpstan-ignore-next-line
209 + $asset = require $asset_path;
210 + $version = isset( $asset['version'] ) ? $asset['version'] : $version;
211 + }
212 + if ( ! wp_style_is( 'visualizer-datatables', 'registered' ) ) {
213 + wp_register_style( 'visualizer-datatables', VISUALIZER_ABSURL . 'css/lib/datatables.min.css', array(), Visualizer_Plugin::VERSION );
214 + }
215 + if ( ! wp_style_is( 'visualizer-gutenberg-block', 'registered' ) ) {
216 + wp_register_style( 'visualizer-gutenberg-block', VISUALIZER_ABSURL . 'classes/Visualizer/Gutenberg/build/style-index.css', array( 'visualizer-datatables' ), $version );
217 + }
205 218 register_block_type(
206 219 'visualizer/chart', array(
220 + // The editor_style registration is what gets the stylesheet into the
221 + // iframed editor canvas; styles enqueued via enqueue_block_editor_assets
222 + // only reach the parent document.
223 + 'editor_style' => 'visualizer-gutenberg-block',
207 224 'render_callback' => array( $this, 'gutenberg_block_callback' ),
208 225 'attributes' => array(
209 226 'id' => array(
210 227 'type' => 'number',
@@ -275,9 +292,9 @@
275 292 /**
276 293 * Get Post Meta Fields
277 294 */
278 295 public function get_visualizer_data( $post ) {
279 - if ( ! current_user_can( 'edit_posts' ) ) {
296 + if ( ! Visualizer_Module::can_edit_chart( $post['id'] ) ) {
280 297 return false;
281 298 }
282 299
283 300 $data = array();
@@ -296,8 +313,11 @@
296 313 $data['visualizer-default-data'] = get_post_meta( $post_id, Visualizer_Plugin::CF_DEFAULT_DATA, true );
297 314
298 315 // faetch and update settings
299 316 $data['visualizer-settings'] = get_post_meta( $post_id, Visualizer_Plugin::CF_SETTINGS, true );
317 + if ( ! is_array( $data['visualizer-settings'] ) ) {
318 + $data['visualizer-settings'] = array();
319 + }
300 320 if ( empty( $data['visualizer-settings']['pagination'] ) ) {
301 321 $data['visualizer-settings']['pageSize'] = '';
302 322 }
303 323 // handle series filter hooks
@@ -306,9 +326,9 @@
306 326 // handle settings filter hooks
307 327 $data['visualizer-settings'] = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $data['visualizer-settings'], $post_id, $data['visualizer-chart-type'] );
308 328
309 329 // handle data filter hooks
310 - $data['visualizer-data'] = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( get_the_content( $post_id ) ) ), $post_id, $data['visualizer-chart-type'] );
330 + $data['visualizer-data'] = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, Visualizer_Module::decode_content( html_entity_decode( get_post_field( 'post_content', $post_id, 'raw' ) ) ), $post_id, $data['visualizer-chart-type'] );
311 331
312 332 // we are going to format only for tabular charts, because we are not sure of the effect on others.
313 333 // this is to solve the case where boolean data shows up as all-ticks on gutenberg.
314 334 if ( in_array( $data['visualizer-chart-type'], array( 'tabular' ), true ) ) {