Hey folks. WordPress 3.4 “Green” just dropped. I know a lot of folks worry about updating so I thought I would write up a post about this. Point of clarification: this post is mostly about how WordPress 3.4 works with Genesis 1.8.1, for other themes and plugins see if their authors and fans have said anything.
I maintain this site as well as a few others. I started testing with the beta and release candidates on my dev site with no significant problems. As soon as the official 3.4 version dropped I updated a half dozen or so sites using various Genesis themes and have now tested 20 total Genesis themes. In all cases the themes have worked nearly perfectly.
Genesis 1.8.1 and WordPress 3.4 is nearly perfect
So you noticed the “near” there? Yeah, there are a couple of minor issues that crop up. Generally these only show up when using debug mode. In all cases the errors do not stop the site from working. Lets start with the scariest looking.
Theme Editor Warnings
There are about half a dozen warnings that can be thrown on the theme editor page. These errors only present in single site installs. I have not been able to replicate on multisite installs in any way. Typically these errors only show when debug mode is active, but a few users have reported that they see the errors when debug is not active.
The Look
On the theme editor page you may see the following above the editor
Warning: preg_grep() expects parameter 2 to be array, null given in /home/kellyb/public_html/ssfobamanet/wp-content/themes/genesis/lib/admin/editor.php on line 39
Warning: Illegal offset type in /home/kellyb/public_html/ssfobamanet/wp-content/themes/genesis/lib/admin/editor.php on line 39
Warning: Illegal offset type in /home/kellyb/public_html/ssfobamanet/wp-content/themes/genesis/lib/admin/editor.php on line 40
Warning: preg_grep() expects parameter 2 to be array, null given in /home/kellyb/public_html/ssfobamanet/wp-content/themes/genesis/lib/admin/editor.php on line 40
Warning: Illegal offset type in /home/kellyb/public_html/ssfobamanet/wp-content/themes/genesis/lib/admin/editor.php on line 40
With words like “warning” and “illegal” it looks like the cops are going to break your door down if you try to do anything, but as you will see in a bit it isn’t nearly as bad as it looks.
The Cause
Genesis tries to hide itself from the WordPress theme editor. Too many users ignored the dire warnings against editing Genesis core files, so steps were taken to minimize the ability of end users to edit Genesis files. Due to changes in the WordPress theme API one of the variables that was edited no longer has a value so it throws some warnings.
What you should do
Trust me, these warnings are pretty minor. You can continue to edit themes and ignore the warnings. I reported this error as soon as I saw it crop up (honestly I never use the theme editor so I wouldn’t have ever seen it myself). Genesis 1.9 should resolve the error if a 1.8.2 update doesn’t address it first. Please note I’m not saying there will be a 1.8.2 update, just saying that if one comes out it would address this.
What about right now?
Let me guess, you are one of those folks that has to flip the light switch 4 times before leaving the house? That’s cool, I have to keep my hand on the wall when I walk down the hall. For folks that just can’t stand to know there are warnings being thrown (dire or otherwise) there is a simple solution.
remove_action( 'admin_notices', 'genesis_theme_files_to_edit' );
You can add that to your functions.php file and then remove it with the next Genesis update. You could also add it to the Genesis functions.php file
Did I just say that? Don’t I say “NEVER, not EVER, edit Genesis core files?” Ok, so for every rule there is an exception, probably even for this rule about exceptions. So here’s the deal. You never edit Genesis files because those edits will be lost on update, but you want to get rid of this edit when you update Genesis right? See where I’m going here? This is one of those super exclusive exceptions. Since this code can go away when you update Genesis you can add it to the core, but just this one time. Don’t do it for stuff you plan on keeping. In either case, put it at the end of the file before any ?> tags that might exist (if that tag isn’t there the very end of the file is good).
Deprecated Function Errors
Again, these should only show up if Debug is active. All themes that were using the custom header feature and/or custom background feature will get two notices that say those functions are deprecated.
The Look
If the theme is using the custom header and/or the custom background you will see one, the other, or both of these notices at the top of every page
Notice: add_custom_background is deprecated since version 3.4! Use add_theme_support( ‘custom-background’, $args ) instead. in /srv/users/designsbynickthegeek/apps/designsbynickthegeek/public/wp-includes/functions.php on line 2705
Notice: add_custom_image_header is deprecated since version 3.4! Use add_theme_support( ‘custom-header’, $args ) instead. in /srv/users/designsbynickthegeek/apps/designsbynickthegeek/public/wp-includes/functions.php on line 2705
They look much less menacing than the warnings from the previous error message, but they can be potentially worse, just not right now. I’ll explain that in the cause.
The Cause
WordPress used two functions to load these features, add_custom_background() and add_custom_image_header(). In Genesis child themes using the custom background you will find the add_custom_background() function in the functions.php file. For themes with the custom header, the add_custom_image_header() is actually being called in Genesis.
In WordPress 3.4 those functions were “deprecated.” This means they should not be used, but still work just fine. The reason this can eventually become a problem is deprecated functions are eventually removed. This isn’t something that will be removed in the next WP version, they have deprecated functions from several versions back, so no need to panic, but some day these functions won’t work any more.
The Solution
Good news, Genesis 1.9 will address the add_custom_image_header() function and already uses add_theme_support to even get to that point, so it is a step ahead of the game. The notice will go away when this is addressed in 1.9 long before the function is actually removed, so you don’t have to do anything to deal with the notice about add_custom_image_header().
The notice about add_custom_background() will require a bit of work on your part for existing themes, but it is super simple. Find this in your functions.php file
add_custom_background();
Replace it with
add_theme_support( 'custom-background' );
Now your theme is ready for the distant future and the notice will go away.
Oh, and if you are wondering, Brian updated the StudioPress child theme functions.php files that this affected so new downloads as of this morning should already have this fixed. This is a “silent” update so there isn’t really a notice going out saying the themes were updated, just a quick fix so new users don’t have to fix their theme.
But I also see …
You might have a few other warnings while using a Genesis child theme. Those might come from code added to the child theme or more likely from a plugin. If you have other problems check your plugins first.
To update or not?
There is a lot of stuff written on what is in WP 3.4, my favorite is the new theme customizer. I’m working up a solution where additional options are added to this so you can see your layout and style selections live in the customizer. Maybe a few other goodies. There are several other new features and quite frankly I’ve seen very few real problems with the update. I’m pulling the trigger on every site I maintain and have had no problems. So go for it.
Best Process for Updating
I do want to put a reminder about updating best practices.
- Backup: if something goes terribly wrong and you want to go back to WP 3.3.2 you must have a backup. Otherwise you have to figure out why things went wrong
- Disable all plugins: seriously, 99% of the problems during any update are caused by a plugin. Just turn them all off. Your settings should be saved in the database by any good plugin.
- Update WordPress
- Update your plugins
- Start turning your plugins back on in small groups
- Check your site for problems, hopefully there aren’t any
If your site goes down for any reason, go read my site recovery tips and tricks article. Remember, it is probably a plugin problem.
David Perdew says
Thanks Nick – I was just wondering if I should venture into the 3.4 waters with my Genesis theme. Thanks for the update. Very timely.
dp
Charlie says
Nick, you’re the best! You had me laughing out loud with your take on “warning” and “illegal” so thanks for bringing some levity to what seemed like cause for concern. Also, thank you for such a thorough explanation on how and when it can all be resolved.
-Charlie
Marcy says
Thanks for the great explanation. I saw the errors on the site I’m working on, and thought, “Oh, oh. What did I do now?” And there you were in my inbox with an explanation.
nickthegeek says
man, see I should figure out how to quote you to get more subscribers 😀
bill scheider says
Twitter worked for me 🙂
Kim says
Thank you 🙂
Linda Sherman says
Thanks Nick.
So long as we know the client isn’t going to be looking at the editor page, we can also just leave these warnings showing until the update resolves the issue, correct?
nickthegeek says
It is certainly ok to leave it up. In fact my recommendation would be to do nothing and let the update resolve it when it comes.
Rose says
Thank you, Nick! Great information, well written and helpful … another reason to love Studio Press!