Skip to content

Commit cf8e01e

Browse files
committed
Add support for LTS release channel
1 parent 36c305c commit cf8e01e

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

assets/src/admin/paired-browsing/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { addQueryArgs, hasQueryArg, removeQueryArgs } from '@wordpress/url';
88
import './app.css';
99

1010
const { app, history } = window;
11-
const { ampSlug, ampPairedBrowsingQueryVar, ampValidationErrorsQueryVar, documentTitlePrefix } = app;
11+
const { ampSlug, ampRuntimeScriptSrc, ampPairedBrowsingQueryVar, ampValidationErrorsQueryVar, documentTitlePrefix } = app;
1212

1313
class PairedBrowsingApp {
1414
/**
@@ -119,7 +119,7 @@ class PairedBrowsingApp {
119119
* @return {boolean} True if AMP compatible, false if not.
120120
*/
121121
documentIsAmp( doc ) {
122-
return doc.querySelector( 'head > script[src="https://cdn.ampproject.org/v0.js"]' );
122+
return doc.querySelector( `head > script[src="${ampRuntimeScriptSrc}"]` );
123123
}
124124

125125
/**

includes/amp-helper-functions.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,26 @@ function amp_register_default_scripts( $wp_scripts ) {
421421
}
422422
}
423423

424+
/**
425+
* Filters whether to use the LTS release channel.
426+
*
427+
* @since 1.5
428+
*
429+
* @param bool $use_lts Whether to use the LTS release channel. Defaults to false (so the stable channel is used).
430+
*/
431+
$lts_release_channel = apply_filters( 'amp_lts_release_channel', false );
432+
433+
if ( $lts_release_channel ) {
434+
$base_url = 'https://cdn.ampproject.org/lts';
435+
} else {
436+
$base_url = 'https://cdn.ampproject.org';
437+
}
438+
424439
// AMP Runtime.
425440
$handle = 'amp-runtime';
426441
$wp_scripts->add(
427442
$handle,
428-
'https://cdn.ampproject.org/v0.js',
443+
$base_url . '/v0.js',
429444
[],
430445
null
431446
);
@@ -441,7 +456,7 @@ function amp_register_default_scripts( $wp_scripts ) {
441456
$handle = 'amp-shadow';
442457
$wp_scripts->add(
443458
$handle,
444-
'https://cdn.ampproject.org/shadow-v0.js',
459+
$base_url . '/shadow-v0.js',
445460
[],
446461
null
447462
);
@@ -456,7 +471,8 @@ function amp_register_default_scripts( $wp_scripts ) {
456471
// Register all AMP components as defined in the spec.
457472
foreach ( AMP_Allowed_Tags_Generated::get_extension_specs() as $extension_name => $extension_spec ) {
458473
$src = sprintf(
459-
'https://cdn.ampproject.org/v0/%s-%s.js',
474+
'%s/v0/%s-%s.js',
475+
$base_url,
460476
$extension_name,
461477
end( $extension_spec['version'] )
462478
);

includes/class-amp-theme-support.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,7 @@ public static function serve_paired_browsing_experience( $template ) {
23822382
'ampPairedBrowsingQueryVar' => self::PAIRED_BROWSING_QUERY_VAR,
23832383
'ampValidationErrorsQueryVar' => AMP_Validation_Manager::VALIDATION_ERRORS_QUERY_VAR,
23842384
'documentTitlePrefix' => __( 'AMP Paired Browsing:', 'amp' ),
2385+
'ampRuntimeScriptSrc' => wp_scripts()->registered['amp-runtime']->src,
23852386
]
23862387
);
23872388

0 commit comments

Comments
 (0)