My Favourite Power Tool

I am talking a lot about power tools in a virtual sense, but actually i just love real power tools.

below is an image of my trusted friend: a BOSCH CSB 800 2RE percussion drill, made in germany, 800 watt power, with three mechanical gears and electronic speed control.

my BOSCH CSB 800 2RE power drill
my BOSCH CSB 800 2RE power drill

i have this tool for over twenty years now, and it has helped me a lot with my diy and handyman projects – from mixing mortar, fixing plaster board to metal frames, building garden decking (driving 15cm long coach screws with its fantastic torque), hanging curtain rails, shelf brackets, drilling holes for wall plugs (from miniscule 4mm diameter precison to massive 12mm dia wall plugs for wash hand basins), to polishing silver jewellery (my hobby).
the machine is nicely balanced, like an extension of my right hand, strong but not overly heavy, simply fun to work with.

Adsense in Content of Posts and Pages for wp3

A flexible way to add google adsense into posts and pages in your wordpress blog.
This appraoch uses shortcodes which are an underused technique of increasing the functionality of themes.
Through the formatting options in the shortcode, the text can flow around the adsense blocks similar as it would happen with inserted images.
Options for the alignment are ‘left’, ‘center’, ‘right’ – anything else will be treated as ‘none’.

The code that needs to be added to functions.php of the theme is shown below:
it is called in the text with: [ a d s e n s e     f l o a t = ' l e f t ' ]

// allowed parameter: 'left', 'center', 'right', 'none';
// other entries will be treated as 'none';
function add_adsense($atts) {
  extract(shortcode_atts(array(
  'float' => 'none',
  ), $atts));
if( $float == 'left' ) $float = ' style=" float:left; margin: 10px 10px 5px 0; "';
elseif( $float == 'center' ) $float = ' style=" display:block; margin: 10px auto; text-align:center; "';
elseif( $float == 'right' ) $float = ' style=" float:right; margin: 10px 0 5px 10px; "';
else $float = '';
$ads = '<span class="adsense "'.$float.'>
<script type="text/javascript"><!--
google_ad_client = "pub-0123412341234123";
/* adsense_in_posts */
google_ad_slot = "1234512345";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</span>';
return $ads;
}

add_shortcode('adsense', 'add_adsense');

You can see the result here entered into a passage of ‘lorem ipsum’:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse in libero libero. Morbi porttitor, sapien et aliquam malesuada, augue elit tincidunt tortor, vel convallis orci felis quis turpis. Maecenas sit amet diam ut nibh rhoncus accumsan in eget urna. Vivamus sed tempor odio. Curabitur ultricies ultricies molestie. Maecenas eu nisl elit, vitae auctor eros. Nam quis risus libero. Nunc nec ligula sem. Nullam eget sem sed nisi porttitor imperdiet. Etiam ac sapien sed est vestibulum iaculis et id mauris. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer tortor magna, malesuada id imperdiet eu, fringilla eget sapien. Donec augue sem, semper et ultrices a, cursus eget nisl. Duis dui enim, ornare ut facilisis eget, egestas ac orci. Etiam viverra varius erat, id feugiat tellus egestas eget.

Aliquam sem purus, ornare ac tempor nec, accumsan ut felis. In cursus massa vitae mauris iaculis nec semper dui commodo. Proin fermentum, lacus ut accumsan scelerisque, orci dui sodales arcu, ac mollis neque odio id turpis. Mauris sagittis tincidunt ultricies. Sed diam ipsum, posuere quis scelerisque et, malesuada quis orci. Mauris nec lectus ac nibh interdum aliquet.

PS: I found more examples of shortcodes in tuttoaster.com

Link Header Image to Home Page

Having the whole header image linking to the home page is one of the most common things of a theme. This article explains how to add this feature to the WordPress theme Twenty Ten.

Edits are to be made in header.php of a child theme of Twenty Ten, at the location recognizable below (theme version 1.6):

<div id="site-description"><?php bloginfo( 'description' ); ?></div>
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<?php
// Compatibility with versions of WordPress prior to 3.4.
if ( function_exists( 'get_custom_header' ) ) {
.....
.....
<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
 <?php endif; ?>
</a></div><!-- #branding -->

The link tag

<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">

was added just after this line

<div id="site-description"><?php bloginfo( 'description' ); ?></div>

and closed it before the end of the #branding div

</a></div><!-- #branding -->

that is all.

Advanced styling of the prev/next post links

when you use the ‘previous/next post’ navigation in single posts, you will have noticed that these links appear empty when there is no previous or next post, as for the latest and the first article.

to keep your page design and to style these occurences by showing a special image or text, you can make use of the virtually undocumented wordpress function ‘get_adjacent_post()’.

see this screenshot of the navigation in a single post page:

prev_next_link

the example below is done for the default theme, and will show a greyed-out text in the place of the links.

<div class="navigation">
<div class="alignleft">
<?php if(get_adjacent_post(false, '', true)) { echo 'Previous older article: '; previous_post_link('%link'); }
else { echo '<span style="color:#bbb;">"'.get_the_title().'" is the oldest post, no further articles. </span>'; } ; ?>
</div>
<div class="alignright">
<?php if(get_adjacent_post(false, '', false)) { echo 'Next newer article: '; next_post_link('%link'); }
else { echo '<span style="color:#bbb;">"'.get_the_title().'" is the latest post: no newer articles. </span>'; } ; ?>
</div>
</div>