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

Convert head[profile] attribute to link[rel=profile] #4193

Merged
merged 5 commits into from
Jan 29, 2020

Conversation

kienstra
Copy link
Contributor

@kienstra kienstra commented Jan 29, 2020

Summary

Like Weston mentioned, head[profile] is invalid, so this converts it to a link[rel=profile].

To test this, I made this change in Twenty Twenty:

diff --git a/header.php b/header.php
index d66d08f..99b02e0 100644
--- a/header.php
+++ b/header.php
@@ -13,13 +13,11 @@
 
 <html class="no-js" <?php language_attributes(); ?>>
 
-       <head>
+       <head profile="https://example-profile.com">
 
                <meta charset="<?php bloginfo( 'charset' ); ?>">
                <meta name="viewport" content="width=device-width, initial-scale=1.0" >
 
-               <link rel="profile" href="https://gmpg.org/xfn/11">
-
                <?php wp_head(); ?>
 
        </head>

...and with this PR, the head[profile] is stripped and moved to a new head > link[rel=profile]:

rel-profile

In the unlikely case that there's already a head > link[rel=profile], this doesn't create a new one. It simply strips the head[profile] if it exists.

Fixes #4131

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

Like Weston mentioned, that was invalid HTML5,
so convert it to a link[rel=profile].
@googlebot googlebot added the cla: yes Signed the Google CLA label Jan 29, 2020
@kienstra
Copy link
Contributor Author

@todo: consider a case where there is both a head[profile] and a link[profile]. For example, Twenty Twenty has a link[profile], though it doesn't have a head[profile].

For example, Twenty Twenty has a link[rel=profile],
though it doesn't have a head[profile].
src/Dom/Document.php Outdated Show resolved Hide resolved
src/Dom/Document.php Outdated Show resolved Hide resolved
@westonruter westonruter added this to the v1.5 milestone Jan 29, 2020
src/Dom/Document.php Outdated Show resolved Hide resolved
Using Weston's suggested code,
handle this case.
@westonruter
Copy link
Member

consider a case where there is both a head[profile] and a link[profile]. For example, Twenty Twenty has a link[profile], though it doesn't have a head[profile].

Nice. I didn't notice that Twenty Twenty had this. Added validation that the normalization here is the right approach.

@westonruter westonruter merged commit b04f801 into develop Jan 29, 2020
@westonruter westonruter deleted the add/head-profile-conversion branch January 29, 2020 21:53
schlessera added a commit that referenced this pull request Mar 7, 2020
westonruter added a commit that referenced this pull request Mar 7, 2020
…nt/4326-tiktok-embed

* 'develop' of github.com:ampproject/amp-wp:
  Fix ZIP build after namespace rename
  Add missing namespace to common lib tests
  Fix phpcs issues in common and optimizer libs; include tests dir in cs/cbf scripts
  Fix and harden normalizeDomStructure when document lacks <html>
  Move any nodes appearing after </body> to be appended to the body
  Skip moving comments outside of html tags
  Merge changes from #4193
  Merge changes into moved Dom\Document class
  Change root namespace for all three packages
  Deal with whitespace around comments
  Preserve comment positions (without breaking structure)
  Update src/Dom/Document.php
  Support content after html end tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically convert head[profile] to head > link[rel=profile]
3 participants