# The Sandbox

Version 0.9.1
A theme rich with powerful and dynamic semantic class selectors

1. ## Introduction

   The Sandbox is a lot of things:

   - Beautiful on the inside
   - For WordPress 2.0.2 through 2.2.x
   - Valid XHTML 1.0 Transitional
   - Widgets plugin-friendly
   - The basis for your new, GPL-licensed theme

   More importantly, the Sandbox can be a lot of things.

   What began as Scott Allan Wallick's leftovers has become an advanced, semantics-based theme. Andy Skelton added his innovative semantic class-generating functions and Scott edited it to oblivion.

   So what can you do with the Sandbox?

   - You can just use it as-is and have a super-cool, truly minimalist theme.
   - You can totally cusotmize it with CSS alone—no need to bother with other files.
   - You can use the functions, theme files, et al, as pleases you—even for your own theme.
   - You can use it as a good place to learn a few things about CSS, XHTML, and PHP, perhaps.

   The real feature of the Sandbox is its markup. The use of class-generating functions in the `body`, post `div`, and comment/trackback `li` elements create an exceptionally extensible foundation. As Andy said, Given straightforward markup with plenty of selectors, there isn't much that can't be accomplished with CSS and a decent browser.

   And the implementation of the hAtom and hCard microformats means we're looking forward (and pleasing the barons at Technorati). You might be able to improve on our markup, but, well, who wants to work that hard?

2. ## Installing

   The Sandbox theme is installed just like any other WordPress theme. To install this theme:

   1. Download the Sandbox
   2. Extract the `/sandbox/` folder from the archive
   3. Upload this folder to the `/wp-contents/themes/` directory
   4. Activate the theme in the Dashboard › Presentation menu
   5. Enjoy

   You can read more detailed installation instructions on the WordPress Codex.

   Developers interested in Subversion access to the Sandbox repository may visit code.google.com/p/sandbox-theme. Please ignore this if you are not familiar with Subversion.

