Top Secret Thesis Hacks

The fol­low­ing hacks/modifications are stan­dard in The­sis 1.3.3 and thus are no longer required if you’re up-to-date with your installation!

As a card-car­ry­ing mem­ber of DIYthemes, I offi­cial­ly do not sup­port edit­ing the core The­sis files. That is, after all, what the custom/ fold­er is there for!

Still, by nature I am a code-tin­ker­er. Some­times I can’t leave well enough alone, and some­times things — like, oh, Word­Press 2.7 — come along which change the game a bit.

And so I want to share some of my The­sis core hacks. All I ask is that if you have prob­lems with them, you ask about it here and not on the The­sis sup­port com­mu­ni­ty. (Again, offi­cial­ly, core hacks are out­side the scope of support.)

Pro­ceed at your own dis­cre­tion, and don’t expect instruc­tions on how to enable all of the new com­ment­ing fea­tures (I’m still work­ing on that…). 

  • Local­iza­tion: Take full advan­tage of XHTML local­iza­tion by includ­ing Word­Press’ 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(); ?>>
  • Seman­tic Class­es: Word­Press 2.7 intro­duced a new func­tion, post_class(), which can be used to apply a myr­i­ad of class­es to your posts; in addi­tion to stan­dards such as post and hentry, this func­tion out­puts a class for each cat­e­go­ry & tag applied to the post, enabling near­ly lim­it­less cus­tomiza­tion. In oth­er words, your posts can be styled dif­fer­ent­ly depend­ing on the com­bi­na­tion of categories/tags giv­en them. This code requires Word­Press 2.7 so don’t think about apply­ing it unless you’ve upgraded!

    In addi­tion to the class­es, 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 func­tion­al­i­ty in Word­Press 2.7 has been upgrad­ed to con­tain nonce-based secu­ri­ty. What this means is that if you are using any hard-cod­ed logout links, they will no longer work. In The­sis, there is such a logout link in the com­ment form for logged in users (“You are logged in as x. Logout →”), and sure enough it does­n’t work if Word­Press has been upgrad­ed 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()) . '"
  • Com­ment Form Acces­si­bil­i­ty: In your Dis­cus­sion set­tings pan­el, chances are good that you have your blog set to require a name & e‑mail address; how­ev­er, The­sis does­n’t mark them as required. The fix I’ll show you not only adds a visu­al cue — an aster­isk — but also an attribute let­ting (cer­tain?) screen read­ing soft­ware know to give an audi­to­ry 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 attrib­ut­es are part of a work­ing draft from the W3C and so will for the time being inval­i­date your markup. How­ev­er, when weigh­ing acces­si­bil­i­ty against val­i­da­tion, acces­si­bil­i­ty often proves far more worthwhile.

  • XHTML Val­i­da­tion: These changes are for no oth­er rea­son than to increase adher­ence to markup stan­dards but oth­er­wise do not affect the dis­play or func­tion­al­i­ty 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. Hap­py hack­ing, and remem­ber, don’t go look­ing for sup­port at DIYthemes for these, or your secu­ri­ty clear­ance for these top secret hacks may get revoked. ;-)


Posted

in

by

Tags:

Comments

7 responses to “Top Secret Thesis Hacks”

  1. Claude Avatar

    Great post as usu­al. Thanks!

  2. Rick Butts Avatar

    Your site is AWESOME and your work in the forum is fabulous!

    You replied to the post about the copy­blog­ger land­ing page — and men­tioned some code in the BODY tag — but I have no idea how to create/edit that.

    To cre­ate a tem­plate that I can add con­tent to in the PAGES area of The­sis — what code would need to be in it to cre­ate a sim­ple 750 width cen­tered table with the same back­ground as the rest of the blog?

    Thanks!
    Rick Butts

  3. Bruce Avatar

    Great tips, Rick. Thanks for sharing!

  4. Somone Avatar

    Re: seman­tic class­es code for cus­tomiz­ing categories/tags — can you pro­vide a bit more insight for what to add to the cus­tom stylesheet?

    The stuff that looks like this :» .cus­tom #some­thinghere { etc…}

    Thanks

  5. Rick Beckman Avatar

    Depends entire­ly on what you’re want­i­ng to do.

    For instance, to col­or all posts in the “Word­Press” cat­e­go­ry in invert­ed col­ors, I could use this: .category-wordpress { color: #fff; background: #111; }

  6. Rick Beckman Avatar

    Unless I’m imag­in­ing things, it looks as though every sin­gle one of the above hacks are now stan­dard in The­sis 1.3.3! Enjoy! :D

Join the Discussion

Your email address will not be published. Required fields are marked *

Use your Gravatar-enabled email address while commenting to automatically enhance your comment with some of Gravatar's open profile data.

Comments must be made in accordance with the comment policy. This site uses Akismet to reduce spam; learn how your comment data is processed.

You may use Markdown to format your comments; additionally, these HTML tags and attributes may be used: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Rick Beckman