Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

AMP compatibility #155

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ function twentynineteen_setup() {
endif;
add_action( 'after_setup_theme', 'twentynineteen_setup' );


/**
* Check if AMP plugin is enabled and if AMP endpoint.
*/
function twentynineteen_is_amp() {
return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint();
}

/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
Expand All @@ -117,8 +125,6 @@ function twentynineteen_content_width() {
function twentynineteen_scripts() {
wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri() );

wp_enqueue_script( 'twentynineteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );

if ( is_singular() && twentynineteen_can_show_post_thumbnail() ) {
wp_add_inline_style( 'twentynineteen-style', twentynineteen_header_featured_image_css() );
}
Expand All @@ -129,6 +135,20 @@ function twentynineteen_scripts() {
}
add_action( 'wp_enqueue_scripts', 'twentynineteen_scripts' );

/**
* Fix skip link focus in IE11.
*
* This does not enqueue the script because it is tiny and because it is only for IE11,
* thus it does not warrant having an entire dedicated blocking script being loaded.
*
*/
function _twentynineteen_skip_link_focus_fix() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change shouldn't be included yet. It's dependent on #47. Also, once/if that PR is merged, this function will then need the is_amp as seen in the WP Rig PR: wprig/wprig#139

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@westonruter should we just revert back to the previous for now until #47 is merged?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

echo '<script>';
echo file_get_contents( get_template_directory() . '/js/skip-link-focus-fix.js' );
echo '</script>';
}
add_action( 'wp_print_footer_scripts', '_twentynineteen_skip_link_focus_fix' );

/**
* SVG Icons class.
*/
Expand Down
2 changes: 1 addition & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
westonruter marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened a separate PR just for this one change: #199

<link rel="profile" href="https://gmpg.org/xfn/11" />
<?php wp_head(); ?>
</head>
Expand Down