In this recipe, we will go over the steps necessary to package your theme for distribution. Even if you never share your theme with the public, following these steps can help you organize your theme better, and test for any potential compatibility issues with plugins or other code.
First, you need to prepare any plug-ins or custom functions that you have created, so that any tags or callbacks that were inserted into template files will not "break" or corrupt the theme. To do this, the function function_exists() can be used to check for a plug-in or function, and detect if it exists or is active. If function_exists() returns a value of false or not found, the plugin tag or function callback will be ignored and the page will continue loading. For example, earlier in this chapter we used the function check for a user message function. The code used was:
<?php if (function_exists ('get_my_user_message')) echo get_my_user_message(); ?>
The previous example function uses get_my_user_message() to print out information to the screen. Check all of your core template files, along with any other custom template files that you have created; otherwise don't be surprised if things break!
Make sure that you include all of the core WordPress template files, like index.php, sidebar.php, single.php, comments.php, header.php, and footer.php. Your template folder should also contain a style.css file. Using a functions.php file to contain loose functions (that is, those that are not plug-ins) is also preferred.
Test your template files, including the comments functionality, for any weird layout issues. You may want to visit the WordPress Forums, or review the basics of HTML, PHP, and CSS at
http://www.w3schools.com, for most issues.
Organize your theme structure to match the way that other themes are set up. This means keeping your style.css file in the main theme folder, and adding any additional styles for schemes and others to a special subfolder, for neatness. If you will have multiple files of the same type, such as .po files, then you should put them in a translations subfolder. Other files, such as .mo files, should be left in the main theme folder, where WordPress expects to find them.
Don't rename default WordPress style definitions just to be different. Keep any main structural styles such as #header and #content named the same. Be aware that many people use .primary and .secondary to denote the main sidebar and secondary sidebar, if you are styling more than one. It is a best practice to add any new classes that you create below the standard WordPress classes in your style.css sheet, and use / ** / to comment liberally about the purpose of your styles.
Comment, comment, and comment some more. Remember: your more adventurous users will be reading your code. They may be looking to do something similar, or may just want to understand what you were thinking.
Test, test, test, and then test your theme some more, using various test blogs, different plug-ins, when the theme is active and inactive, and in other instances. You cannot test your theme enough.
Double-check that you have documented any custom tweaks, tips, plug-ins, or other things that the user must know, in a readme file.
Put all of your theme files, including a readme text file with information and description, in a ZIP file for easy downloading. If possible, provide two or more file compression types, such as RAR, ZIP, GZIP, and so on, in order to maximize user choices.
Releasing a theme for public use is not for the faint of heart. Read on for more information about letting your theme go public.
Is your theme really ready for public release?
Packaging your theme is one thing, but exposing your efforts to public view and criticism is another. Are you ready for the requests for support, e-mails about grammatical errors, and complaints about things you never even considered before? If so, then you may have the courage to release your theme to the public. Visit http://codex.wordpress.org/ Designing_Themes_for_Public_Release for more ways to prepare your little theme for the great big WordPress community.
Was this article helpful?
The success of a blog lies in the content. It is the content and the key words that consistently attract potential customers. Great blog content literally means something different on every blog. Great blog content is researched and not impulsive. You cannot treat the blog as an experimental playground and expect it to work for you. It is designed to mean business and make you presence felt online and you have to ensure it performs the way you want it to.