Add Googlebot User Agent to Safari Develop Menu

Googlebot Safari

If you’re like me, you’ve wanted to have the Googlebot user agent availalbe in the Develop menu of Safari.

  1. Go to /Applications/
  2. Right-click on Safari.app and select Show Package Contents
  3. Navigate to Contents/Resources/
  4. Find UserAgents.plist
  5. Open UserAgents.plist in your favorite text editor
  6. Either
    • Replace with the contents of this file and continue to step 9: [download id="12"]
    • … or continue on:
  7. At the end of the file, find:
    </array>
    </plist>
  8. Replace with:
    	<dict>
    		<key>separator</key>
    		<true/>
    	</dict>
    	<dict>
    		<key>name</key>
    		<string>Googlebot</string>
    		<key>version</key>
    		<string>2.1</string>
    		<key>platform</key>
    		<string>Googlebot</string>
    		<key>user-agent</key>
    		<string>Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</string>
    	</dict>
    	<dict>
    		<key>name</key>
    		<string>Bing</string>
    		<key>version</key>
    		<string>2.0</string>
    		<key>platform</key>
    		<string>Bingbot</string>
    		<key>user-agent</key>
    		<string>Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)</string>
    	</dict>
    </array>
    </plist>
    
  9. Save the file (you’ll need to type in your user password)

Voila! Now in your Safari Develop > User Agent menu, you should see Googlebot 2.1 - Googlebot and Bing 2.0 - Bingbot.

Posted in Mac, Web Development | Tagged , , , , , , | Leave a comment

Time Out Free: An App to Enforce Your Stretch Breaks

It’s hard to get up and stretch on a regular basis, especially when your computer allows you to keep working!

I will spend all day on my ass. That can’t be good. I have been dreaming about the perfect app that would force me to get up by blocking all access to what I was doing.

I found the app I’ve been looking for: it’s called Time Out Free.

Time Out Screenshot Time Out Free is a timer that kicks in every so often (you set the rules) and blocks your entire screen. You can set short breaks and long breaks, and you can override the breaks if you want to. Time Out Free makes it easy for me to remember to stand up, stretch my legs and move. It encourages me to stay hydrated and to fill up my empty water glasses.

It’s a developer’s best friend (and worst nagging enemy!).

It can be frustrating, but I know that it’s good for me, so I removed the option to skip breaks. The three options are:

  1. Take a break
  2. Delay the break by 1 minute
  3. Delay the break by 2 minutes

After three delays, I get annoyed and stretch. The app works!

Suggestion for improvement: move to the menu bar.

Given that it’s a free app, it’s already amazing. I believe an improvement would be to have the app in the menu bar and remove it from the dock. That way, it’s not taking up space in the app switcher. To get around this for now, I’m using Dock Dodger, which works well…except that the preferences are not easily accessible.

Posted in Uncategorized | Leave a comment

Create a Custom Error Page for “Error establishing a database connection”

Error establishing a database connection

Here’s how to make a custom database error page for WordPress.

If your site’s all set up and you see “Error establishing a database connection,” that’s an immediate “oh crap” situation.

Hostgator.com, the company that hosts this website, has had some issues recently, and I’ve seen that screen a little too often.

If you want to define a custom “Error establishing a database connection” screen, add a file to your /wp-content/ folder named db-error.php. That will be loaded instead of that stupid message. Check out SEODenver.com’s db-error.php.

A Good Idea for SEO

If you want to prevent search engines from indexing your site while it’s down, add <meta name="robots" content="noindex, nofollow" /> to your page’s <head>. You sure don’t want Google caching your error! Continue reading

Posted in WordPress | Tagged , , | 1 Comment

Generate a Link to Activate a Plugin in WordPress

Here’s another specialized plugin development tip!

If you want to create a link to activate a plugin, you need to know the path of the plugin file. Let’s use Akismet for this example.

$path = 'akismet/akismet.php';
$link = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$path), 'activate-plugin_'.$path);

The $link URL will be something like http://yoursite.com/wp-admin/plugins.php?action=activate&plugin=akismet%2Fakismet.php&_wpnonce=f97dabdf9

Posted in Web Development, WordPress | Tagged , | Leave a comment

How to Hard-Code a UA String for the Google Analytics for WordPress Plugin

If you want to define a Google Analytics “UA String” while using Yoast Google Analytics plugin for WordPress.

Add the following to your theme’s functions.php file:

add_filter( 'option_Yoast_Google_Analytics', 'custom_ua_string_filter');

function custom_ua_string_filter($options = array()) {
	$options['uastring'] = 'UA-########-#';
	$options['manual_uastring'] = true;
	return $options;
}

For users of WordPress Multisite, this will allow you to pre-configure new blogs with the same UA string.

Posted in Web Development, WordPress | Leave a comment

Enable Shortcodes for Gravity Forms Field Descriptions

To enable shortcodes inside your Gravity Forms form description, field labels and descriptions, you need to add the following code to your theme’s functions.php file:

add_filter('gform_pre_render', 'walker_do_shortcode_gform_description', 10, 2);

function do_shortcode_gform_description(&$item, $key) {
	$item = do_shortcode($item);
}

function walker_do_shortcode_gform_description($form, $ajax) {

	$form['description'] = do_shortcode($form['description']);
	array_walk_recursive($form['fields'], 'do_shortcode_gform_description');

	return $form;
}
Posted in WordPress | Tagged | Leave a comment

Merge Settings Into an Array in WordPress

Arrays Merging

I found people are coming to this site (to an unrelated article) looking for a way to merge settings into an array.

You’re looking for wp_parse_args()

The main function for WordPress to do this is wp_parse_args(). You likely want this function.

Learn more about wp_parse_args()

Also consider shortcode_atts()

This is used for parsing shortcode options. It only supports defined arguments.

Learn more about shortcode_atts()

Posted in WordPress | Tagged , , , | 3 Comments

Mitt Romney’s Compressed Images

Mitt, don’t skimp on image optimization

I just visited Mitt Romney’s website for the first time and noticed right away that his site looked cheap because his button images had been so compressed for load time.

 

For comparison, here are some similar boxes on BarackObama.com

 

Look for yourself

I don’t think the affect of the bad quality comes across in these pictures. I encourage you to compare and contrast.

Posted in Design | Tagged , , , | 6 Comments

Simple Way to Get Plugin Status in WordPress

Active plugin volcano.

I have previously written on how to determine if a widget is active. This is helpful for widgets, but not for plugins.

WordPress has a couple of different functions that help you determine plugin status. They are both located in wp-includes/plugin.php

  • validate_plugin() spits out an error if the plugin file does not  exist or has an invalid header. This lets you know that the file is there.
  • is_plugin_inactive() lets you know if the plugin is not active (using the is_plugin_active() function)

A function to get plugin status

Using these two functions, I put together a one-size-fits-all function get_plugin_status(). Continue reading

Posted in Web Development, WordPress | Tagged , , , , | Leave a comment

A WordPress Developer’s Tips for Using Panic Coda

Panic CodaI use Panic Coda for coding. I like its Mac-style interface and it “fits” me well. There are some items that are frustrating, including a lack of auto-complete for functions you’ve already used in your code. Here are three tips to improve your coding experience. Continue reading

Posted in Web Development, WordPress | Tagged , , | 5 Comments