From 4fb548aa8883a9fd80c7849fb74e51cf5edb8366 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Nov 2018 22:26:25 -0800 Subject: [PATCH 1/3] Fix object-fit:cover style of Twenty Nineteen featured image --- .../class-amp-core-theme-sanitizer.php | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/includes/sanitizers/class-amp-core-theme-sanitizer.php b/includes/sanitizers/class-amp-core-theme-sanitizer.php index 1221d04e637..524e54009fc 100644 --- a/includes/sanitizers/class-amp-core-theme-sanitizer.php +++ b/includes/sanitizers/class-amp-core-theme-sanitizer.php @@ -53,16 +53,17 @@ class AMP_Core_Theme_Sanitizer extends AMP_Base_Sanitizer { protected static $theme_features = array( // Twenty Nineteen. 'twentynineteen' => array( - 'dequeue_scripts' => array( + 'dequeue_scripts' => array( 'twentynineteen-skip-link-focus-fix', // This is part of AMP. See . 'twentynineteen-priority-menu', 'twentynineteen-touch-navigation', // @todo There could be an AMP implementation of this, similar to what is implemented on ampproject.org. ), - 'remove_actions' => array( + 'remove_actions' => array( 'wp_print_footer_scripts' => array( 'twentynineteen_skip_link_focus_fix', // See . ), ), + 'add_twentynineteen_masthead_styles' => array(), ), // Twenty Seventeen. @@ -526,6 +527,51 @@ protected static function get_twentyseventeen_navigation_outer_height() { return 72; } + /** + * Add required styles for featured image header in Twenty Nineteen. + * + * The following is necessary because the styles in the theme apply to the featured img, + * and the CSS parser will then convert the selectors to amp-img. Nevertheless, object-fit + * does not apply on amp-img and it needs to apply on an actual img. + * + * @link https://github.com/WordPress/wordpress-develop/blob/5.0/src/wp-content/themes/twentynineteen/style.css#L2276-L2299 + * @since 1.0 + */ + public static function add_twentynineteen_masthead_styles() { + add_action( 'wp_enqueue_scripts', function() { + ?> + + ', '' ), '', ob_get_clean() ); + wp_add_inline_style( get_template() . '-style', $styles ); + }, 11 ); + } + /** * Add required styles for video and image headers. * From 322be16bd78d4c36261d2df83cf4902c4d96995c Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Nov 2018 22:29:39 -0800 Subject: [PATCH 2/3] Fix remaining gutenberg_get_jed_locale_data() usage missed in c5b505ad9 --- tests/validation/test-class-amp-validation-manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/validation/test-class-amp-validation-manager.php b/tests/validation/test-class-amp-validation-manager.php index 671e6fa13f5..4164400aafd 100644 --- a/tests/validation/test-class-amp-validation-manager.php +++ b/tests/validation/test-class-amp-validation-manager.php @@ -1282,7 +1282,7 @@ public function test_print_plugin_notice() { * @covers AMP_Validation_Manager::enqueue_block_validation() */ public function test_enqueue_block_validation() { - if ( ! function_exists( 'gutenberg_get_jed_locale_data' ) ) { + if ( ! function_exists( 'wp_get_jed_locale_data' ) && ! function_exists( 'gutenberg_get_jed_locale_data' ) ) { $this->markTestSkipped( 'Gutenberg not available.' ); } From 9d9527287da594acd89dffbf511852dba898de8b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 16 Nov 2018 07:56:28 -0800 Subject: [PATCH 3/3] Add missing ob_start() call --- includes/sanitizers/class-amp-core-theme-sanitizer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/sanitizers/class-amp-core-theme-sanitizer.php b/includes/sanitizers/class-amp-core-theme-sanitizer.php index 524e54009fc..a7010a27f3a 100644 --- a/includes/sanitizers/class-amp-core-theme-sanitizer.php +++ b/includes/sanitizers/class-amp-core-theme-sanitizer.php @@ -539,6 +539,7 @@ protected static function get_twentyseventeen_navigation_outer_height() { */ public static function add_twentynineteen_masthead_styles() { add_action( 'wp_enqueue_scripts', function() { + ob_start(); ?>