WordPress.org

Making WordPress.org

Opened 4 years ago

Closed 3 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)

1113.diff (2.8 KB) - added by coreymckrill 3 years ago.

Download all attachments as: .zip

Change History (6)

#1 @iandunn
4 years ago

  • Keywords good-first-bug added

#2 @iandunn
4 years ago

  • Owner set to iandunn
  • Status changed from new to accepted

@coreymckrill
3 years ago

#3 @coreymckrill
3 years ago

  • Keywords has-patch added; needs-patch removed

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.

#4 @iandunn
3 years ago

That looks great, thanks Corey :)

The only things I might change would be a couple small readability things:

  1. If you use \WordCamp\RemoteCSS; at the start of the file, you can then call RemoteCSS\get_safe_css_post instead of \WordCamp\RemoteCSS\get_safe_css_post
  2. 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.
  3. 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.

Last edited 3 years ago by iandunn (previous) (diff)

#5 @coreymckrill
3 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 4398:

Site Cloner: prepend Remote CSS rules to Custom CSS stylesheet

Check the source site for a cached version of a Remote CSS stylesheet
and combine it with any Jetpack Custom CSS before applying to the
recipient site.

Fixes #1113

Note: See TracTickets for help on using tickets.