| @@ -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', |
| @@ -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 |