@@ -158,18 +158,17 @@ protected static function get_theme_features_config( $theme_slug ) {
158158 // Twenty Nineteen.
159159 case 'twentynineteen ' :
160160 return [
161- 'dequeue_scripts ' => [
161+ 'dequeue_scripts ' => [
162162 'twentynineteen-skip-link-focus-fix ' , // This is part of AMP. See <https://github.com/ampproject/amphtml/issues/18671>.
163163 'twentynineteen-priority-menu ' ,
164164 'twentynineteen-touch-navigation ' , // @todo There could be an AMP implementation of this, similar to what is implemented on ampproject.org.
165165 ],
166- 'remove_actions ' => [
166+ 'remove_actions ' => [
167167 'wp_print_footer_scripts ' => [
168168 'twentynineteen_skip_link_focus_fix ' , // See <https://github.com/WordPress/twentynineteen/pull/47>.
169169 ],
170170 ],
171- 'add_twentynineteen_masthead_styles ' => [],
172- 'adjust_twentynineteen_images ' => [],
171+ 'adjust_twentynineteen_images ' => [],
173172 'enable_determine_hero_images_transformer ' => [],
174173 ];
175174
@@ -938,121 +937,20 @@ static function() use ( $method ) {
938937 }
939938
940939 /**
941- * Add required styles for featured image header in Twenty Nineteen.
942- *
943- * The following is necessary because the styles in the theme apply to the featured img,
944- * and the CSS parser will then convert the selectors to amp-img. Nevertheless, object-fit
945- * does not apply on amp-img and it needs to apply on an actual img.
946- *
947- * @link https://github.com/WordPress/wordpress-develop/blob/5.0/src/wp-content/themes/twentynineteen/style.css#L2276-L2299
948- * @since 1.0
949- */
950- public static function add_twentynineteen_masthead_styles () {
951- add_action (
952- 'wp_enqueue_scripts ' ,
953- static function () {
954- ob_start ();
955- ?>
956- <style>
957- .site-header.featured-image .site-featured-image .post-thumbnail amp-img > img {
958- height: auto;
959- left: 50%;
960- max-width: 1000%;
961- min-height: 100%;
962- min-width: 100vw;
963- position: absolute;
964- top: 50%;
965- transform: translateX(-50%) translateY(-50%);
966- width: auto;
967- z-index: 1;
968- /* When image filters are active, make it grayscale to colorize it blue. */
969- }
970-
971- @supports (object-fit: cover) {
972- .site-header.featured-image .site-featured-image .post-thumbnail amp-img > img {
973- height: 100%;
974- left: 0;
975- object-fit: cover;
976- top: 0;
977- transform: none;
978- width: 100%;
979- }
980- }
981- </style>
982- <?php
983- $ styles = str_replace ( [ '<style> ' , '</style> ' ], '' , ob_get_clean () );
984- wp_add_inline_style ( get_template () . '-style ' , $ styles );
985- },
986- 11
987- );
988- }
989-
990- /**
991- * Add required styles for video and image headers.
940+ * Add required styles for Twenty Seventeen header.
992941 *
993- * This is currently used exclusively for Twenty Seventeen .
942+ * This is required since JS is not applying the required styles at runtime .
994943 *
995944 * @since 1.0
996- * @link https://github.com/WordPress/wordpress-develop/blob/1af1f65a21a1a697fb5f33027497f9e5ae638453/src/wp-content/themes/twentyseventeen/style.css#L1687
997- * @link https://github.com/WordPress/wordpress-develop/blob/1af1f65a21a1a697fb5f33027497f9e5ae638453/src/wp-content/themes/twentyseventeen/style.css#L1743
998945 */
999946 public static function add_twentyseventeen_masthead_styles () {
1000- /*
1001- * The following is necessary because the styles in the theme apply to img and video,
1002- * and the CSS parser will then convert the selectors to amp-img and amp-video respectively.
1003- * Nevertheless, object-fit does not apply on amp-img and it needs to apply on an actual img.
1004- */
1005947 add_action (
1006948 'wp_enqueue_scripts ' ,
1007949 static function () {
1008950 $ is_front_page_layout = ( is_front_page () && 'posts ' !== get_option ( 'show_on_front ' ) ) || ( is_home () && is_front_page () );
1009951 ob_start ();
1010952 ?>
1011953 <style>
1012- .has-header-image .custom-header-media amp-img > img,
1013- .has-header-video .custom-header-media amp-video > video{
1014- position: fixed;
1015- height: auto;
1016- left: 50%;
1017- max-width: 1000%;
1018- min-height: 100%;
1019- min-width: 100%;
1020- min-width: 100vw; /* vw prevents 1px gap on left that 100% has */
1021- width: auto;
1022- top: 50%;
1023- padding-bottom: 1px; /* Prevent header from extending beyond the footer */
1024- -ms-transform: translateX(-50%) translateY(-50%);
1025- -moz-transform: translateX(-50%) translateY(-50%);
1026- -webkit-transform: translateX(-50%) translateY(-50%);
1027- transform: translateX(-50%) translateY(-50%);
1028- }
1029- .has-header-image:not(.twentyseventeen-front-page):not(.home) .custom-header-media amp-img > img {
1030- bottom: 0;
1031- position: absolute;
1032- top: auto;
1033- -ms-transform: translateX(-50%) translateY(0);
1034- -moz-transform: translateX(-50%) translateY(0);
1035- -webkit-transform: translateX(-50%) translateY(0);
1036- transform: translateX(-50%) translateY(0);
1037- }
1038- /* For browsers that support object-fit */
1039- @supports ( object-fit: cover ) {
1040- .has-header-image .custom-header-media amp-img > img,
1041- .has-header-video .custom-header-media amp-video > video,
1042- .has-header-image:not(.twentyseventeen-front-page):not(.home) .custom-header-media amp-img > img {
1043- height: 100%;
1044- left: 0;
1045- -o-object-fit: cover;
1046- object-fit: cover;
1047- top: 0;
1048- -ms-transform: none;
1049- -moz-transform: none;
1050- -webkit-transform: none;
1051- transform: none;
1052- width: 100%;
1053- }
1054- }
1055-
1056954 .navigation-top.site-navigation-fixed {
1057955 display: none;
1058956 }
@@ -1555,7 +1453,7 @@ static function() {
15551453 font-size: 32px;
15561454 line-height: 46px;
15571455 }
1558- .featured-content .post-thumbnail amp-img > img {
1456+ .featured-content .post-thumbnail amp-img {
15591457 object-fit: cover;
15601458 object-position: top;
15611459 }
0 commit comments