3. ## Class functions

   The three semantic class-generating functions used in the Sandbox are charted below, outlining what semantic classes are generated (“Class”), any related WordPress function (“WP Tag”), and the usage of these classes (“Usage”). For more on the WP Tag aspect, read the Template Tags and Conditional Tags articles on the WordPress Codex.

   1. ### `sandbox_body_class()`

      The `sandbox_body_class()` function is definied in the `functions.php` file. It has no parameters. It adds semantic classes to the `body` element relative to the content of the page that is being displayed.

          <body class="<?php sandbox_body_class() ?>">

      The chart below lists the semantic classes added to the `body` tag by this function.

      `sandbox_body_class()`
      CSS example
      `body.single div.sidebar { display: none; }`
      Class | WP Tag | Usage
      --- | --- | ---
      archive | `is_archive()` | When any archive page is displayed, i.e., applies to category-, date-, and author-based archive pages
      attachment | `is_attachment()` | When the post subpage containing an attachment is displayed, as set with "Linked to Page" in the post editor
      author | `is_author()` | When a author archive page is displayed
      author-[name] | `is_author()` | When a specific author archive page is displayed, where [name] is the author's login name, e.g., author-admin
      author-paged-[n] | `is_author()` & `is_paged()` | Displays the "paged" number of author archive, where [n] is the paginated number
      category | `is_category()` | When a category archive page is displayed
      category-[name] | `is_category()` | For a specific category, where [name] is the category slug, e.g., category-useful-links
      category-paged-[n] | `is_category()` & `is_paged()` | Displays the "paged" number of category archive, where [n] is the paginated number
      d01–31 | `gmdate('d')` | The current day of when the page is displayed (Offset to GMT)
      date | `is_date()` | When a date archive page is displayed, e.g., by month, by year
      date-paged-[n] | `is_date()` & `is_paged()` | Displays the "paged" number of date-based archive, where [n] is the paginated number
      h00–24 | `gmdate('h')` | The current hour of when the page is displayed (Offset to GMT)
      four04 | `is_404()` | When a request results in zero posts, i.e., a 404 error page
      home | `is_home()` | When the home page is displayed
      m00–12 | `gmdate('m')` | The current month of when the page is displayed (Offset to GMT)
      loggedin | n/a | When the page is displayed by a logged-in user
      page | `is_page()` | When a page is displayed
      page-author-[name] | `is_page()` | For a page by a specific author, where [name] is the user's login name, e.g., page-author-admin
      page-paged-[n] | `is_page()` & `is_paged()` | Displays the "paged" number of pages, where [n] is the paginated number
      paged | `is_paged()` | When whatever is displayed is "paged," e.g., page 2 of the index
      paged-[n] | `is_paged()` | Displays the "paged" number, where [n] is the paginated number, e.g., paged-3 for third page of index
      pageid-[n] | `is_page()` | Displays the page ID number of queried page, where [n] is the page ID, e.g., pageid-20
      postid-[n] | `is_single()` | Displays the post ID number of queried post, where [n] is the post ID, e.g., postid-20
      search | `is_search()` | When the results of a search are displayed
      single | `is_single()` | When a single post is displayed
      s-author-[name] | `is_single()` & `is_author()` | For a single post published by a specific author, where [name] is the user's login name, e.g., s-author-admin
      s-category-[name] | `is_single()` & `is_category()` | For a single post published in a specific category, where [name] is the category slug, e.g., s-category-news
      s-d01–31 | `gmdate('d')` | For a single post published on a specific day (Offset to GMT)
      s-h00–24 | `gmdate('h')` | For a single post published at a specific hour (Offset to GMT)
      s-m00–12 | `gmdate('m')` | For a single post published in a specific month (Offset to GMT)
      s-y2007 | `gmdate('Y')` | For a single post published in a specific year (Offset to GMT)
      wordpress | n/a | When anything is displayed; a class that is always applied
      y2007 | `gmdate('Y')` | The current year of when the page is display (Offset to GMT)

   2. ### `sandbox_post_class()`

      The `sandbox_post_class()` function is definied in the `functions.php` file. It has no parameters. It adds semantic classes to each post `div` element, relative to the actual post it contains.

          <div id="post-<?php the_ID(); ?>" class="<?php sandbox_post_class() ?>">

      The chart below lists the semantic classes added to each post `div` element by this function.

      `sandbox_post_class()`
      CSS example
      `div.category-news .entry-title { background: url('images/news.png'); }`
      Class | WP Tag | Usage
      --- | --- | ---
      alt | n/a | For odd-numbered posts, e.g., 1st, 3rd, 5th
      author-[name] | `is_author()` | For any specific author, where [name] is the user's login name, e.g., author-admin
      category-[name] | `is_category()` | For any specific category, where [name] is the category slug, e.g., category-news
      draft | n/a | For a post saved as a draft, as contrasted with an published post
      hentry | n/a | For the hAtom 0.1 specification, applied every post
      p[n] | n/a | For counting posts relative to the top of the page, where [n] is the number, e.g., p1 for the first post, p2 for the second, p3 for the third
      page | n/a | A general class, applied to every page
      post | n/a | A general class, applied to every post
      private | n/a | For a post that has been saved as "private"
      protected | n/a | For a post that has been password-protected
      publish | n/a | For any published post, as contrasted with an unpublished draft
      h00–24 | `gmdate('h')` | For a post published at a specific hour (Offset to GMT)
      d01–31 | `gmdate('d')` | For a post published on a specific day (Offset to GMT)
      m00–12 | `gmdate('m')` | For a post published in a specific month (Offset to GMT)
      y2007 | `gmdate('Y')` | For a post published in a certain year (Offset to GMT)

   3. ### `sandbox_comment_class()`

      The `sandbox_comment_class()` function is definied in the `functions.php` file. It has no parameters. It adds semantic classes to the each comment `li` element (“comment” here meaning comments, trackbacks, and pingbacks).

          <li id="comment-<?php comment_ID(); ?>" class="<?php sandbox_comment_class() ?>">

      The chart below lists the semantic classes added to each comment `li` element by this function.

      `sandbox_comment_class()`
      CSS example
      `div.comments li.bypostauthor { border: 1px solid red; }`
      Class | WP Tag | Usage
      --- | --- | ---
      alt | n/a | For odd-numbered comments, e.g., 1st, 3rd, 5th
      bypostauthor | n/a | When the comment author is also the post author
      byuser | n/a | For any comment by a registered user
      c-h00–24 | `gmdate('h')` | For a comment posted at a specific hour (Offset to GMT)
      c[n] | n/a | For counting comments relative to the first, where [n] is the number, e.g., c1 for the first comment, c2 for the second, c3 for the third
      c-d01–31 | `gmdate('d')` | For a comment posted on a specific date (Offset to GMT)
      c-m00–12 | `gmdate('m')` | For a comment posted in a specific month (Offset to GMT)
      c-y2007 | `gmdate('Y')` | For a comment posted in a specific year (Offset to GMT)
      comment | n/a | A general class, applied to every comment
      comment-author-[name] | n/a | For a comment by a specific registered user, where [name] is the user's login name, e.g., comment-author-john
      t[n] | n/a | For counting trackbacks relative to the first, where [n] is the number, e.g., t1 for the first trackback, t2 for the second, t3 for the third
      trackback | is_trackback() | When a comment is a trackback/pingback

