Skip to content

Commit

Permalink
Update amp_register_polyfills to register Polyfills only on older W…
Browse files Browse the repository at this point in the history
…P versions
  • Loading branch information
thelovekesh committed Feb 7, 2023
1 parent 077523c commit 378522c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions includes/admin/class-amp-template-customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ public function add_customizer_scripts() {
$dependencies = $asset['dependencies'];
$version = $asset['version'];

/** This action is documented in includes/class-amp-theme-support.php */
do_action( 'amp_register_polyfills' );
if ( ! Services::get( 'dependency_support' )->has_support() ) {
/**
* Fires when AMP Polyfills should be registered.
*/
do_action( 'amp_register_polyfills' );
}

wp_enqueue_script(
$handle,
Expand Down Expand Up @@ -585,8 +589,12 @@ public function add_legacy_customizer_scripts() {
$dependencies = $asset['dependencies'];
$version = $asset['version'];

/** This action is documented in includes/class-amp-theme-support.php */
do_action( 'amp_register_polyfills' );
if ( ! Services::get( 'dependency_support' )->has_support() ) {
/**
* Fires when AMP Polyfills should be registered.
*/
do_action( 'amp_register_polyfills' );
}

wp_enqueue_script(
'amp-customize-controls', // Note: This is not 'amp-customize-controls-legacy' to not break existing scripts that have this dependency.
Expand Down Expand Up @@ -645,8 +653,12 @@ public function enqueue_legacy_preview_scripts() {
return;
}

/** This action is documented in includes/class-amp-theme-support.php */
do_action( 'amp_register_polyfills' );
if ( ! Services::get( 'dependency_support' )->has_support() ) {
/**
* Fires when AMP Polyfills should be registered.
*/
do_action( 'amp_register_polyfills' );
}

$asset_file = AMP__DIR__ . '/assets/js/amp-customize-preview-legacy.asset.php';
$asset = require $asset_file;
Expand Down

0 comments on commit 378522c

Please sign in to comment.