@@ -284,35 +284,30 @@ public static function init_app_shell() {
284
284
285
285
$ requested_app_shell_component = self ::get_requested_app_shell_component ();
286
286
287
- if ( ! is_amp_endpoint () ) {
288
-
289
- if ( 'outer ' === $ requested_app_shell_component ) {
290
- wp_enqueue_script ( 'amp-shadow ' );
291
- // @todo Enqueue script which hooks uses AMP Shadow API (assets/js/amp-app-shell.js).
292
- // @todo Prevent showing admin bar?
293
- // @todo For non-outer
294
- } elseif ( 'inner ' === $ requested_app_shell_component ) {
295
- wp_die (
296
- esc_html__ ( 'Inner app shell can only be requested of the AMP version (thus requires paired mode). ' , 'amp ' ),
297
- esc_html__ ( 'AMP Inner App Shell Problem ' , 'amp ' ),
298
- array ( 'response ' => 400 )
299
- );
300
- }
287
+ // @todo Prevent showing admin bar in outer app shell?
288
+ if ( ! is_amp_endpoint () && 'inner ' === $ requested_app_shell_component ) {
289
+ // @todo For non-outer
290
+ wp_die (
291
+ esc_html__ ( 'Inner app shell can only be requested of the AMP version (thus requires paired mode). ' , 'amp ' ),
292
+ esc_html__ ( 'AMP Inner App Shell Problem ' , 'amp ' ),
293
+ array ( 'response ' => 400 )
294
+ );
295
+ } elseif ( is_amp_endpoint () && 'outer ' === $ requested_app_shell_component ) {
296
+ wp_die (
297
+ esc_html__ ( 'Outer app shell can only be requested of the non-AMP version (thus requires paired mode). ' , 'amp ' ),
298
+ esc_html__ ( 'AMP Outer App Shell Problem ' , 'amp ' ),
299
+ array ( 'response ' => 400 )
300
+ );
301
+ }
301
302
302
- // @todo Is this right? It should really be enqueued regardless. It's not about whether the current template has AMP available, but _other_ URLs.
303
- $ template_availability = self ::get_template_availability ();
304
- if ( ! empty ( $ template_availability ['supported ' ] ) ) {
305
- wp_enqueue_script ( 'amp-shadow ' );
306
- // @todo Enqueue other required scripts.
307
- }
308
- } else {
309
- if ( 'outer ' === $ requested_app_shell_component ) {
310
- wp_die (
311
- esc_html__ ( 'Outer app shell can only be requested of the non-AMP version (thus requires paired mode). ' , 'amp ' ),
312
- esc_html__ ( 'AMP Outer App Shell Problem ' , 'amp ' ),
313
- array ( 'response ' => 400 )
314
- );
315
- }
303
+ // Enqueue scripts for (outer) app shell, including precached app shell and normal site navigation prior to service worker installation.
304
+ if ( 'inner ' !== $ requested_app_shell_component ) {
305
+ wp_enqueue_script ( 'amp-shadow ' );
306
+ wp_enqueue_script ( 'amp-wp-app-shell ' );
307
+ $ exports = array (
308
+ 'contentElementId ' => self ::APP_SHELL_CONTENT_ELEMENT_ID ,
309
+ );
310
+ wp_add_inline_script ( 'amp-wp-app-shell ' , sprintf ( 'var ampWpAppShell = %s; ' , wp_json_encode ( $ exports ) ), 'before ' );
316
311
}
317
312
}
318
313
0 commit comments