WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 2 years ago

Last modified 17 months ago

#13774 closed task (blessed) (fixed)

Theme installer should support child themes

Reported by: westi Owned by: dd32
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.0
Component: Upgrade/Install Keywords: has-patch 3.4-early needs-testing
Focuses: Cc:

Description

The theme installer and by extension the theme repo should support child themes.

i.e. Handle update and install gracefully

This become more important now that there are a lot of child themes from TwentyTen likely to be created.

Attachments (5)

13774.diff (3.4 KB) - added by Otto42 3 years ago.
First stab at a patch for this
13774.2.diff (5.1 KB) - added by dd32 3 years ago.
child-theme-install.png (27.6 KB) - added by dd32 3 years ago.
child-theme-install-parent-fail.png (18.4 KB) - added by dd32 3 years ago.
13774.3.diff (7.0 KB) - added by dd32 3 years ago.

Download all attachments as: .zip

Change History (45)

comment:1 ptahdunbar4 years ago

  • Cc trac@… added

comment:2 scribu4 years ago

  • Cc scribu@… added

comment:3 follow-up: dougal4 years ago

  • Cc dougal added

This would definitely be great. I think it would spur a new wave of theme submissions.

I'm not sure how much infrastructure the Theme and Plugin repositories share, but it would also be interesting if the general idea could be abstracted to support plugin dependencies. Then we could develop plugins which purely provide API infrastructures that other plugins could build upon. For example, someone could create an OAuth support plugin, which other plugins could depend on to authenticate with Twitter, Photobucket, Google, Brightkite, Meetup, Netfix, etc.

Anyhow, back to the child-theme bits... I'm wondering if the details for child themes should show the screenshot for the parent theme, in addition to the child theme's screenshot, for comparison? I think that would be kinda neat. But OTOH, I worry that it could be confusing to novice users, if we can't present it in a clear way. Perhaps there could be a text link saying something like, "Bazzo is a child theme, based on the Foobar theme." And maybe 'Foobar' would be a link, which could popup an overlay showing the two screenshots?

comment:4 in reply to: ↑ 3 batmoo4 years ago

  • Cc batmoo@… added

Replying to dougal:

I'm not sure how much infrastructure the Theme and Plugin repositories share, but it would also be interesting if the general idea could be abstracted to support plugin dependencies. Then we could develop plugins which purely provide API infrastructures that other plugins could build upon. For example, someone could create an OAuth support plugin, which other plugins could depend on to authenticate with Twitter, Photobucket, Google, Brightkite, Meetup, Netfix, etc.

Definitely would be great to have something like this. In terms of the installation process, I have something we can use as a start.

A couple weeks back, I wrote an installer plugin for Google's Living Stories plugin, which automatically installs all the necessary dependencies for you. If a dependency is already installed, it skips it. It allows installation from the plugin directory or a custom URL. (The manual installation process involves installing a bunch of different plugins and theme in a specific order, which is an unnecessary huge pain!).

The installer is fairly abstracted as is and uses standard WordPress APIs, and if others see value in this, I'll abstract it out further and submit a patch. (I was originally envisioning using to it create something like a directory where people could create and submit plugin bundles, somewhat like Firefox add-on Collections, but that's a lofty dream.)

Code for the plugin is available here: http://code.google.com/p/living-stories/source/browse/installer/living-story-installer.php?repo=wordpress

comment:5 gazouteast4 years ago

  • Cc gazouteast added

+1 for this idea - both child themes and plug-in dependants

comment:6 lancewillett3 years ago

  • Cc lancewillett added

Otto423 years ago

First stab at a patch for this

comment:7 Otto423 years ago

Proposed patch will install the parent for a child theme from the repo, if the parent isn't already installed, when you attempt to install the child. Most of the installer changes are for visual prettiness, the actual installation is relatively simple.

comment:8 nacin3 years ago

  • Keywords has-patch 3.3-early added; needs-patch removed
  • Owner changed from dd32 to nacin
  • Status changed from new to accepted

Awesome. Marking for 3.3.

comment:9 nacin3 years ago

  • Milestone changed from Future Release to 3.3

comment:10 nacin3 years ago

  • Type changed from defect (bug) to task (blessed)

comment:11 WraithKenny3 years ago

  • Cc Ken@… added

comment:12 sabreuse3 years ago

  • Cc sabreuse@… added

comment:13 kovshenin3 years ago

  • Cc kovshenin@… added

comment:14 nerrad3 years ago

  • Cc nerrad added

comment:15 destastic3 years ago

  • Cc dcox@… added

comment:16 aaroncampbell3 years ago

  • Cc aaroncampbell added

dd323 years ago

dd323 years ago

comment:17 dd323 years ago

attachment 13774.2.diff added

  • My stab at implementing the parent theme installation.
  • Doesnt handle themes_api() failing on the parent installation
  • Doesnt handle parent theme installation failing (see screenshot) - It shouldn't offer activation/preview in that case.

I've taken the approach of having the parent themes installation details being included in the "steps" rather than having a duplicated header as in Otto's patch, this makes it less obvious that 2 themes are being installed, but also brings a few issues where the messages area easy to mistake for the child themes installation.

