Build Your Own Business Website header image

Introduction to Customizing Thesis 2.1 Using PHP – Part 2 – Using the Thesis Custom PHP Files

Difficulty Level -

Filed Under Topics - ,

Listed Under Lesson Subjects -

Applies to -

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

So we’re going to start off this Customizing Thesis 2.1 with PHP seminar by looking at the Thesis Custom PHP files.

Thesis 2.1 File Locations

I’m going to grab up my FTP client here and we’ll go to thesis2demo. So Thesis 2.1 comes with files in a couple of different locations. In the first place, it’s all inside of wp-content but you have wp-content/thesis and you have wp-content/themes/thesis. Now, the wp-content/themes/thesis folder contains all of the core files for Thesis, period, all the core files are there.

The wp-content/thesis folder contains what Chris calls “user files” and so you have userboxes, user packages and user skins. This is essentially where all of the boxes, skins and packages that you create or work with in any way are stored.

So if you install a new skin, it doesn’t get stored in wp-content/themes/thesis, it gets stored in wp-content/thesis/skins. Well today, we’re going to be creating boxes and so the boxes will go into wp-content/thesis and boxes.

Types of Editable Custom Files

The reason I mention that is because Thesis comes with two different types of custom files for you to edit. It comes with master.php and then each skin comes with its own custom.php. Both of those are essentially blank. They have a little comments in them but they’re essentially blank from the get go and generally speaking, any professionally created skin that you use is going to include a custom.php inside of the skin file.

Not Skin Dependent – master.php

The master.php that’s inside of wp-content/thesis is going to apply no matter what skin is activated. So you can be switching from one skin to another and the functions inside of master.php will continue to fire.

So you’ll use master.php if what you’re doing is not really skin specific and for many DIYers building their own site, master.php is probably a great place for you to put your work.

Skin Dependent – custom.php

However, if you are doing something that you want to be skin specific (you want it only to apply to one specific skin that you’re working in) then in that case you would use the custom.php file here. The reason is that the functions in that file will only fire when someone activates the skin and they won’t fire otherwise.

So that’s a value judgement that you end up needing to make at the very beginning, do you want this to fire no matter what skin is being used or do you want it to fire only in a specific skin? Obviously, any functions that you create that are dependent upon a skin, those functions should go in custom.php.

We’ll be Working in master.php

Today, we’re going to be working only in master.php because I think that most DIY web builders are going to spend most of their time working there. Web developers are never going to use custom.php in their own skin design because custom.php is deliberately intended for the end user of the skin.

Custom.php does not get replaced when the skin gets updated so that’s what custom.php is for and that’s why a developer wouldn’t use it because that is intended for the end user to play around with.

Using the master.php File

So we’re just going to dive right into using master.php. Let’s take a look in Thesis and master.php and open it up. There we go, “This is the Thesis master.php file. Use this file to affect every site on your network. Note: this is the last file included in Thesis!”.

The point of this is that, master.php also works with all sites in a multi-site. So if you’re using master.php in a multi-site environment, all of these functions in master.php are going to fire on all sites. So that’s another thing to keep in mind when you are looking at that.

When it says, “Note: this is the last file included in Thesis!”, the point of that is to let you know that since this is the last file that’s included, functions that you write here can in fact replace the functionality of Thesis functions. That’s not really a beginning concept so it’s not something you need to worry about at the moment but that’s what that means.

And we can take a look at the custom.php in Classic Responsive for a moment, class custom.php in classic-r. In fact, I put a function here when I was demonstrating something. It says “This file is for skin specific customizations. Be careful not to change your skin’s skin.php file blah blah blah blah blah”.

So anyway, that’s what your custom.php file looks like, absent this little function which is one that I used when I was showing something in the live Q&A session. So out of the box, what you have is an empty file that starts with an opening PHP tag, has this little comment block and has nothing else, no closing PHP tag in particular.

Understanding PHP Tags in WordPress

This is something sometimes that PHP programmers are a little bit surprised with when they come to WordPress but the convention in WordPress is not to include a closing PHP tag at the end of a PHP file. Actually, it makes it less prone to error for many different reasons. So don’t include the closing PHP tag at the end of the file.

And make sure that whatever you do you don’t include anything above this PHP tag. If you’ve got a space here like this, this is going to fail. You’ll get a fatal error because headers have already been sent, blah, blah, blah and that’s just because there’s some space above PHP. Obviously, you never want that to happen.

You want your opening PHP tag to be the very first thing and nothing else on the opening PHP tag line. So nothing else should be there, just an opening PHP tag. Everything else done here is just going to follow regular syntax but that’s what this file will look like.

0 Comments… add one
0 comments… add one

Leave a Comment