File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
classes/Visualizer/Module Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -355,6 +355,9 @@ public function renderChart( $atts ) {
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 ' ] ) ) {
@@ -365,6 +368,9 @@ private function addSchema( $id ) {
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
@@ -373,8 +379,18 @@ private function addSchema( $id ) {
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
You can’t perform that action at this time.
0 commit comments