-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Theme Sheet: Use information from WordPress.org for themes on Jetpack sites #9875
Conversation
ae46bfe
to
f9ac0e8
Compare
@@ -12,10 +12,7 @@ import { isRequestingActiveTheme } from 'state/themes/selectors'; | |||
|
|||
class QueryActiveTheme extends Component { | |||
static propTypes = { | |||
siteId: PropTypes.oneOfType( [ | |||
PropTypes.number, | |||
PropTypes.oneOf( [ 'wpcom' ] ) |
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.
A theme can only be active on an actual site, not on all of WP.com 😄
(Discovered while adding wporg
to some other propTypes
and schema
s.)
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.
Code wise looks good, although hard to follow: to much stuff is going on at the same time. 👍
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.
Code looks good. I've tested with both wporg and custom themes on a Jetpack site.
Only glaring thing is the empty Features
panel.
// * If it's a premium theme | ||
// * If it's on a Jetpack site, and the theme object doesn't have a 'download' attr | ||
// Note that not having a 'download' attr would be permissible for a theme on WPCOM | ||
// since we don't provide any for some themes found on WordPress.org (notably the 'Twenties'). |
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.
(notably the 'Twenties')
Think it is just Twenty Sixteen
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.
I checked a bunch of other Twenties to which the same seems to apply, but possibly not all of them.
@@ -451,6 +469,7 @@ const ThemeSheet = React.createClass( { | |||
return ( | |||
<Main className="theme__sheet"> | |||
<QueryTheme themeId={ this.props.id } siteId={ siteIdOrWpcom } /> | |||
{ isJetpack && <QueryTheme themeId={ this.props.id } siteId="wporg" /> } |
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.
Do we need the two instances of <QueryTheme/>
?
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.
Yeah, the first one fetches the theme object from the JP site, and the second one fetches the supplementary one from the WP.org API.
context( 'with a wpcom site', () => { | ||
useNock( ( nock ) => { | ||
nock( 'https://public-api.wordpress.com:443' ) | ||
.persist() |
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.
I don't think these persist
calls are generally necessary unless you want the same result multiple times.
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.
Breaks tests if I remove it for all wpcom
, wporg
, and JP 😕
Yeah, sorry about that. I guess I could've split it into even more PRs, but then again, I already did that twice, so I wanted to get it done... |
839faf9
to
5404e83
Compare
4eedad4
to
4276754
Compare
…Id key There's no such thing as an active theme on all of WP.com :-)
6e80e0f
to
738baab
Compare
Done in 8cbee7e |
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.
(Mini-fix to |
const term = isValidTerm( item.slug ) ? item.slug : `feature:${ item.slug }`; | ||
return ( | ||
<li key={ 'theme-features-item-' + item.slug }> | ||
<a href={ `/design/filter/${ term }/${ siteSlug || '' }` }>{ item.name }</a> | ||
{ isJetpack | ||
? <a>{ item.name }</a> |
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.
Just curious if adding the <a>
is actually doing anything here. Are styles applied to it because its an anchor?
Maybe it could just be { item.name }
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.
Yeah, we're styling it. (I had removed it and noticed it didn't look the same.) I opted for keeping the element instead of tweaking the styling 😄
Keep it only if it's already working flawlessly. If you need even just 10 minutes of extra work to make it work across .com/Jetpack (how does Jetpack zip the theme to allow its download?) remove it. It's not a priority right now.
Ok, let me branch it out! :) For Jetpack:
|
Oh, maybe I wasn't quite clear -- we're only showing the Download link if the theme is found on WP.org, and has a download URI (pointing to a ready-made zip, that is) already. Otherwise we're hiding it. |
Ok cool, I thought the whole "check .org's availability" was postponed. :) Excellent then! :D |
Hehe, no, that's what this PR does 😄 (cf. #9869 (comment)):
|
Oh, I was trying to implement #9869 (comment)
So if you look at the 'Support' tab's forum link for a theme on a JP site that's also found on WP.org, it will point to that theme's WP.org support forum right now. |
Same as the above. I was working on the assumption .org's checking wasn't included right now, in that case:
|
Allows us to find out if a theme on a Jetpack site is present on WP.org and act accordingly.
Implements #9869 (comment):
(Question about item 4. -- I'm not sure I've implemented it correctly, I'm currently not removing the entire 'Support' tab but only the link to the theme forum. I wasn't sure I understood the idea correctly, and I thought the other two links might still make some sense even on a JP site. Clarification needed 😄)
To do all that, this PR:
fetchThemeInformation
method tolib/wporg
requestTheme
to hit that endpoint ifsiteId === 'wporg'
, thus putting themes fetched from there in a newwporg
subtreegetTheme
selector so that if a theme on a JP site is requested, supplementary data (upon availability) such as demo URI, download URI, ortaxonomies
is merged into the returned object.isWporgTheme( state, themeId )
aliasing!! getTheme( state, 'wpcom', themeId )
To test:
(For reference, here's an example response containing all the fields we can get from WP.org: https://api.wordpress.org/themes/info/1.1/?action=theme_information&request%5Bslug%5D=twentyfourteen)