The following hacks/modifications are standard in Thesis 1.3.3 and thus are no longer required if you’re up-to-date with your installation!
As a card-carrying member of DIYthemes, I officially do not support editing the core Thesis files. That is, after all, what the custom/
folder is there for!
Still, by nature I am a code-tinkerer. Sometimes I can’t leave well enough alone, and sometimes things — like, oh, WordPress 2.7 — come along which change the game a bit.
And so I want to share some of my Thesis core hacks. All I ask is that if you have problems with them, you ask about it here and not on the Thesis support community. (Again, officially, core hacks are outside the scope of support.)
Proceed at your own discretion, and don’t expect instructions on how to enable all of the new commenting features (I’m still working on that…).
-
Localization: Take full advantage of XHTML localization by including WordPress’
language_attributes()
.In
header.php
, find:<html xmlns="http://www.w3.org/1999/xhtml">
Replace with:
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
-
Semantic Classes: WordPress 2.7 introduced a new function,
post_class()
, which can be used to apply a myriad of classes to your posts; in addition to standards such aspost
andhentry
, this function outputs a class for each category & tag applied to the post, enabling nearly limitless customization. In other words, your posts can be styled differently depending on the combination of categories/tags given them. This code requires WordPress 2.7 so don’t think about applying it unless you’ve upgraded!In addition to the classes, a unique
id
is applied to each post/page based upon its ID number.In
lib/functions/loop_functions.php
, find:?> <div class="post_box hentry<?php if ($post_count == 1) echo(' top'); ?>">
Replace with:
$classes = 'post_box'; if ($post_count == 1) $classes .= ' top'; ?> <div <?php post_class($classes); ?> id="post-<?php the_ID(); ?>"> <?php /* <div class="post_box hentry<?php if ($post_count == 1) echo(' top'); ?>"> */ ?>
Find:
<div class="post_box hentry top">
Replace with:
<div <?php post_class('post_box top'); ?> id="post-<?php the_ID(); ?>">
Find:
the_post(); ?> <div class="post_box top">
Replace with:
the_post(); ?> <div <?php post_class('post_box top'); ?> id="post-<?php the_ID(); ?>">
Find:
the_post(); ?> <div class="post_box hentry<?php if ($post_count == 1) echo(' top'); ?>">
Replace with:
the_post(); $classes = 'post_box'; if ($post_count == 1) $classes .= ' top'; ?> <div <?php post_class($classes); ?> id="post-<?php the_ID(); ?>"> <?php /* <div class="post_box hentry<?php if ($post_count == 1) echo(' top'); ?>"> */ ?>
-
Logout Link: The logout functionality in WordPress 2.7 has been upgraded to contain nonce-based security. What this means is that if you are using any hard-coded logout links, they will no longer work. In Thesis, there is such a logout link in the comment form for logged in users (“You are logged in as x. Logout →”), and sure enough it doesn’t work if WordPress has been upgraded to 2.7. This fix is easy enough.
In
comments.php
, find:"' . get_option('siteurl') . '/wp-login.php?action=logout"
Replace with:
"' . wp_logout_url(get_permalink()) . '"
-
Comment Form Accessibility: In your Discussion settings panel, chances are good that you have your blog set to require a name & e‑mail address; however, Thesis doesn’t mark them as required. The fix I’ll show you not only adds a visual cue — an asterisk — but also an attribute letting (certain?) screen reading software know to give an auditory cue that the fields are required as well.
In
comments.php
, find:<p><input class="text_input" type="text" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="1" /><label for="author"><?php _e('Name', 'thesis'); ?></label></p> <p><input class="text_input" type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="2" /><label for="email"><?php _e('E-mail', 'thesis'); ?></label></p>
Replace with:
<p><input class="text_input" type="text" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="1"<?php if ($req) echo ' aria-required="true"'; ?> /><label for="author"><?php _e('Name', 'thesis'); if ($req) echo ' <span class="required-field" title="Required">*</span>'; ?></label></p> <p><input class="text_input" type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="2"<?php if ($req) echo ' aria-required="true"'; ?> /><label for="email"><?php _e('E-mail', 'thesis'); if ($req) echo ' <span class="required-field" title="Required">*</span>'; ?></label></p>
The
aria-required
attributes are part of a working draft from the W3C and so will for the time being invalidate your markup. However, when weighing accessibility against validation, accessibility often proves far more worthwhile. -
XHTML Validation: These changes are for no other reason than to increase adherence to markup standards but otherwise do not affect the display or functionality of Thesis.
In
comments.php
, find:<p class="comment_box"><textarea name="comment" id="comment" tabindex="4"></textarea></p>
Replace with:
<p class="comment_box"><textarea name="comment" id="comment" tabindex="4" cols="40" rows="8"></textarea></p>
Find:
'/wp-login.php?redirect_to=' . get_permalink() . '"
Replace with:
'/wp-login.php?redirect_to=' . urlencode(get_permalink()) . '"
That’s all for now. Happy hacking, and remember, don’t go looking for support at DIYthemes for these, or your security clearance for these top secret hacks may get revoked. ;-)
Join the Discussion