Time for action – tidying up your theme

Let's tidy up the theme directory and code files. Perform the following steps for the same:

  1. Open the theme directory in your file manager. Make a backup of your theme just in case.
  2. Check there aren't any files in your theme folder that aren't used by the theme. If so, remove them.
  3. Open your code files in turn and check them. If you've commented out any code, remove that. Check that you haven't unnecessarily duplicated code, such as stylesheet declarations.
  4. Review your code. Is it clear and easy to work with? Is it laid out well so other users could see what's happening and how your files are structured? See the WordPress coding standards at http://codex.wordpress.org/WordPress_Coding_Standards.
  5. Now save all of the files you've edited.

What just happened?

You tidied up your files and your code. You should now have a theme which is well coded and meets the WordPress coding standards. Well done!

Describing your theme in the stylesheet

The next step is to ensure that your stylesheet has all of the information users of your theme will need. In Chapter 3, Coding It Up, we added text at the top of the stylesheet inside comments to tell WordPress the name of the theme and provide more information. Now let's add to that.

The opening lines of the stylesheet are commented out and contain the following information about your theme:

  • Theme Name: The full name of your theme.
  • Theme URI: Where the theme can be downloaded from.
  • Description: A quick description of what the theme looks like, any specific purpose it's best suited for, and/or any other theme it's based on or inspired by.
  • Author: Your name as the theme's author goes here.
  • Author URI: A URL to a page, where people can find out more about you.
  • Version: The version number—1.0 if it's a new theme. Each time you edit the theme, change this by adding a 0.1 increment for small changes or going up to the next whole number for major changes.
  • Tags: A list of tags applying to your theme, which will help people searching for themes with certain characteristics.

You can also add license information—this won't be displayed on the Themes admin page, but will be visible to anyone who opens your stylesheet. This can take the form of the full license information or a short description of the license (for example, GPL).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset