From a4e9b28a8b0b2bbcc6583bce93a2d84d0f22b684 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 3 Oct 2023 17:06:44 +0530 Subject: [PATCH 01/17] Fix deprecation due to `_admin_bar_bump_cb` --- includes/class-amp-theme-support.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php index 08fa48d5e71..00b5e46a04a 100644 --- a/includes/class-amp-theme-support.php +++ b/includes/class-amp-theme-support.php @@ -1225,12 +1225,21 @@ public static function init_admin_bar() { } else { $header_callback = '_admin_bar_bump_cb'; } - remove_action( 'wp_head', $header_callback ); + + // @see . + if ( ! function_exists( 'wp_enqueue_admin_bar_header_styles' ) ) { + remove_action( 'wp_head', $header_callback ); + } + if ( '__return_false' !== $header_callback ) { - ob_start(); - $header_callback(); - $style = ob_get_clean(); - $data = trim( preg_replace( '#]*>(.*)#is', '$1', $style ) ); // See wp_add_inline_style(). + if ( ! function_exists( 'wp_enqueue_admin_bar_header_styles' ) ) { + ob_start(); + $header_callback(); + $style = ob_get_clean(); + $data = trim( preg_replace( '#]*>(.*)#is', '$1', $style ) ); // See wp_add_inline_style(). + } else { + $data = ''; + } // Override AMP's position:relative on the body for the sake of the AMP viewer, which is not relevant an an Admin Bar context. if ( amp_is_dev_mode() ) { From 9d74e5cf035c7c1561dd16a75c1727d48ddc18f6 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 3 Oct 2023 17:41:46 +0530 Subject: [PATCH 02/17] Remove decoding attribute from img tag markup in test cases --- tests/php/test-amp-gallery-embed-handler.php | 58 ++++++++++---------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/tests/php/test-amp-gallery-embed-handler.php b/tests/php/test-amp-gallery-embed-handler.php index 526a2efdec9..3c0a4fed002 100644 --- a/tests/php/test-amp-gallery-embed-handler.php +++ b/tests/php/test-amp-gallery-embed-handler.php @@ -70,7 +70,6 @@ public function tear_down() { */ public function get_conversion_data() { $amp_carousel_caption = ''; - $decoding_attribute = version_compare( get_bloginfo( 'version' ), '6.1-alpha', '>' ) ? 'decoding="async"' : ''; return [ 'shortcode_with_invalid_id' => [ @@ -81,9 +80,9 @@ public function get_conversion_data() { '[gallery ids={{id1}},{{id2}},{{id3}}]', ' -
Alt text' . $amp_carousel_caption . '
-
Alt text
-
Alt text
+
Alt text' . $amp_carousel_caption . '
+
Alt text
+
Alt text
', true, ], @@ -92,14 +91,14 @@ public function get_conversion_data() { ' ', @@ -108,18 +107,18 @@ public function get_conversion_data() { '[gallery amp-lightbox=false amp-carousel=true ids={{id1}},{{id2}},{{id3}}]', ' -
Alt text' . $amp_carousel_caption . '
-
Alt text
-
Alt text
+
Alt text' . $amp_carousel_caption . '
+
Alt text
+
Alt text
', ], 'shortcode_with_carousel_linking_to_file' => [ '[gallery amp-lightbox=false amp-carousel=true link="file" ids={{id1}},{{id2}},{{id3}}]', ' -
Alt text' . $amp_carousel_caption . '
-
Alt text
-
Alt text
+
Alt text' . $amp_carousel_caption . '
+
Alt text
+
Alt text
', ], 'shortcode_with_lightbox' => [ @@ -127,13 +126,13 @@ public function get_conversion_data() { ' ', @@ -143,13 +142,13 @@ public function get_conversion_data() { ' ', @@ -158,18 +157,18 @@ public function get_conversion_data() { '[gallery amp-lightbox=true amp-carousel=true ids={{id1}},{{id2}},{{id3}}]', ' ' . - '
Alt text' . $amp_carousel_caption . '
' . - '
Alt text
' . - '
Alt text
' . + '
Alt text' . $amp_carousel_caption . '
' . + '
Alt text
' . + '
Alt text
' . '
', ], 'shortcode_with_lightbox_and_carousel_linking_to_file' => [ '[gallery amp-lightbox=true amp-carousel=true link="file" ids={{id1}},{{id2}},{{id3}}]', ' ' . - '
Alt text' . $amp_carousel_caption . '
' . - '
Alt text
' . - '
Alt text
' . + '
Alt text' . $amp_carousel_caption . '
' . + '
Alt text
' . + '
Alt text
' . '
', ], 'shortcode_with_no_attributes' => [ @@ -178,14 +177,14 @@ public function get_conversion_data() { ' ', @@ -285,6 +284,9 @@ public function test__conversion( $source, $expected, $use_legacy_mode = false ) // Remove fetchpriority attribute. $content = preg_replace( '/\s+fetchpriority="high"/', '', $content ); + // Remove decoding attribute. + $content = preg_replace( '/\s+decoding="async"/', '', $content ); + $this->assertEquals( $this->normalize( $expected ), $this->normalize( $content ) From bb221a39e68e6a27baf2c943bf86fb6c0546f075 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 3 Oct 2023 18:09:55 +0530 Subject: [PATCH 03/17] Update string contains string assertions for amp scripts --- tests/php/test-amp-helper-functions.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/php/test-amp-helper-functions.php b/tests/php/test-amp-helper-functions.php index 0bfa2e6a82d..51720c8033f 100644 --- a/tests/php/test-amp-helper-functions.php +++ b/tests/php/test-amp-helper-functions.php @@ -1450,9 +1450,14 @@ static function ( $script ) { $output = get_echo( 'wp_print_scripts' ); - $this->assertStringContainsString( '', $output ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript - $this->assertStringContainsString( '', $output ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript - $this->assertStringContainsString( '', $output ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + $this->assertStringContainsString( 'assertStringContainsString( 'https://cdn.ampproject.org/v0.js', $output ); + $this->assertStringContainsString( 'https://cdn.ampproject.org/v0/amp-mathml-0.1.js', $output ); + $this->assertStringContainsString( 'https://cdn.ampproject.org/v0/amp-mustache-latest.js', $output ); + $this->assertStringContainsString( 'async', $output ); + $this->assertStringContainsString( 'custom-element="amp-mathml"', $output ); + $this->assertStringContainsString( 'custom-template="amp-mustache"', $output ); + $this->assertStringContainsString( '', $output ); // Try rendering via amp_render_scripts() instead of amp_render_scripts(), which is how component scripts get added normally. $output = amp_render_scripts( @@ -1463,13 +1468,18 @@ static function ( $script ) { ] ); $this->assertStringNotContainsString( 'amp-mathml', $output, 'The amp-mathml component was already printed above.' ); - $this->assertStringContainsString( '', $output ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript - $this->assertStringContainsString( '', $output ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + $this->assertStringContainsString( '', $output ); + $this->assertStringContainsString( '', $output ); // Try some experimental component to ensure expected script attributes are added. wp_register_script( 'amp-foo', 'https://cdn.ampproject.org/v0/amp-foo-0.1.js', [ 'amp-runtime' ], null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter, WordPress.WP.EnqueuedResourceParameters.MissingVersion $output = get_echo( 'wp_print_scripts', [ 'amp-foo' ] ); - $this->assertStringContainsString( '', $output ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + + $this->assertStringContainsString( 'assertStringContainsString( 'https://cdn.ampproject.org/v0/amp-foo-0.1.js', $output ); + $this->assertStringContainsString( 'async', $output ); + $this->assertStringContainsString( 'custom-element="amp-foo"', $output ); + $this->assertStringContainsString( '', $output ); } /** From c8bff40ee57ba5638970b079443930e11780fd73 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 3 Oct 2023 23:56:38 +0530 Subject: [PATCH 04/17] Fix validation sources in AMP validation manager test cases --- .../test-class-amp-validation-manager.php | 45 +------------------ 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/tests/php/validation/test-class-amp-validation-manager.php b/tests/php/validation/test-class-amp-validation-manager.php index 39b03bd2243..2b54183131e 100644 --- a/tests/php/validation/test-class-amp-validation-manager.php +++ b/tests/php/validation/test-class-amp-validation-manager.php @@ -1875,49 +1875,6 @@ public function test_decorate_shortcode_and_filter_source() { 'function' => version_compare( get_bloginfo( 'version' ), '5.5-alpha', '>' ) ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive', ], ]; - } elseif ( has_filter( 'the_content', 'do_blocks' ) ) { - $sources = [ - [ - 'type' => 'plugin', - 'name' => 'gutenberg', - 'function' => 'do_blocks', - ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'WP_Embed::run_shortcode', - ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'WP_Embed::autoembed', - ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'wptexturize', - ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'wpautop', - ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'shortcode_unautop', - ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'prepend_attachment', - ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'wp_make_content_images_responsive', - ], - ]; } else { $sources = [ [ @@ -1953,7 +1910,7 @@ public function test_decorate_shortcode_and_filter_source() { [ 'type' => 'core', 'name' => 'wp-includes', - 'function' => 'wp_make_content_images_responsive', + 'function' => version_compare( get_bloginfo( 'version' ), '5.5-alpha', '>' ) ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive', ], ]; } From 818cb53ee89ab94f3efaf91476f6d5b8f621d5fc Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 4 Oct 2023 00:23:32 +0530 Subject: [PATCH 05/17] Fix source stack trace in AMP validation manager test cases --- .../test-class-amp-validation-manager.php | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/tests/php/validation/test-class-amp-validation-manager.php b/tests/php/validation/test-class-amp-validation-manager.php index 2b54183131e..5a6685c9191 100644 --- a/tests/php/validation/test-class-amp-validation-manager.php +++ b/tests/php/validation/test-class-amp-validation-manager.php @@ -1869,11 +1869,6 @@ public function test_decorate_shortcode_and_filter_source() { 'name' => 'wp-includes', 'function' => 'prepend_attachment', ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => version_compare( get_bloginfo( 'version' ), '5.5-alpha', '>' ) ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive', - ], ]; } else { $sources = [ @@ -1907,11 +1902,16 @@ public function test_decorate_shortcode_and_filter_source() { 'name' => 'wp-includes', 'function' => 'prepend_attachment', ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => version_compare( get_bloginfo( 'version' ), '5.5-alpha', '>' ) ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive', - ], + ]; + } + + // This will be called after `do_shortcode` in WP 6.4 and later. + // @see . + if ( version_compare( get_bloginfo( 'version' ), '6.3', '<=' ) ) { + $sources[] = [ + 'type' => 'core', + 'name' => 'wp-includes', + 'function' => version_compare( get_bloginfo( 'version' ), '5.5-alpha', '>' ) ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive', ]; } @@ -1944,14 +1944,26 @@ public function test_decorate_shortcode_and_filter_source() { 'name' => 'wp-includes', 'function' => 'do_shortcode', ], - [ - 'type' => 'core', - 'name' => 'wp-includes', - 'function' => 'convert_smilies', - ], ] ); + // `wp_filter_content_tags` is called after `do_shortcode` in WP 6.4 and later. + // @see . + if ( version_compare( get_bloginfo( 'version' ), '6.4-alpha', '>=' ) ) { + $sources[] = [ + 'type' => 'core', + 'name' => 'wp-includes', + 'function' => 'wp_filter_content_tags', + ]; + } + + // `wp_filter_content_tags` is called before `convert_smilies` in WP 6.4 and later. + $sources[] = [ + 'type' => 'core', + 'name' => 'wp-includes', + 'function' => 'convert_smilies', + ]; + foreach ( $sources as &$source ) { $function = $source['function']; unset( $source['function'] ); From e256ad94a4d24f2fe3c1ab96f408fc71cf389e40 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 4 Oct 2023 00:35:47 +0530 Subject: [PATCH 06/17] Update https status detection in SupportData service --- src/Support/SupportData.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Support/SupportData.php b/src/Support/SupportData.php index 2f6205c4fea..fa06b0263c3 100644 --- a/src/Support/SupportData.php +++ b/src/Support/SupportData.php @@ -251,7 +251,10 @@ public function get_site_info() { $loopback_status = ( ! empty( $loopback_status->status ) ) ? $loopback_status->status : ''; } - if ( function_exists( 'wp_is_https_supported' ) ) { + if ( function_exists( 'wp_get_https_detection_errors' ) ) { + $https_errors = wp_get_https_detection_errors(); + $is_ssl = empty( $https_errors ); + } elseif ( function_exists( 'wp_is_https_supported' ) ) { $is_ssl = wp_is_https_supported(); } else { $is_ssl = is_ssl(); From 4f1c89313791c1f75567f01c5ab1fe4f993e2599 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 4 Oct 2023 18:06:29 +0530 Subject: [PATCH 07/17] Fix version compare with alpha version --- tests/php/validation/test-class-amp-validation-manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/php/validation/test-class-amp-validation-manager.php b/tests/php/validation/test-class-amp-validation-manager.php index 5a6685c9191..d3e80922c62 100644 --- a/tests/php/validation/test-class-amp-validation-manager.php +++ b/tests/php/validation/test-class-amp-validation-manager.php @@ -1907,7 +1907,7 @@ public function test_decorate_shortcode_and_filter_source() { // This will be called after `do_shortcode` in WP 6.4 and later. // @see . - if ( version_compare( get_bloginfo( 'version' ), '6.3', '<=' ) ) { + if ( version_compare( get_bloginfo( 'version' ), '6.4-alpha', '<' ) ) { $sources[] = [ 'type' => 'core', 'name' => 'wp-includes', From 08e20ffdfff095ea687d15299a6d31c9ef7dd6ed Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Fri, 6 Oct 2023 22:53:28 +0530 Subject: [PATCH 08/17] Fix test cases in LikelyCulpritDetectorTest --- .../DevTools/LikelyCulpritDetectorTest.php | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/php/src/DevTools/LikelyCulpritDetectorTest.php b/tests/php/src/DevTools/LikelyCulpritDetectorTest.php index c72a132df37..af0618a2d2c 100644 --- a/tests/php/src/DevTools/LikelyCulpritDetectorTest.php +++ b/tests/php/src/DevTools/LikelyCulpritDetectorTest.php @@ -128,13 +128,13 @@ public function single_step_trace_data() { ], 'parent theme' => [ - [ get_template_directory() . '/functions.php' ], + [ '{{ get_template_directory }}/functions.php' ], 'theme', 'default', ], 'child theme' => [ - [ get_stylesheet_directory() . '/functions.php' ], + [ '{{ get_stylesheet_directory }}/functions.php' ], 'theme', 'default', ], @@ -167,8 +167,8 @@ public function multi_step_trace_data() { __FILE__, // AMP plugin is skipped. WP_PLUGIN_DIR . '/bad-plugin/bad-plugin.php', // <== Likely culprit. WP_CONTENT_DIR . '/mu-plugins/bad-mu-plugin.php', - get_template_directory() . '/functions.php', - get_stylesheet_directory() . '/functions.php', + '{{ get_template_directory }}/functions.php', + '{{ get_stylesheet_directory }}/functions.php', ], 'plugin', 'bad-plugin', @@ -180,8 +180,8 @@ public function multi_step_trace_data() { __FILE__, // AMP plugin is skipped. WP_CONTENT_DIR . '/mu-plugins/bad-mu-plugin.php', // <== Likely culprit. WP_PLUGIN_DIR . '/bad-plugin/bad-plugin.php', - get_template_directory() . '/functions.php', - get_stylesheet_directory() . '/functions.php', + '{{ get_template_directory }}/functions.php', + '{{ get_stylesheet_directory }}/functions.php', ], 'mu-plugin', 'bad-mu-plugin.php', @@ -191,10 +191,10 @@ public function multi_step_trace_data() { [ ABSPATH . '/wp-includes/some-file.php', // Core is skipped. __FILE__, // AMP plugin is skipped. - get_template_directory() . '/functions.php', // <== Likely culprit. + '{{ get_template_directory }}/functions.php', // <== Likely culprit. WP_PLUGIN_DIR . '/bad-plugin/bad-plugin.php', WP_CONTENT_DIR . '/mu-plugins/bad-mu-plugin.php', - get_stylesheet_directory() . '/functions.php', + '{{ get_stylesheet_directory }}/functions.php', ], 'theme', 'default', @@ -204,10 +204,10 @@ public function multi_step_trace_data() { [ ABSPATH . '/wp-includes/some-file.php', // Core is skipped. __FILE__, // AMP plugin is skipped. - get_stylesheet_directory() . '/functions.php', // <== Likely culprit. + '{{ get_stylesheet_directory }}/functions.php', // <== Likely culprit. WP_PLUGIN_DIR . '/bad-plugin/bad-plugin.php', WP_CONTENT_DIR . '/mu-plugins/bad-mu-plugin.php', - get_template_directory() . '/functions.php', + '{{ get_template_directory }}/functions.php', ], 'theme', 'default', @@ -275,7 +275,12 @@ public function test_analyze_trace( $file_stack, $expected_type, $expected_name private function get_trace_from_file_stack( $file_stack ) { return array_map( static function ( $file ) { - return [ 'file' => $file ]; + $file = str_replace( '{{ get_template_directory }}', get_template_directory(), $file ); + $file = str_replace( '{{ get_stylesheet_directory }}', get_stylesheet_directory(), $file ); + + return [ + 'file' => $file, + ]; }, $file_stack ); From c598023c79673e318f21ff7bb9ff855cf60b1d12 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Fri, 6 Oct 2023 22:56:17 +0530 Subject: [PATCH 09/17] Update wp emoji styles removal based on latest core changes @see . --- includes/class-amp-theme-support.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php index 00b5e46a04a..f2b6bc9c98a 100644 --- a/includes/class-amp-theme-support.php +++ b/includes/class-amp-theme-support.php @@ -84,6 +84,13 @@ class AMP_Theme_Support { */ const READER_MODE_TEMPLATE_DIRECTORY = 'amp'; + /** + * `wp-emoji-styles` styles handle. + * + * @var string + */ + const WP_EMOJI_STYLES = 'wp-emoji-styles'; + /** * Sanitizers, with keys as class names and values as arguments. * @@ -848,7 +855,13 @@ public static function add_hooks() { // Prevent emoji detection and emoji loading since platforms/browsers now support emoji natively (and Twemoji is not AMP-compatible). add_filter( 'wp_resource_hints', [ __CLASS__, 'filter_resource_hints_to_remove_emoji_dns_prefetch' ], 10, 2 ); remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); - remove_action( 'wp_print_styles', 'print_emoji_styles' ); + + if ( function_exists( 'wp_enqueue_emoji_styles' ) ) { + // By default, emoji styles are enqueued at priority 10. + add_action( 'wp_print_styles', [ __CLASS__, 'dequeue_emoji_styles' ], 11 ); + } else { + remove_action( 'wp_print_styles', 'print_emoji_styles' ); + } // The AMP version of the skip link is implemented by AMP_Accessibility_Sanitizer::add_skip_link(). remove_action( 'wp_footer', 'gutenberg_the_skip_link' ); @@ -907,6 +920,15 @@ static function() { ); } + /** + * Dequeue emoji styles. + * + * @since 2.4.3 + */ + public static function dequeue_emoji_styles() { + wp_dequeue_style( self::WP_EMOJI_STYLES ); + } + /** * Filter resource hints to remove the emoji CDN (s.w.org). * From 6986676946ecf62590b0f7d92e33b03ad6263e0c Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Fri, 6 Oct 2023 22:57:33 +0530 Subject: [PATCH 10/17] Update Test_AMP_Theme_Support test cases --- tests/php/test-class-amp-theme-support.php | 37 +++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/php/test-class-amp-theme-support.php b/tests/php/test-class-amp-theme-support.php index 3870a22be84..00630165ab8 100644 --- a/tests/php/test-class-amp-theme-support.php +++ b/tests/php/test-class-amp-theme-support.php @@ -55,6 +55,7 @@ public function set_up() { unset( $GLOBALS['current_screen'] ); delete_option( AMP_Options_Manager::OPTION_NAME ); // Make sure default reader mode option does not override theme support being added. remove_theme_support( 'amp' ); + switch_theme( 'default' ); $this->register_core_themes(); } @@ -777,7 +778,12 @@ public function test_add_hooks() { $this->assertEquals( 10, has_filter( 'wp_resource_hints', [ self::TESTED_CLASS, 'filter_resource_hints_to_remove_emoji_dns_prefetch' ] ) ); $this->assertFalse( has_action( 'wp_head', 'print_emoji_detection_script' ) ); - $this->assertFalse( has_action( 'wp_print_styles', 'print_emoji_styles' ) ); + + if ( function_exists( 'wp_enqueue_emoji_styles' ) ) { + $this->assertEquals( 11, has_action( 'wp_print_styles', [ self::TESTED_CLASS, 'dequeue_emoji_styles' ] ) ); + } else { + $this->assertFalse( has_action( 'wp_print_styles', 'print_emoji_styles' ) ); + } $this->assertEquals( 20, has_action( 'wp_head', 'amp_add_generator_metadata' ) ); $this->assertEquals( 0, has_action( 'wp_enqueue_scripts', [ self::TESTED_CLASS, 'enqueue_assets' ] ) ); @@ -1043,17 +1049,27 @@ function() { AMP_Theme_Support::init_admin_bar(); $this->assertEquals( 10, has_filter( 'style_loader_tag', [ AMP_Theme_Support::class, 'filter_admin_bar_style_loader_tag' ] ) ); $this->assertEquals( 10, has_filter( 'script_loader_tag', [ AMP_Theme_Support::class, 'filter_admin_bar_script_loader_tag' ] ) ); - $this->assertFalse( has_action( 'wp_head', $callback ) ); + + if ( ! function_exists( 'wp_enqueue_admin_bar_header_styles' ) ) { + $this->assertFalse( has_action( 'wp_head', $callback ) ); + } + + remove_action( 'wp_print_styles', 'print_emoji_styles' ); + ob_start(); wp_print_styles(); wp_print_scripts(); $output = ob_get_clean(); - $this->assertStringContainsString( '