Filter Hook Reference List
As of Thesis 1.5.1, filters are an important part of what’s possible in Thesis customization. An introduction to Thesis filters is available, and we’re hoping to add an increasing number of possible filters in the future to allow for increasingly custom designs, but what you’re really interested in is what’s possible today, right? This doc’s for you!
As stated in the introduction to filters, the basic structure of a filter looks like this:
function custom_filter($content) {
return $content;
}
add_filter('name_of_filter_hook', 'custom_filter');
Very similar to hooks, which you’re all rocking spectacularly!, but with key differences: A filter must accept a variable, a filter must return something (no echoes here, folks), and add_filter() is used rather than add_action().
To get started, though, you need to know which filter hooks are available as well as what the default value of $content is for each hook. Once you have those things, you’ll be able to perform customizations to your heart’s content on Thesis’ output.
You don’t necessarily have to simply act on $content! You can ignore it completely, build your own output using PHP and WordPress template tags, and then return it instead.
All that said, here you go:
thesis_allowed_tags-
$contentincludes the entirespan.allowed, which contains the list of allowed tags as seen in most common forms.Whatever is returned by this hook will be output within
p.comment_box. thesis_avatar-
$contentincludes the entirespan.avatar, which contains comment authors’ avatars as well as a link to their sites, if applicable.Whatever is returned by this hook will be output within
dt.comment. thesis_body_classes-
$contentcontains an array of classes which are applied tobody.Additional classes added via filter must be valid HTML classes and must be an array.
thesis_comments_intro-
$contentincludes the entirediv.comments_introwhich appears before the list of comments and before trackbacks on individual posts.Whatever is returned by this hook will be output within
div#comments. thesis_comments_link-
$contentincludesp.to_commentsand everything in it, which is the link at the end of posts on, for example, the main blog page which also includes how a number of how many comments the post has.Whatever is returned by this hook will be output within
div.format_text thesis_content_classes-
$contentcontains a space separated list of classes which are applied todiv#content.Additional classes added via filter must be valid HTML classes and must be space delimited.
thesis_comments_navigation-
$contentcontains the entirediv.prev_nextwhich contains previous/next comment page navigation, if paginated comments is enabled within WordPress.Whatever is returned by this hook will be output within
div#comments thesis_get_footer-
$contentis empty by default. This filter can only be used to return the slug of a custom footer file; for instance, if you want to use the filefooter-custom.php, your filter should returncustom. thesis_get_header-
$contentis empty by default. This filter can only be used to return the slug of a custom header file; for instance, if you want to use the fileheader-custom.php, your filter should returncustom. thesis_img_caption_shortcode-
$contentis not defined for this filter hook. Rather, it exists so that you may replace Thesis’ default gallery handling shortcode with your own function. An example, based on Thesis 1.5.1’s gallery handling, would look like this:function custom_img_caption_shortcode($attr, $content = null) { // Get necessary attributes or use the default. extract(shortcode_atts(array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ), $attr)); // Not enough information to form a caption, so just dump the image. if (1 > (int) $width || empty($caption)) return $content; // For unique styling, create an ID. if ($id) $id = ' id="' . $id . '"'; // Format our captioned image. $output = "<div$id class=\"wp-caption $align\" style=\"width: " . (int) $width . "px\"> $content <p class=\"wp-caption-text\">$caption</p>\n</div>"; // Return our result. return $output; } add_filter('thesis_img_caption_shortcode', 'custom_img_caption_shortcode'); thesis_trackback_datetime-
$contentlooks like this when evaluated:<span>February 7, 2009 at 2:22 am</span>. The function used for the date isget_comment_date()and for the time,get_comment_time().This filter is passed a second parameter,
$comment, which is the array defining the currently acted upon trackback, allowing you to use that information to customize even on a per-trackback level. See after the list of filter hooks for information on using multiple parameters.Whatever is returned by this hook will be displayed within a
ddin thedl#trackback_listlist. thesis_trackback_link-
$contentcontains the output ofget_comment_author_link(), which is an HTML link pointing to the site that created the trackback.This filter is passed a second parameter,
$comment, which is the array defining the currently acted upon trackback, allowing you to use that information to customize even on a per-trackback level. See after the list of filter hooks for information on using multiple parameters.
Whatever is returned by this hook will be displayed within a dt in the dl#trackback_list list.