@@ -353,6 +353,10 @@ public function renderChart( $atts ) {
353
353
return '<div id=" ' . $ id . '" ' . $ this ->getHtmlAttributes ( $ attributes ) . '> ' . wp_get_attachment_image ( $ chart_image , 'full ' ) . '</div> ' ;
354
354
}
355
355
}
356
+ // Unset chart image base64 string.
357
+ if ( isset ( $ settings ['chart-img ' ] ) ) {
358
+ unset( $ settings ['chart-img ' ] );
359
+ }
356
360
357
361
// add chart to the array
358
362
$ this ->_charts [ $ id ] = array (
@@ -395,22 +399,29 @@ public function renderChart( $atts ) {
395
399
396
400
$ actions_div .= $ css ;
397
401
402
+ $ _charts = array ();
403
+ $ _charts_type = '' ;
398
404
foreach ( $ this ->_charts as $ id => $ array ) {
405
+ $ _charts = $ this ->_charts ;
399
406
$ library = $ array ['library ' ];
400
- wp_register_script (
401
- "visualizer-render- $ library " ,
402
- VISUALIZER_ABSURL . 'js/render-facade.js ' ,
403
- apply_filters ( 'visualizer_assets_render ' , array ( 'jquery ' , 'visualizer-customization ' ), true ),
404
- Visualizer_Plugin::VERSION ,
405
- true
406
- );
407
-
408
- wp_enqueue_script ( "visualizer-render- $ library " );
407
+ $ _charts_type = $ library ;
408
+ if ( ! wp_script_is ( "visualizer-render- $ library " , 'registered ' ) ) {
409
+ wp_register_script (
410
+ "visualizer-render- $ library " ,
411
+ VISUALIZER_ABSURL . 'js/render-facade.js ' ,
412
+ apply_filters ( 'visualizer_assets_render ' , array ( 'jquery ' , 'visualizer-customization ' ), true ),
413
+ Visualizer_Plugin::VERSION ,
414
+ true
415
+ );
416
+ wp_enqueue_script ( "visualizer-render- $ library " );
417
+ }
418
+ }
419
+ if ( wp_script_is ( "visualizer-render- $ _charts_type " ) ) {
409
420
wp_localize_script (
410
- "visualizer-render- $ library " ,
421
+ "visualizer-render- $ _charts_type " ,
411
422
'visualizer ' ,
412
423
array (
413
- 'charts ' => $ this -> _charts ,
424
+ 'charts ' => $ _charts ,
414
425
'language ' => $ this ->get_language (),
415
426
'map_api_key ' => get_option ( 'visualizer-map-api-key ' ),
416
427
'rest_url ' => version_compare ( $ wp_version , '4.7.0 ' , '>= ' ) ? rest_url ( 'visualizer/v ' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/ ' ) : '' ,
@@ -422,8 +433,8 @@ public function renderChart( $atts ) {
422
433
'is_front ' => true ,
423
434
)
424
435
);
425
- wp_enqueue_style ( 'visualizer-front ' );
426
436
}
437
+ wp_enqueue_style ( 'visualizer-front ' );
427
438
428
439
// return placeholder div
429
440
return $ actions_div . '<div id=" ' . $ id . '" ' . $ this ->getHtmlAttributes ( $ attributes ) . '></div> ' . $ this ->addSchema ( $ chart ->ID );
0 commit comments