-
Notifications
You must be signed in to change notification settings - Fork 113
Adds wordpress detection #131
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
Adds wordpress detection #131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone brought up
Since WordPress 4.4, there should be a link element in the header with a rel attribute equal to api.w.org and a href attribute equal to the site's URL.
I think that's our strongest signal. Falling back on wp-includes sg.
I was thinking something like this, but I'm open to alternatives..
const hasAPILinkElem = ....
const hasWPIncludes = ...
if (!hasAPILinkElem || !hasWPIncludes) return false;
const generatorMeta = ...
const version = ...
if (version) return { version }
else return { version: UNKNOWN_VERSION };
library/libraries.js
Outdated
test: function (win) { | ||
if (!!document.querySelector('meta[name=generator][content^="WordPress"]')) { | ||
var versionName = document.querySelector("meta[name='generator']").getAttribute("content"); | ||
return { version: versionName.replace(/[^0-9\.]+/g,"") }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
over on https://wordpress.org/news/ i spotted WordPress 5.2-alpha-44796
so I think we'll need something different..
.replace(/^\w+\s/,'')
perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. The version can look like any one of:
5.1.2
5.1-beta2
5.0-RC1
5.2-alpha-44742-src
So yes, just removing 'WordPress '
from the beginning will be the way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh didn't know more than just numbered releases could be included. Fixed 👍
@paulirish Updated it to your suggestion. I think it looks good. One thing however: I used CC @Shelob9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree on the &&. :) good call.
this looks great.
@housseindjirdeh This looks good to me. |
Note: As of WordPress 6.3.0, sites will no longer be outputting this <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="https://example.com/wp-includes/wlwmanifest.xml"> The logic needs to be updated to not depend on it. See #203. |
CC @wardpeet @paulirish