I was bored yesterday so I made a little site called (I love ccTLDs). Its a silly stupid little site that basically tells you who is hosting a site based on the nameservers. Its probably not that useful and there are still some bugs I need to fix and enhancements I want to make but I was pleasantly surprised that I actually got it to work. I really like having projects even small ones so hopefully I can find something else to do like this next week.

Clearing Default Fields with Gravity Forms

[sourcecode language=”javascript”]
jQuery(document).ready(function() {

jQuery.fn.cleardefault = function() {
return this.focus(function() {
if( this.value == this.defaultValue ) {
this.value = "";
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
jQuery(".clearit input, .clearit textarea").cleardefault();



Contextual Help with WordPress 3.3

If you are looking for the right away to do contextual help in WordPress 3.3 look no further than Twenty Eleven. It does everything by the book including a fallback for WordPress 3.2. Just look in /inc/theme-options.php in Twenty Eleven starting at line 114. Props to @nacin for pointing this out to me.

oEmbed = Awesome

I was aware of oEmbed as Obox uses it in their video meta boxes, but I really didn’t know much about it. What I didn’t know is that all you have to do to use it is paste the link to a video or image on a new line and WordPress will automatically go out, find and return the media. If you want to see what sources are whitelisted by default, please see this codex entry. I found out about this from a video from WordPress Montreal 2011 starring Otto and Nacin. There is a lot of really cool things in that video, you should really check it out.

Note: The video was embedded in this post by just posting the url on a new line in the WordPress visual editor

P.S. Don’t forget to set your $content_width constant so WordPress knows how large to make your media.

if ( ! isset( $content_width ) )
	$content_width = 584;

Contextual Help Menus and Custom Post Types

I am a big fan of custom post types and I use them in just about every project I do now. The same thing goes for contextual help menus. I think they are one of the most underutilized aspects of WordPress and I am a firm believer that if you have an admin screen you need to have a contextual help menu (I’ll save this particular rant for another time). But what I just noticed is that by default when you create a CPT it does not create a contextual help menu. I guess I thought that it would display the same menu for a CPT as a regular post but I was wrong.

So now that I know that custom post types do not have contextual help menus what should I do about it? At the very minimum even if you do not want to take the time to write your own custom help menu you should at least include the regular post help menu. For your convenience I have put together a gist with the code you need. I based my code off this codex entry. That being said, if you modify either the list view or the editor view of your custom post type you really should modify the help menus to reflect that. There is nothing worse than asking a user to input something in Box A when Box A no longer exists.

What do you think? Am I making too big of deal about this? Do you think all CPTs need a contextual help menu?

Finishing Touches for Custom Post Types

Lately most client/Obox projects have involved custom post types of one kind or another. However one thing that has always bothered me is how these custom post types don’t show up in the Right Now Dashboard Widget. I know the widget only shows you how many posts (or post types) there are and many people simply turn it off but I still want my custom post types to be represented there.

After a quick Codex search I found this entry Right Now Dashboard Widget, which is really nice because it gives a ready to go example where all you need to do is change a few lines of code and you are in business.

What do you think? Is it worth the effort? Does anybody really care if your CPT’s are listed in the Right Now Dashboard Widget besides me?


An example of this technique applied to a Custom Post Type

Cleaning up the Comment Form

While trying to help someone in the forums today I found a much better way to work with the WordPress comment form than I had been using in the past.

Here are two articles that I found that show how to implement it correctly.

Better way to do Featured Posts

For as long as I can remember every commercial WordPress theme has had some sort of featured posts. Either in the form of a slider or a specific area of a home page. The usual method was to have a custom loop where you call either all the posts in a particular category or tagged with a particular tag. While this got the job done it is messy and required the user to remember what what special steps were needed to mark their posts are featured.

I recently read a post on the ThemeShaper blog written by the awesome Ian Stewart where he offered a different (& better) method.  Ian’s method involves using a hidden custom taxonomy instead. If you follow the code in his blog post you will end up with a nice checkbox option in the backend.

Finished Result

After setting up the backend option all you need to do it setup a custom loop that only includes posts that are in that custom taxonomy and you have featured posts without the messiness of using tags or categories. This method also adheres to the WordPress philosophy of “Striving for Simplicity”. Also if the user switches themes there will be less unnecessary things from the previous theme under this method as well.

What do you think? Is this the way to go?

What to do about shortcodes?

I recently read a wonderful post by Justin Tadlock where he outlined the various problems associated with going overboard with shortcodes. The biggest problem he identified was that by using a theme’s shortcodes, you are essentially locked into using one of their themes forever as once you switch themes the special formatting is gone and you are left with stray shortcodes in your posts. While you could just edit each post and remove all the stray shortcodes there has to be a better way. WordPress is loved for it ease of use and special features shouldn’t be added in a way that tarnish that reputation.

Lately I have been trying to think more long term about WordPress themes. While every theme developer wants to believe that they are going to have a customer for life it is important to think how your development decisions will affect your users in the future, especially if they switch to another theme.

Then I ran across a post by Alison Barrett who offered an alternative to shortcodes. Her idea was instead of using shortcodes in her Bolts parent theme she would add new styles to the TinyMCE styles dropdown in the visual editor. By utilizing this method while you will still lose the formatting when you switch themes the correct html will be in place and there will not be any stray shortcodes in your posts, the code will degrade gracefully.

Also in order to provide easy transferal of the css for the html code generated by the styles dropdown I would make sure to have a separate stylesheet (which Alison did) or at least a clearly marked portion of your regular stylesheet that has all the custom styles. Then when the user switches themes all they have to do is transfer over that css and all their previous formatting will be preserved.

Does this method make sense? Any other pros/cons?

Timthumb with WP Multisite

For a while now it has been bothering me that I could not get the timthumb script to work with my WP multisite test site. I would always just end up placing the files in the regular upload directory as I could not get the images in the blogs.dir to show up via timthumb. 

As I finally had a bit of free time, I looked around and found a solution. Basically since the images are stored on the regular domain and my site is technically a subdomain, timthumb thinks that my images are actually stored on an external site and by default timthumb does not allow linking to external sites. The solution is actually quite simple, all you have to do is edit the timthumb settings to allow external sites by changing the “allow external” setting to true and then add your domain to the list of allowed sites.