devinsays/portfolio-post-type — pull request #15 by GaryJones (2013-08-25 15:54:39+00:00)
Title: Re-work taxonomy term body classes.

Simplifies the functions down from three to one. Here, we re-specify the names of the taxonomies, but a future refactor should be able to pull these out into a class property that can be used in multiple methods (including registration).

Use of get_the_ID() instead of global $post; $post->ID.

Better error checking for what get_the_terms() can return, in case someone has unregistered the two taxonomies.

Use of sanitize_html_class() to ensure term values are appropriately sanitized for output.

Use of taxonomy (with underscore replaced with hyphen per code standards for class names) as prefix for the term class, so that there's far less possibility of a term clashing with existing body classes. e.g. a portfolio might be tagged with "full-width", but without a prefix, this might confuse the theme into thinking that the single page should be displayed full width. With this change, the class becomes "portfolio-tag-full-width".

Use of single instance of aray_unique() to remove any duplicates once the classes have been added, instead of a check for in_array() for each and every term for both taxonomies.

See #11.