One suggestion I've got for that is something like this:

Installing Theme: Journalist 1.9 <-- page header

Downloading install package from http://wordpress.org/...zip…
Unpacking the package…
Installing the theme…
Successfully installed the theme Journalist 1.9.

Preparing to install the parent theme The Common Blog 1.5.3… <-- Same font size as the lines above and below
Downloading install package from http://wordpress.org/..zip…
Unpacking the package…
Installing the theme…
Successfully installed the parent theme The Common Blog 1.5.3.

..Actions on child theme here...

attachment child-theme-install.png added

  • Top: Installing a child theme, automatically installing the parent (Note: The above patch is forcing installation of that "parent" theme for all theme installs)
  • Bottom: Installing a child theme, when the parent is already installed.

attachment child-theme-install-parent-fail.png added

  • An example of the Child theme installing whilst the parent installation fails.

comment:18 nacin3 years ago

  • Owner changed from nacin to dd32
  • Status changed from accepted to assigned

comment:19 dd323 years ago

  • Keywords ui-feedback added
  • Status changed from assigned to accepted

comment:20 dd323 years ago

See also: #18490 - Add a message saying installation of the parent theme is needed. Close/Duplicate that one if this is completed for 3.3, otherwise, consider implementing that if time runs out here.

comment:21 jane3 years ago

  • Keywords ui-feedback removed

Suggested alterations to display. If parent theme not already installed:

Installing Theme: Child Theme 2.0

Downloading install package from http://wordpress.org/..zip

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Parent Theme 1.0.

Checking for parent theme, Parent Theme 1.0…

Preparing to install Parent Theme 1.0…

Downloading install package from http://wordpress.org/..zip

Unpacking the package…

Installing the theme…

Successfully installed parent theme, Parent Theme 1.0.

Successfully installed the theme Child Theme 2.0.

You may now begin using Child Theme 2.0.

Preview | Activate | Return to Themes


If parent theme is already installed:


Installing Theme: Child Theme 2.0

Downloading install package from http://wordpress.org/..zip

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Parent Theme 1.0.

Checking for parent theme, Parent Theme 1.0…

Parent theme, Parent Theme 1.0, is currently installed.

Successfully installed the theme Child Theme 2.0.

You may now begin using Child Theme 2.0.

Preview | Activate | Return to Themes

dd323 years ago

comment:22 follow-up: dd323 years ago

  • Keywords needs-testing added

attachment 13774.3.diff added

Just posting what I've got for testing, Most of Janes suggestions have been added with the exception of a few which I felt don't fit the current UI.

  • "You may now begin using Child Theme 2.0." is a good line, but isn't consistent, we should do that when we repaint the upgraders to make them all visually similar.
  • Combined the Theme Requires a parent theme... and checking for parent theme into a single string: This theme requires a parent theme, Checking if <strong>parent-theme</strong> is installed… It fits the overall flow better IMHO.
  • The failure string for when a Parent them can't be installed is currently: <strong>The parent theme could not be found, You will need to install the parent theme %s before you can use this child theme.</strong>
  • The This theme requires a parent theme, Checking if <strong>parent-theme</strong> is installed… line uses the parent theme slug, as this is what is within the style.css file.. It could be altered to display the actual themes name (But it'll do that /after/ it's searched for the theme being installed and checking the installer API..)

Examples:
Parent Theme already installed:

<h2>Installing Theme: Child Theme 3.0</h2>

Downloading install package from http://wordpress.org/....zip…

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Checking if <strong>parent-theme</strong> is installed…

The Parent theme, <strong>Parent Theme 2.0</strong>, is currently installed.

Successfully installed the theme <strong>Child Theme 3.0</strong>.

Preview | Activate | Return to Theme Installer

Parent Theme Not Installed

<h2>Installing Theme: Child Theme 3.0</h2>

Downloading install package from http://wordpress.org/...zip…

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Checking if <strong>parent-theme</strong> is installed…

Preparing to install <strong>Parent Theme 2.0</strong>…

Downloading install package from http://wordpress.org/.zip…

Unpacking the package…

Installing the theme…

Successfully installed the parent theme <strong>Parent Theme 2.0</strong>.

Successfully installed the theme <strong>Child Theme 3.0</strong>.

Preview | Activate | Return to Theme Installer

Parent Theme can't be installed

<h2>Installing Theme: Child Theme 3.0</h2>

Downloading install package from http://wordpress.org/.....zip…

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Checking if <strong>non-existant-theme</strong> is installed…

<strong>The parent theme could not be found, You will need to install the parent theme non-existant-theme before you can use this child theme.</strong>

Successfully installed the theme <strong>Child Theme 3.0</strong>.

Return to Theme Installer

The Final case of "Child's installed, Parent Failed, It was a success!" wording is a bit disconnected, but that's quite common with errors in the upgraders right now, Ideally they should all be fixed at the same time rather than wrapped in this patch.

