My functions.php file is getting on the long side. Is it all right to use includes to break it up (php includes I mean) or is this considered bad form?
|
Many theme frameworks and complex themes break up functions into different files and include them in one file called functions.php, sometimes within a folder called If it's a theme to be released, end users typically look for a functions.php file as the default WP framework functions file. The two latest default WP themes - twentyten http://wordpress.org/extend/themes/twentyten and twentyeleven http://wordpress.org/extend/themes/twentyeleven - use one functions.php file, as that's part of the standard WP theme file structure. But again, many themes use multiple files for functions, and if a user wants to work with or modify the theme, they will need a certain level of proficiency anyway. Code comments are helpful. |
|||
|
|
|
I think it is down to personal preference - as far as I'm aware there are no conventions that say you should or shouldn't use includes in the functions file. Personally, I do like to split the functions file up into separate includes - I find it a lot easier to find the section of code I'm looking for when it's in a separate file rather than trawling through 1000's of lines of code. As long as you comment everything in a meaningful way should anyone else work on the theme in the future they'll be able to understand what you've done and why. |
|||
|
|
|
If you have anything in the functions.php file that is more of a site function than related directly to the specific theme formatting, you should consider moving to a site-specific plugin. More on this: http://wpcandy.com/teaches/how-to-create-a-functionality-plugin |
|||
|
|