Sfoglia il codice sorgente

Merge pull request #2231 from rtCamp/fix/dalston-amp-compatibility

Dalston: Enqueue Block Scripts only in non-AMP
Allan Cole 5 anni fa
parent
commit
5384940bad
1 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. 16 0
      dalston/functions.php

+ 16 - 0
dalston/functions.php

@@ -210,6 +210,11 @@ add_action( 'enqueue_block_editor_assets', 'dalston_editor_styles' );
  */
 function dalston_block_extends() {
 
+	// Bail out early while in AMP endpoint.
+	if ( dalston_is_amp() ) {
+		return;
+	}
+
 	// Cover Block Tweaks
 	wp_enqueue_script( 'dalston-extend-cover-block',
 		get_stylesheet_directory_uri() . '/block-extends/extend-cover-block.js',
@@ -241,3 +246,14 @@ function dalston_block_extends() {
 	);
 }
 add_action( 'enqueue_block_assets', 'dalston_block_extends' );
+
+/**
+ * Whether this is an AMP endpoint.
+ *
+ * @see https://github.com/Automattic/amp-wp/blob/e4472bfa5c304b6c1b968e533819e3fa96579ad4/includes/amp-helper-functions.php#L248
+ * @return bool
+ */
+function dalston_is_amp() {
+	return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint();
+}
+