StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
  #1  
Old 10-25-2012, 06:30 PM
jjaycallejas jjaycallejas is offline
Registered User
Pro Plus Member
 
Join Date: Nov 2011
Posts: 154
Default .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:

remove_action
('genesis_header''genesis_do_header');
add_action('genesis_header','custom_header');

function 
custom_header() {
include 
'/custom-header.php';

Does anyone see anything wrong with this practice?

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.
  #2  
Old 10-26-2012, 07:56 AM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

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.
__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

  #3  
Old 10-29-2012, 06:02 PM
jjaycallejas jjaycallejas is offline
Registered User
Pro Plus Member
 
Join Date: Nov 2011
Posts: 154
Default

Thanks Nick.

Other than writing the include, how else would this approach increase overhead? Or is that the extra work you were talking about?
  #4  
Old 10-29-2012, 06:13 PM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

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.
__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

  #5  
Old 10-29-2012, 06:20 PM
thebluegger's Avatar
thebluegger thebluegger is offline
Registered User
Genesis Member
 
Join Date: Oct 2012
Posts: 59
Default

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?
__________________
Warning:- I'm a n00b. Heeding to my advice, can be injurious to your site. :)
  #6  
Old 10-29-2012, 06:37 PM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

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 ?>
__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Community themes v child themes non-Studiopress GinnyBee General Discussion 1 05-12-2012 12:20 PM


All times are GMT -5. The time now is 07:35 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.