My biggest question is ���what will happen if we take the newly updated theme, and place it on a blog running a previous version of WordPress?���
Is there some way to check which version of WordPress is being run, or will we have to put out a WordPress 2.3 only version of each and every theme?
I’m not normally an active commenter on blogs, but since I knew the answer to the question, I figured I’d speak up and answer the question. Because of this, I figured I’d go ahead and answer it here as well.
PHP comes with the built in capability to check to see if a function exists. Since template tags are nothing more than PHP functions, it makes sense that you can very easily use the function_existscondition to check the availability of the function before actually calling it. It would go a little something like this:
the_tags('Tags:', ', ', ''); } ?>
So now, you have added the ability to add tags to your theme, without breaking it in all versions prior to 2.3.
Bonus TipOK, I have to admit that I haven’t actually done this for my themes, but I wanted to throw this out there as a possibility. If you’ve been developing themes for a while now, you’ve got to be aware of tags that have been deprecated. For instance, let’s say you wanted to list your categories in the sidebar. Normally, you would use the wp_list_categoriesfunction.
But if you wanted to be backward compatible, you would use the deprecated tag ( wp_list_cats) instead of the new one. That way, you make sure you have a catch-all function (since WordPress doesn’t remove deprecated functions from the code for quite a while).
In reality, you’re using an inferior function, even if the user has a fully upgraded version of WordPress.
It would be better if you used the function check to make sure your theme is truly, fully backward compatible. That means that even after WordPress phases out the deprecated function, your theme still works.
This also eliminates the need to release different themes for different versions of WordPress. A single theme will work universally! Here’s a sample of how you would do it:
wp_list_categories(); } else {
wp_list_cats(); } ?>
Easy as cake! Enjoy your new, fully backward compatible theme!
0 nhận xét:
Đăng nhận xét