| @@ -252,9 +252,9 @@ | ||
| 252 | 252 | $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type ); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // handle data filter hooks |
| 256 | - $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type ); | |
| 256 | + $data = self::get_chart_data( $chart, $type ); | |
| 257 | 257 | if ( ! empty( $atts['data'] ) ) { |
| 258 | 258 | $data = apply_filters( $atts['data'], $data, $chart->ID, $type ); |
| 259 | 259 | } |
| 260 | 260 | |
| @@ -354,8 +354,11 @@ | ||
| 354 | 354 | * |
| 355 | 355 | * @access private |
| 356 | 356 | */ |
| 357 | 357 | private function addSchema( $id ) { |
| 358 | + // should we show informative errors as HTML comments? | |
| 359 | + $show_errors = apply_filters( 'visualizer_schema_show_errors', true, $id ); | |
| 360 | + | |
| 358 | 361 | $settings = get_post_meta( $id, Visualizer_Plugin::CF_SETTINGS, true ); |
| 359 | 362 | $title = ''; |
| 360 | 363 | if ( isset( $settings['title'] ) && ! empty( $settings['title'] ) ) { |
| 361 | 364 | $title = $settings['title']; |
| @@ -364,8 +367,11 @@ | ||
| 364 | 367 | } |
| 365 | 368 | } |
| 366 | 369 | $title = apply_filters( 'visualizer_schema_name', $title, $id ); |
| 367 | 370 | if ( empty( $title ) ) { |
| 371 | + if ( $show_errors ) { | |
| 372 | + return "<!-- Not showing structured data for chart $id because title is empty -->"; | |
| 373 | + } | |
| 368 | 374 | return ''; |
| 369 | 375 | } |
| 370 | 376 | |
| 371 | 377 | $desc = ''; |
| @@ -372,10 +378,20 @@ | ||
| 372 | 378 | if ( isset( $settings['description'] ) && ! empty( $settings['description'] ) ) { |
| 373 | 379 | $desc = $settings['description']; |
| 374 | 380 | } |
| 375 | 381 | $desc = apply_filters( 'visualizer_schema_description', $desc, $id ); |
| 382 | + if ( empty( $desc ) ) { | |
| 383 | + if ( $show_errors ) { | |
| 384 | + return "<!-- Not showing structured data for chart $id because description is empty -->"; | |
| 385 | + } | |
| 386 | + return ''; | |
| 387 | + } | |
| 388 | + | |
| 376 | 389 | // descriptions below 50 chars are not allowed. |
| 377 | - if ( empty( $desc ) || strlen( $desc ) < 50 ) { | |
| 390 | + if ( strlen( $desc ) < 50 ) { | |
| 391 | + if ( $show_errors ) { | |
| 392 | + return "<!-- Not showing structured data for chart $id because description is shorter than 50 characters -->"; | |
| 393 | + } | |
| 378 | 394 | return ''; |
| 379 | 395 | } |
| 380 | 396 | |
| 381 | 397 | $schema = apply_filters( |