This is all good for testing now, Note however, That this is not as simple to test as no child themes are currently available in the Extend directory, Line 679 of the patch forces all install attempts to have "The Common Blog" as a parent theme.. So just imagine that's a parent (or change it to a non-existant theme for testing there).

It also works for themes uploaded from zip files:

Installing Theme from uploaded file: twentyeleven-child.zip

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Checking if twentyeleven is installed…

Preparing to install Twenty Eleven 1.2…

Downloading install package from http://wordpress.org/extend/themes/download/twentyeleven.1.2.zip…

Unpacking the package…

Installing the theme…

Successfully installed the parent theme Twenty Eleven 1.2.

Theme installed successfully.

Preview | Activate | Return to Themes page

comment:23 in reply to: ↑ 22 SergeyBiryukov3 years ago

Replying to dd32:

This is all good for testing now, Note however, That this is not as simple to test as no child themes are currently available in the Extend directory

FWIW, I've found a couple:
http://wordpress.org/extend/themes/multi
http://wordpress.org/extend/themes/shelter

comment:24 dd323 years ago

FWIW, I've found a couple:

Thanks! I didn't even think they were accepted in the repo yet. There are a few BuddyPress child themes as well it seems.

comment:25 Otto423 years ago

They're not accepted yet generally, but I put through a couple extras to help us test things with.

http://wordpress.org/extend/themes/mazeld is another one. It uses twenty-ten as the base, so it's handy for testing the parent-theme-already-exists case.

Version 0, edited 3 years ago by Otto42 (next)

comment:26 dd323 years ago

  • Keywords 3.4-early added; 3.3-early removed
  • Milestone changed from 3.3 to Future Release

Unfortunately the Feature freeze has hit us a few weeks back, Leaving this here sitting and waiting for early 3.4

comment:27 F J Kaiser3 years ago

  • Cc 24-7@… added

comment:28 pauldewouters2 years ago

  • Cc pauldewouters added

comment:29 DrewAPicture2 years ago

Any chance this makes it into 3.4?

comment:30 nacin2 years ago

  • Milestone changed from Future Release to 3.4

This appears good to go. Let's kick the tires and get it in this week. The theme reviewers will certainly appreciate it.

comment:31 Otto422 years ago

Testing it now.

Notes:

  • Check the 13774.3.diff before commit. There's two sections of debug code that needs to be removed first. Both are marked with TODO's.
  • Works for pre-existing parent themes (mazeld depends on twenty-ten):
Downloading install package from http://wordpress.org/extend/themes/download/mazeld.1.0.zip…

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Checking if twentyten is installed…

The Parent theme, Twenty Ten 1.3, is currently installed.

Successfully installed the theme Mazeld 1.0.

Works for children that don't have a parent installed (multi depends on desk-mess-mirrored):

Downloading install package from http://wordpress.org/extend/themes/download/multi.1.8.3.zip…

Unpacking the package…

Installing the theme…

This theme requires a parent theme, Checking if desk-mess-mirrored is installed…

Preparing to install Desk Mess Mirrored 2.0.1…

Downloading install package from http://wordpress.org/extend/themes/download/desk-mess-mirrored.2.0.1.zip…

Unpacking the package…

Installing the theme…

Successfully installed the parent theme Desk Mess Mirrored 2.0.1.

Successfully installed the theme Multi 1.8.3.
  • Works for both cases in direct mode.
  • Works for both cases when forcing FTP mode (ftpsockets). Note, tested on localhost, so PHP timeouts not a problem in this case. But nothing much that can be done about that anyway.
  • FTP Filesystem finder works correctly to find the right directories on a multi-single-site install in FTP mode. Tested with 8 subdirectory WP installs on localhost and the FTP directory pointing at the htdocs root (so it can see them all).

Looks good to me. Remove the debug lines and should be good to go. UI details can be adjusted later if needed.

comment:32 cais2 years ago

  • Cc edward.caissie@… added

comment:33 cais2 years ago

This is an important ticket for the WPTRT ... and I just noticed the testing was done with my Parent-Theme / Child-Theme as examples, too (*grin*).

PS: I would really like to get Multi updated as it will fail due to changes I made in Desk Mess Mirrored. The current working version of Multi can be found here: https://github.com/Cais/multi

comment:34 emiluzelac2 years ago

  • Cc emil@… added

comment:35 navjotjsingh2 years ago

  • Cc navjotjsingh@… added

comment:36 nacin2 years ago

I've tested this, tweaked the strings, and updated it to use the new WP_Theme API (partially; the rest will come in a follow-up commit).

comment:37 nacin2 years ago

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

In [20267]:

Support child theme installation in the theme installer. props otto42, dd32. fixes #13774.

comment:38 nacin2 years ago

In [20268]:

Leverage WP_Theme in the upgrader. Remove debug line from [20267]. Stop using get_theme_data() as it will be deprecated. see #13774. see #20103.

comment:39 dd3218 months ago

#18490 was marked as a duplicate.

comment:40 Otto4217 months ago

Somehow, somewhere, this got broken. Finding out when/how would be useful.

New ticket: #22515

Note: See TracTickets for help on using tickets.