@@ -436,6 +436,7 @@ public function renderChart( $atts ) {
436436
437437 $ _charts = array ();
438438 $ _charts_type = '' ;
439+ $ count = 0 ;
439440 foreach ( $ this ->_charts as $ id => $ array ) {
440441 $ _charts = $ this ->_charts ;
441442 $ library = $ array ['library ' ];
@@ -450,24 +451,26 @@ public function renderChart( $atts ) {
450451 );
451452 wp_enqueue_script ( "visualizer-render- $ library " );
452453 }
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 ++;
471474 }
472475
473476 // return placeholder div
0 commit comments