@@ -436,6 +436,7 @@ public function renderChart( $atts ) {
436
436
437
437
$ _charts = array ();
438
438
$ _charts_type = '' ;
439
+ $ count = 0 ;
439
440
foreach ( $ this ->_charts as $ id => $ array ) {
440
441
$ _charts = $ this ->_charts ;
441
442
$ library = $ array ['library ' ];
@@ -450,24 +451,26 @@ public function renderChart( $atts ) {
450
451
);
451
452
wp_enqueue_script ( "visualizer-render- $ library " );
452
453
}
453
- }
454
- if ( wp_script_is ( "visualizer-render- $ _charts_type " ) ) {
455
- wp_localize_script (
456
- "visualizer-render- $ _charts_type " ,
457
- 'visualizer ' ,
458
- array (
459
- 'charts ' => $ _charts ,
460
- 'language ' => $ this ->get_language (),
461
- 'map_api_key ' => get_option ( 'visualizer-map-api-key ' ),
462
- 'rest_url ' => version_compare ( $ wp_version , '4.7.0 ' , '>= ' ) ? rest_url ( 'visualizer/v ' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/ ' ) : '' ,
463
- 'wp_nonce ' => wp_create_nonce ( 'wp_rest ' ),
464
- 'i10n ' => array (
465
- 'copied ' => __ ( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data. ' , 'visualizer ' ),
466
- ),
467
- 'page_type ' => 'frontend ' ,
468
- 'is_front ' => true ,
469
- )
470
- );
454
+
455
+ if ( wp_script_is ( "visualizer-render- $ _charts_type " ) && 0 === $ count ) {
456
+ wp_localize_script (
457
+ "visualizer-render- $ _charts_type " ,
458
+ 'visualizer ' ,
459
+ array (
460
+ 'charts ' => $ this ->_charts ,
461
+ 'language ' => $ this ->get_language (),
462
+ 'map_api_key ' => get_option ( 'visualizer-map-api-key ' ),
463
+ 'rest_url ' => version_compare ( $ wp_version , '4.7.0 ' , '>= ' ) ? rest_url ( 'visualizer/v ' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/ ' ) : '' ,
464
+ 'wp_nonce ' => wp_create_nonce ( 'wp_rest ' ),
465
+ 'i10n ' => array (
466
+ 'copied ' => __ ( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data. ' , 'visualizer ' ),
467
+ ),
468
+ 'page_type ' => 'frontend ' ,
469
+ 'is_front ' => true ,
470
+ )
471
+ );
472
+ }
473
+ $ count ++;
471
474
}
472
475
473
476
// return placeholder div
0 commit comments