![]() |
.php includes with child themes
Hello,
I was looking into what's everyones thoughts on designing themes with php includes as opposed to throwing everything into functions.php. e.g. PHP Code:
I was thinking about this when creating custom metaboxes and can see how the functions.php can get out of hand with various custom post types. |
Includes are a great plan and help keep things more simple. This will add a slight bump to overhead but not enough to be noticed.
|
Thanks Nick.
Other than writing the include, how else would this approach increase overhead? Or is that the extra work you were talking about? |
It adds a tiny fraction of overhead because you are using one extra function and loading one extra file. The overhead added is so minuscule that it isn't worth worry about compared to the advantages of better code organization.
|
Hope you don't mind me jumping into the discussion.
include, include_once, require, require_once = the arguments we can use right? Which one of them would be the best to use? Also, the custom header php file syntax: do you start with <?php and end with ?> or <?php and end with genesis(); or <?php and don't add anything at the end? or no <?php ?> at all for the php files with extra functions? |
We did some testing, include seems to use the least overhead. require slightly more. Then incude_once followed by require_once().
Include will not throw an error if the file is not found. require will break the site if it cannot find the file. The functions.php file should open with a <?php so you only need <?php if you closed php with ?> |
That would help me troubleshoot what I did wrong last time.
Thanks a lot Nick! :): P.S: you can disregard the comment I posted on your site that was something similar to the last query. :) |
Great info. One thing I've been wondering though. Does divvying up the php files adversely effect load time?
|
As I said, it adds a tiny bit of overhead. Unless you go absolutely nuts with it the load time won't be affected enough to worry about. Maybe a couple milliseconds.
|
Great. I guess I'll go ahead and try this workflow for a future project and see where it takes me. :):
|
| All times are GMT -5. The time now is 04:53 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.