Thesis 1.x included a series of constants that programmers routinely used when customizing their sites. Thesis 2.0 adds to that list new constants that will be useful to skin, box and package designers. In this part of the seminar we examine all of the constants in the new Thesis theme.
Local Path and URL Path
Chances are you understand the difference between the local path and the, I’m now briefly forgetting what that’s called, the URL. But there’s 2 different ways of referring to files depending upon what is trying to access them. And if a web page is trying to access them, you use the URL path. And if the program itself is trying to access them then you use the local path.
Anyway, you know that you’re looking at the URL version of it because each of the constants ends with URL, if it’s the URL version. If it doesn’t end with the URL, it’s the local version of the path. Anyway, this is the core. These are the core constants.
Then you come down to the user constants and the user constants, for example, Thesis user, refers to the wp content directory which is wp content or whatever…it’s possible for a website owner to change the address of the wp content directory. So it doesn’t actually have to be wp content. It could be something else as long as WordPress understands where it is, this is the WordPress constant for the wp content directory. And so the Thesis user is wpcontent/thesis. It’s that user folder that we talked about.
User Skins, Boxes and Packages
And then inside of that again, you’ve got the user skins, user boxes and user packages. And
again, these are all the local paths of those things. And then you have the URL paths to those. So again, it’s the Thesis user URL so it’s the www.myskin.com/wpcontent/thesis. And then user skins URL, user boxes URL and user packages URL.
If you’re a skin developer, you may, in fact, extend these because you may create additional constants. But if you want to include files from your own skin php file, you may say include once Thesis skins URL/myskin slash… myincludedfile.php.
So you can use this… the skins URL or the user skins as a way of including additional files inside of your skin. If you’re a skin or a plugin author, you know how important to have a reliable starting place for referencing additional files. And not only reliable but also relative. And so this gives you the opportunity to have a reliable relative starting point for referencing any files you create in your skin or box or package.
Then we have the Legacy system here which shows up in 2 different contexts. It might not be clear to you what the context is here. But stylesheet path, if file exists, stylesheet path/custom. Stylesheet path refers to either a child theme or the main theme, the parent theme if there is no child theme.
Template path never refers to a child theme. It always refers to the main theme. Stylesheet path could refer either to one or the other. It refers to the child theme first and if there is no child theme then it refers to the main theme.
So what this is doing is the first one’s saying if there is a child theme and it has a directory called custom then Thesis custom = stylesheetpath/custom. And Thesis custom folder which is the URL path = get blog info stylesheet directory/custom. This is the case whether there’s a child theme or not. So if it’s a child theme, it looks in the child theme folder for it. If it’s not a child theme, it’s looking in this folder. It’s going to look directly in the themes Thesis folder for a custom folder.
So this is a way in which you can add a custom folder and add custom functions php file and use the Legacy system for essentially affecting all of the Thesis customization. So if you were to create in this a folder called custom then this function here says okay, there’s a folder in the stylesheet path called custom so we’re going to call it Thesis custom folder and that’s its local path and its URL path is Thesis custom folder so its local path is Thesis custom or Thesis custom folder.
Now these two constants are Thesis 1 style constants. And so if you have your own functions that sit inside of your custom functions php file that use these constants, those constants will still continue to work as long as you have this custom directory sitting inside of your Thesis folder. If you’ve got a child theme that is over laying Thesis, this also works for the child theme. That’s why the stylesheet path thing is there.
Now the other thing it looks for is a folder called custom sample. And it looks for this and if it finds this then it doesn’t bother looking for this. If this custom folder exists either in the main template, main Thesis file or in the child theme Thesis file, it’s not going to look for it here.
But when it doesn’t, it does come and look in the main folder to see whether or not there is a folder called custom sample. And if there is a folder called custom sample then Thesis custom becomes that instead.
So the first thing is it’s looking for its custom and it looks in 2 places. The second one is custom sample and it only looks in the main Thesis folder. So here, this could just as easily be named custom sample and it’ll continue to work.
If we’ve got a custom sample folder in here then this Thesis custom will now act on or Thesis custom will become the constant for the local path and Thesis custom folder will become the constant for the URL path. Now if you have a custom and a custom sample then the custom is going to take precedence. The custom sample’s going to be ignored.
And in any case when you are writing boxes, packages, plugins or child themes or the like, as long as Thesis 2.0 is installed, you have these constants that you can refer to and use in locating specific things for use in your own code.