@@ -402,6 +402,7 @@ public function renderChart( $atts ) {
402
402
403
403
$ _charts = array ();
404
404
$ _charts_type = '' ;
405
+ $ count = 0 ;
405
406
foreach ( $ this ->_charts as $ id => $ array ) {
406
407
$ _charts = $ this ->_charts ;
407
408
$ library = $ array ['library ' ];
@@ -416,24 +417,26 @@ public function renderChart( $atts ) {
416
417
);
417
418
wp_enqueue_script ( "visualizer-render- $ library " );
418
419
}
419
- }
420
- if ( wp_script_is ( "visualizer-render- $ _charts_type " ) ) {
421
- wp_localize_script (
422
- "visualizer-render- $ _charts_type " ,
423
- 'visualizer ' ,
424
- array (
425
- 'charts ' => $ _charts ,
426
- 'language ' => $ this ->get_language (),
427
- 'map_api_key ' => get_option ( 'visualizer-map-api-key ' ),
428
- 'rest_url ' => version_compare ( $ wp_version , '4.7.0 ' , '>= ' ) ? rest_url ( 'visualizer/v ' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/ ' ) : '' ,
429
- 'wp_nonce ' => wp_create_nonce ( 'wp_rest ' ),
430
- 'i10n ' => array (
431
- 'copied ' => __ ( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data. ' , 'visualizer ' ),
432
- ),
433
- 'page_type ' => 'frontend ' ,
434
- 'is_front ' => true ,
435
- )
436
- );
420
+
421
+ if ( wp_script_is ( "visualizer-render- $ _charts_type " ) && 0 === $ count ) {
422
+ wp_localize_script (
423
+ "visualizer-render- $ _charts_type " ,
424
+ 'visualizer ' ,
425
+ array (
426
+ 'charts ' => $ this ->_charts ,
427
+ 'language ' => $ this ->get_language (),
428
+ 'map_api_key ' => get_option ( 'visualizer-map-api-key ' ),
429
+ 'rest_url ' => version_compare ( $ wp_version , '4.7.0 ' , '>= ' ) ? rest_url ( 'visualizer/v ' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/ ' ) : '' ,
430
+ 'wp_nonce ' => wp_create_nonce ( 'wp_rest ' ),
431
+ 'i10n ' => array (
432
+ 'copied ' => __ ( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data. ' , 'visualizer ' ),
433
+ ),
434
+ 'page_type ' => 'frontend ' ,
435
+ 'is_front ' => true ,
436
+ )
437
+ );
438
+ }
439
+ $ count ++;
437
440
}
438
441
wp_enqueue_style ( 'visualizer-front ' );
439
442
0 commit comments