Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hreflang link tags #54

Merged
merged 3 commits into from
Aug 11, 2022
Merged

Add hreflang link tags #54

merged 3 commits into from
Aug 11, 2022

Conversation

tellyworth
Copy link
Contributor

This is basically a straight port of the hreflang_link_attributes function from the wporg theme.

I made a couple of quick edits so it runs in local testing without GlotPress installed.

Fixes #43.

Props @dd32.

How to test the changes in this Pull Request:

  1. Refresh the main page.
  2. View source.
  3. Confirm the presence of at least two <link rel="alternate" href="..." hreflang=".."> elements.

I made a couple of quick edits so it runs in local testing without GlotPress installed.
@tellyworth tellyworth added the [Component] Backend Anything wp-admin or PHP-related label Aug 8, 2022
return strcasecmp( $a->hreflang, $b->hreflang );
} );

wp_cache_set( 'local-sites', $sites, 'locale-associations' );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about making the cache_set conditional on count( $sites ) > 2 so my local testing bypass can't poison the cache in production if it somehow executed the wrong code path.


foreach ( $sites as $site ) {
$url = sprintf(
'https://%swordpress.org%s',
Copy link
Member

Choose a reason for hiding this comment

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

I guess we don't really care that this will reference wordpress.org as the hreflang when it's being used locally, so I see no problem keeping the production domain here.

@tellyworth
Copy link
Contributor Author

I think this is good to go now but let's wait till after the DC review.

@tellyworth tellyworth merged commit 9b4e4f3 into trunk Aug 11, 2022
@tellyworth tellyworth deleted the add/hreflang branch August 11, 2022 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Backend Anything wp-admin or PHP-related
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add hreflang tags
2 participants