| @@ -238,9 +238,8 @@ | ||
| 238 | 238 | 'header', |
| 239 | 239 | 'footer' |
| 240 | 240 | ]; |
| 241 | 241 | |
| 242 | - $CoreAssets = new CoreAssets(); | |
| 243 | 242 | $FileUpload = new FileUpload(); |
| 244 | 243 | foreach ( $template_types as $template_type ) { |
| 245 | 244 | $post_id = Helper::get_template_id( $template_type ); |
| 246 | 245 | if ( $post_id ) { |
| @@ -254,11 +253,14 @@ | ||
| 254 | 253 | } |
| 255 | 254 | $js_file_path = $FileUpload->get_file_path( $post_id . '.min.js' ); |
| 256 | 255 | if ( file_exists( $js_file_path ) ) { |
| 257 | 256 | $js_file_url = $FileUpload->get_file_url( $post_id . '.min.js' ); |
| 258 | - wp_enqueue_script( 'ablocks-blocks-' . $template_type . '-' . $post_id . '-combine-script', $js_file_url, array(), filemtime( $js_file_path ), true ); | |
| 259 | - wp_localize_script( 'ablocks-blocks-' . $template_type . '-' . $post_id . '-combine-script', 'ABlocksGlobal', $CoreAssets->get_localize_frontend_data() ); | |
| 257 | + // One shared ABlocksGlobal for the whole page: without this each | |
| 258 | + // template type (header/footer/single/archive) printed its own | |
| 259 | + // identical copy on top of the page combine script's. | |
| 260 | + wp_enqueue_script( 'ablocks-blocks-' . $template_type . '-' . $post_id . '-combine-script', $js_file_url, array( 'ablocks-globals' ), filemtime( $js_file_path ), true ); | |
| 261 | + CoreAssets::localize_globals_once(); | |
| 260 | 262 | } |
| 261 | 263 | } |
| 262 | - } | |
| 264 | + }//end foreach | |
| 263 | 265 | } |
| 264 | 266 | } |