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(); ?>...