If you are a Theme Author or you just want to use the benefits of WordPreciousss in a normal WordPress theme, there are some basic things you need to do to add support for the plugin:

Support for overriding header.php, footer.php and sidebar.php

Out of the box WordPreciousss are able to add or replace theme template files like page.php and single.php etc. in any Child Themes or Skins, however there are three files you can’t do this with unless you add support for it:
  • header.php
  • footer.php
  • sidebar.php

To be able to override these files in a Child Theme or Skin you need to find the following codes in your (Parent) theme:

<?php get_header(); ?>

<?php get_footer(); ?>

<?php get_sidebar(); ?>

And replace them with:

<?php if(function_exists('precious_get_file')) {
    precious_get_file('header'); } else {  get_header();
} ?>

<?php if(function_exists('precious_get_file')) {
   precious_get_file('footer'); } else {  get_footer();
} ?>

<?php if(function_exists('precious_get_file')) {
   precious_get_file('sidebar'); } else {  get_sidebar();
} ?>

See that “if(function_exists('precious_get_file'))”?

That will make sure the theme won’t break if WordPreciousss is not installed or activated.

Note: If your theme make use of the get_sidebar('name') functionality in WordPress, you need to replace that code with:

<?php if(function_exists('precious_get_file')) {
   precious_get_file('sidebar-name'); } else {  get_sidebar('name');
} ?>

Adding support for overriding misc. template files

A lot of themes has miscellaneous template files included, and the most common is searchform.php.

Usually this file is included with the following code:

<?php include (TEMPLATEPATH . '/searchform.html'); ?>

If a Child Theme or Skin should be able to override the Parent Theme’s searchform.php, you need to use the following code instead:

<?php if(function_exists('precious_include_file')) {
   precious_include_file('searchform','/index.html'); } else {
   include (TEMPLATEPATH . '/searchform.html');
} ?>

This can be done with any kind of misc. template that use the include (TEMPLATEPATH . '/filename.html'); code.

What’s important when you use the precious_get_file() function is to set the second parameter right, as this tells WordPress which directory in your theme to look for the file. In the above example is the second parameter set to “/” which simply means the root directory of the theme.

If you don’t do this, it will look for the file in a directory called “includes”, which is the default.

Renaming your custom page templates

If your theme has custom page templates, you need to rename them so WordPreciousss can recognize them and let your theme override the default template sets.

So if you have a custom page template for archives called archives.php this need to be renamed to page-archives.php.

Adding support for Precious Skinner

This is simply done by creating a directory called “skins” in your theme’s folder.