4. ## Web standards

   The Sandbox is compliant with both XHTML and CSS standards. What does this mean? An explanation of web standards from The Web Standards Project:

   > Complying with web standards can give your web pages greater visibility in web searches. The structural information present in compliant documents makes it easy for search engines to access and evaluate the information in those documents, and they get indexed more accurately.

   > Accessibility is an important idea behind many web standards. Not only does this mean allowing the web to be used by people with disabilities, but also allowing web pages to be understood by people using browsers other than the usual ones—including voice browsers that read web pages aloud to people with sight impairments, Braille browsers, hand-held browsers, teletext displays, and other unusual output devices.

   You can read more about developing with web standards at 456 Berea Street.

5. ## Microformats

   Microformats are markup that express semantic information in your blog. People and machines can extract information from webpages marked up in a microformat much like feed readers extract information from Atom or RSS syndicated feeds. Essentially it's about making content more accessible.

   Microformats that have been implemented in the Sandbox theme include (less XFN, which is built into WordPress):

   - hAtom: For all blog posts and pages
   - hCard: For all post and comment authors
   - rel="home": For marking links pointing to the blog home page
   - XOXO: For menu, blogroll, archive, and sidebar lists

   Microformats help the Sandbox be an especially POSH WordPress theme. POSH stands for "plain old semantic HTML." It is a term used to refer to best practices of semantic HTML development. The Microformats Wiki POSH article has a working copy of these best practices:

   1. Validate your markup, meaning it should be valid, not just validated
   2. No use of tables for presentational purposes—only for tabular data
   3. Correct any "Bed and BReakfast" markup, i.e., no presentational elements like `b`, and no `<br />`
   4. Correct any "Anorexic anchors," e.g., an `a` element with only a `name` attribute
   5. Use well-formed, semantic class names (Sandbox does this for you)

   So the Sandbox can be highly POSH, but the semantic use of HTML elements is completely up to you, the end user. To learn more about writing semantic HTML, visit Mezzoblue.

6. ## Other features

   In addition to the more advanced, code-related features of the Sandbox, there are at least two other features that make the Sandbox a highly viable choice as a base theme.

   1. ### Comments on pages

      Comments are not displayed on pages by default, but are displayed on posts, per the current convention. You can enable comments on a per page basis by adding a custom key/value with only the text `comments`.

      To enable comments on a page:

      1. In the Write › Page menu, expand the Custom Fields box
      2. In the Custom Fields box, add a new key with the exact text: `comments`
      3. Add any text for a value (some text must be included for the key to save)
      4. Click Add Custom Field to save the key/value
      5. Comments should now be enabled on that page

      Enabling comments simply includes the `comments.php` file with the page. You can turn off comments on a page by deleting the `comments` key/value. This does not delete any exisiting comments, but simply disables `comments.php` from loading with the page.

   2. ### Page templates

      There are two page templates included: Links Page (`links.php`) and Archives Page (`archives.php`). You can add a title, text, and enable comments (see above) with both of these page templates.

      To use the page templates:

      1. In the Write › Page menu, expand the Page Templates box
      2. From the drop-down, select the page template to use
      3. Add a title and text (optional) for the page
      4. Click Create New Page / Save to publish the page

      The Archive Page template displays archives by month and by category. The Links Page displays links by link category.

7. ## License

   The Sandbox © 2006–2007 is licensed under the GNU General Public License:

   > This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

   > This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.

   > You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.