Opened 9 years ago
Closed 8 years ago
#1113 closed enhancement (fixed)
Site Cloner: Add support for Remote CSS plugin
Reported by: | iandunn | Owned by: | iandunn |
---|---|---|---|
Milestone: | Priority: | normal | |
Component: | WordCamp Site & Plugins | Keywords: | good-first-bug has-patch |
Cc: |
Description
In the near future, WordCamp.org will be able to import CSS from remote Git repositories, to allow organizing teams to use a traditional development workflow instead of Jetpack's CSS editor.
When that launches, the Site Cloner will need to be able to import the CSS that the site uses.
I think most teams who use the Site Cloner will be doing so because they don't have the resources to build a new design from scratch, which makes it unlikely that they'd want to use a remote repository, and will probably be using the Jetpack editor.
I also don't see a good way to support the Remote CSS approach directly; we wouldn't want to use the source site's repository, because any changes to it would cause unintended changes to the new site.
So, I think it's probably best to just copy the cached/sanitized CSS from the source site, and then add that to Jetpack's CSS on the new site.
It should be prepended to any Jetpack CSS that's also being pulled in, to maintain the same cascading order that the Remote CSS plugin implements.
Attachments (1)
Change History (6)
#4
@
8 years ago
That looks great, thanks Corey :)
The only things I might change would be a couple small readability things:
- If you
use \WordCamp\RemoteCSS;
at the start of the file, you can then callRemoteCSS\get_safe_css_post
instead of\WordCamp\RemoteCSS\get_safe_css_post
- It's not obvious why was the
str_replace
is needed, so it might be worth leaving a comment to explain. It looks like Jetpack doesn't comment it either, though. Was that just a precaution, or did you run into a specific problem? Either way it'd probably be good to document that in the code. - You can avoid some of the nesting by returning early, which makes it more readable. Same thing for the
instanceof
check. It is nice to have a single point of return, but I think it's ok to have multiple points as long as they're at the very start of the function.
if ( ! function_exists( '\WordCamp\RemoteCSS\get_safe_css_post' ) ) { return $remote_css; }
Those are obviously small things, though, and open to interpretation, so feel free to use your judgement and go with what you think is best.
Added a patch looks for Remote CSS rules and prepends them to the Jetpack CSS before applying to the recipient site.
It also adds inline comments specifying the source of each block of CSS.