Mostly about my amusement

Day: August 12, 2010 (page 1 of 1)

Easy Twitter Button for WordPress

Twitter announced their own Tweet Button and have provided a page for creating a button on your web site. You enter some info and you get the HTML code to add.

Extending WordPress has always been easy. You can add what you want via a plugin, or you can put the functionality into your theme’s function.php file.

I wanted to play around with adding this to my blog, so I went to their page and created my button. I then used the generated code as a template for what I wanted to do.

There is no way I’m savvy enough to write a plugin, but adding a filter to my theme’s function.php file is within my reach.

This is from an idea I got when I read WP Beginner’s post on how to add post thumbnails to your RSS feed. I used his code to do this.

function tweet_button($content) {
        global $post;
        // Your Twitter ID goes here
        $twitterid = 'jan_dembowski';
        $tweetbutton = '<div class="tweet-button">';
        $tweetbutton = $tweetbutton . '<a href="http://twitter.com/share" class="twitter-share-button" data-url="' . get_permalink() .'" data-text="' . get_the_title() .'" data-count="horizontal" data-via="' . $twitterid . '">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
        $tweetbutton = $tweetbutton . '</div>';
        // $content = $content . $tweetbutton;
        $content = $tweetbutton . $content;
        return $content;
        }
add_filter('the_content', 'tweet_button');

You can download the code via this text file link.

It’s not exactly user friendly, but it gets the job done. I wrapped it in a <div> so I can style it later. If you want the button at the end instead of the beginning, then comment out line 9 and un-comment out line 8.

It’s a fun hack for me and I am sure that soon there will be a plugin to do this. If you do decide to do this then make sure you backup your theme’s function.php file. Any typo’s or mistakes will make your WordPress blog stop working.

Coraline child theme

Have I mentioned how easy it is to use WordPress child themes? I can’t stress it enough, never modify a WordPress theme. Create a child theme instead.

I just converted a blog from an old outdated Cutline theme to a SVN copy of Coraline.  This is the WordPress.COM replacement for the Cutline theme.  The old theme bugged me for a few reasons, mainly it was the lack of basic features such as Gravatar support. I had meant to clean it up but never got around to it.

It took me less than an hour to make the switch. I retrieved a copy of Coraline like so

$ cd wp-content/themes
$ svn co http://svn.automattic.com/wpcom-themes/coraline coraline

This keeps an unmodified copy of the Coraline theme.  Once it’s in the WordPress.ORG website, I’ll replace it with that copy.

All I had to do was create a separate directory and create a style.css file with the following:

/**
 * Theme Name: Coraline for Stefan's Stuff
 * Description: Jan Dembowski's Coraline Child Theme
 * Version: 1.0
 * Template: coraline
 */

@import url("../coraline/style.css");

/* =Asides
---------------- */

.home #content .aside {
 border-left: 1px solid red;
}

The old asides had a slightly different styling.  I made copies of the header.php and footer.php files into my child theme directory and added an archives.php template. I modified one line in each of the copies.

I tossed in a rotate.php script and copies of the random banner images and I was all set. I did need to resize the old banner images from a width of 970 to 990 but that was it.

Child Themes are cool and once again I can keep the parent theme up to date without worrying about my changes.

Android or iPhone 4?

Do I get an Android phone or an iPhone 4? I’m in no rush to get a new phone but I do periodically suffer from phone envy.

I am a fan of easy-to-use technology. I currently own an iPhone 3G with iOS 4.0.1 installed. My phone has been jailbroken not because I have a “SOFTWARE MUST BE FREE!!!1!” itch, but because I wanted to tweek my phone in ways that Apple doesn’t support for my hardware.

Cool Applications, not so cool app store

One of my favorite apps on my iPhone is Camera+. It lets me take photos, make adjustments, and share those photos online. All within the app and very easily.

The Camera+ developers came up with the idea of modifying the volume up button to be used as a shutter button. This re-mapping of the button would only be done while the user is in the app. It’s a great idea and makes using Camera+ easier.  But the idea was rejected by the app store, so the developers created a back door to enable that setting.

That’s a sensible work around because the app store was apparently afraid that re-mapping the volume up key while in the Camera+ app would create confusion. Since the end-user would have to access a specific application URL, they would have to know what they were doing.

But as expected the Camera+ app has been removed from the app store. Rules are rules, especially when they are arbitrary, imaginary, mostly made up, and not published.

Do I really want to continue using a product that fosters an environment like this? I know that the Android Market Place has it’s pitfalls too but the Apple App store is driven by incompetence.

Android is becoming more cool

I know two people who have Android phones from Verizon.  The first phone I’ve seen is the HTC Incredible.  The UI is easy to use and makes the experience fun.

The other phone is the Droid X.  The display portion alone feels like it’s bigger than my iPhone 3G.  It’s not a small phone in comparison but the display is fantastic. It’s not as slick as an HTC phone but it is close.

How would a Gorilla design a better Gorilla?

I’ve also seen the iPhone 4.  The display is phenomenal but it’s essentially a better iPhone 3GS. It’s more resolution, more memory, faster CPU.  But it’s still an iPhone and I already have an inferior version right now.

Why just get a better version of the iPhone 3G? Why not get a new phone and try out the other guys? If Camera+ existed for the Android phone, that would go a long way to hastening my decision.