Converting modified theme to child theme
-
I’ve been contracted to help move, update and manage a wordpress site using the Hueman theme. The problem is the previous original developer neglected to set up a child theme for their customizations. They used the custom.css file for custom css, but renamed it. They have added custom page templates. Beyond that I’m not sure what else they had changed. The theme is listed as version 1.4.1, while the current version is at 2.2.3, so quite a bit out of date.
I’d like to be able to isolate the changes made and migrate those all to a child theme so the theme can be updated since there has been several security fixes and added support for newer WP features. What would be the best way to accomplish this?
Thanks.
-
Hi killab. This, unfortunately, is a classic example of why a child theme is so highly recommended if you’re going to make changes. There have been 13 updates to the version on the wp.org repository between v1.4.1 and the current version 1.5.4. Version 2.2.3 on the theme web site shares the same basic code as the wp.org version but includes additional code as noted on the web site. Off the top of my head I would say you’re looking at a process something like the following:
– download a new copy of v1.4.1 here in zip format at the bottom of the page.
– extract the files
– do a folder diff comparison between the current site and the default 1.4.1 theme folders to find the changed files. There are many utilities available to help with this; here’s one I’ve used.
– install a new copy of the current version (1.5.4 or 2.2.3)
– create a child theme
– copy the changed files from the current site v1.4.1 to the new child theme
– test it and see if it runs
– if it runs, at least you know the theme updates haven’t broken any of the customizations. If it doesn’t run then you’ve got some troubleshooting ahead of you to figure out where the conflicts are between the default files and the customized files.
– in either case, I’d recommend moving the changes to the current version
– move the changed v1.4.1 files out of the child theme
– copy the related files from the new version parent theme to the child theme
– run a file diff of the customized 1.4.1 files against the new files in the child theme
– copy the changes from the 1.4.1 files to the files in the child theme
– test and repeatYou’ll also need to review the custom page templates and see if they are compatible with the new theme version.
At some point, depending on the level and number of customizations, it might be better to just start over with a clean install and code the changes from scratch based on the customer specifications. More work? Maybe. But, if you’re going to be supporting it, at least that way you’ll know what changes you made and why. Just a thought.
Thanks for the reply. I’ve got winmerge since its available as a portable app. Its been easier to setup a portable dev suite on a flash drive than go through the hassle of trying to get what I need installed on the workstation provided π
The old developers advertise themselves as Drupal & WordPress experts, which makes how they went about customizing the theme by way of direct hacks depressing.
Looks like just about every PHP & CSS file is different than the default 1.4.1 folder. Also the look and layout of the theme have been heavily customized. Yay!
A main part of why I was brought in was to move the site from the old developers host to a new in-house managed host. While waiting for the new host to be setup I’ve been going through the current site and updating WP & plugins (neither had been updated) and correcting/adding smaller features. I’m going to see how easy it is to fix the theme mess on my development server to see if it might be better to go with a whole new theme once everything is transferred.
Thanks for the help! I’ll be a bit busy with this for a while! At least I’m paid by the hour π
customizing the theme by way of direct hacks
That’s the sort of thing that gives us all a bad rap. Then, when someone has to come in and clean up the mess, the client thinks, “Hey, it’s WordPress, the easiest website tool there is! How hard can it be?” Hopefully your client has some appreciation for the task you’ve undertaken. Let me know if you have any questions along the way. Good luck.
Seems like maybe the previous dev might have learned designing for wordpress in the earlier days. A lot of custom fields for content.
My contract is with a department in my local county government. And luckily the person I report to is great to work with and understanding. I have a 2-stage development plan. Get the site moved with the current theme/look and make smaller upgrades. Then look to move to a new theme/cleaner layout with larger changes.
I do have one question you might be able to help with.
The home page has been setup with a custom page template that uses a 1 column design. The template has done away with adding content via the main edit field and instead uses a feature image as a banner image below a top menu and secondary header menu. The main content has been added via custom fields.This isn’t too much of an issue, except I’ve been asked to add a calendar to the front page. I’ve set up a Google calendar and installed Google Calendar Events plugin to integrate it into the theme. When I add the calendar shortcode to the custom field its either stripped out or rendered as plain text. Is there a easy way to add shortcode support to a custom field? I can just add the google calendar iframe code, but it doesn’t visually look as good as using the plugin.
Thanks
Don’t have an answer directly but maybe one of these refs will help:
http://www.wprecipes.com/how-to-execute-shortcodes-inside-custom-fields
http://www.engagewp.com/how-to-use-shortcodes-in-custom-fields/
Thanks, I think one of those techniques might work for me.
Since the theme was so heavily customized, I’m getting lots of PHP errors. Yay.
I’m working to separate the customization made to the theme functions.php into a child theme functions.php. I haven’t had to dive as deep into the PHP code in any of my past WordPress sites, most of my past WordPress tweaks have mostly been CSS.So, with functions.php, I need to strip out all the customization to live alone in the child theme functions.php, correct? Is this only with functions or are the other php files treated the same (header, footer, etc)?
One last question. Does the child theme folder need to maintain the folder structure of the parent theme? For example page templates is in its own folder in the parent, does it need its own folder in the child?
Thanks
Most of the theme functions have a wrapper that checks to see if the function is not already defined:
if ( ! function_exists( 'alx_load' ) ) {Normally one would copy the function from the parent theme functions.php file, without the wrapper, to the child theme functions.php file and modify it there. The child theme functions.php file is loaded first and then the parent theme function.php runs. In the parent file the wrapper will detect that the function has already been loaded by the child theme and not load it again. The other theme files are a bit different. If you copy a theme file to the child theme the site generation process will use the child theme copy, whether it’s been modified or not, and the parent theme file never gets loaded.
Yes, the general rule is that the path in the child theme should match the path in the parent theme.
Ok. So I’ll just need to go through functions and copy the full function for each one that has customization and save it in the child functions.php.
One benefit to all this is I’m gaining deeper knowledge of the ins and outs of theme customization π
Personally I think it’s one of the best ways to learn how themes work. Dig in, take it apart, make changes and see what works and what doesn’t.
The topic ‘Converting modified theme to child theme’ is closed to new replies.
