Change Admin Footer Text

If you need to customize the WordPress administration area, you’ll find this useful.

add_filter('admin_footer_text', 'left_admin_footer_text_output'); //left side
function left_admin_footer_text_output($text) {
    $text = 'How much wood would a woodchuck chuck?';
    return $text;
}

add_filter('update_footer', 'right_admin_footer_text_output', 11); //right side
function right_admin_footer_text_output($text) {
    $text = "That's purely hypothetical.";
    return $text;
}

Custom Post Types

Adding a new post type, for when ‘posts’ and ‘pages’ just won’t do.

add_action( 'init', 'my_new_post_types' );
function my_new_post_types() {
    $labels = array(
        'name' => _x('Hotels', 'post type general name'),
        'singular_name' => _x('Hotel', 'post type singular name'),
        'add_new' => _x('Add New', 'hotel'),
        'add_new_item' => __('Add New Hotel'),
        'edit_item' => __('Edit Hotel'),
        'new_item' => __('New Hotel'),
        'view_item' => __('View Hotel'),
        'search_items' => __('Search Hotels'),
        'not_found' =>  __('No hotels found'),
        'not_found_in_trash' => __('No hotels found in Trash'), 
        'parent_item_colon' => '',
        'menu_name' => 'Hotels'    
    );
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'show_in_menu' => true, 
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'has_archive' => true, 
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','author','thumbnail','excerpt','comments')
    ); 
    register_post_type('hotel',$args);
}

Hide Plugin Update count

In case you need to hide the plugin update count (can’t/don’t want to update yet) you can hide it with this. Can be especially useful if you don’t want clients to wander over the the update area.

add_action('admin_menu', 'remove_plugin_update_count');
function remove_plugin_update_count(){
    global $menu, $submenu;
    $menu[65][0] = 'Plugins';
    $submenu['index.php'][10][0] = 'Updates';
}

Remove Title Attribute from Featured Image

If you have featured images (formerly post thumbnails) that aren’t named as well as they could be, it’s nice to remove the title attribute so that things like “header-large” don’t appear in the tool tips.

add_filter('post_thumbnail_html', 'remove_feat_img_title');
function remove_feat_img_title($img) {
    $img = preg_replace('/title="(.*?)"/','',$img);
    return $img; 
}

Custom Taxonomies

When you need more than just ‘categories’ and ‘tags’ use custom taxonomies.

Especially useful in combination with custom post types.

add_action('init', 'my_new_taxonomies');
function my_new_taxonomies() {

	$labels = array(
	'name' => __( 'Action Hooks' ),
	'singular_name' => __( 'Action Hook' ),
	'search_items' =>  __( 'Search Action Hooks' ),
	'popular_items' => __( 'Popular Action Hooks' ),
	'all_items' => __( 'All Action Hooks' ),
	'parent_item' => null,
	'parent_item_colon' => null,
	'edit_item' => __( 'Edit Action Hook' ),
	'update_item' => __( 'Update Action Hook' ),
	'add_new_item' => __( 'Add New Action Hook' ),
	'new_item_name' => __( 'New Action Hook' ),
	'separate_items_with_commas' => __( 'Separate hooks with commas' ),
	'add_or_remove_items' => __( 'Add or remove hooks' ),
	'choose_from_most_used' => __( 'Choose from the most used hooks' ),
	'menu_name' => __( 'Action Hooks' ),
	); 

	register_taxonomy('action_hook','post',array(
	'hierarchical' => false,
	'labels' => $labels,
	'show_ui' => true,
	'query_var' => true,
	'rewrite' => array( 'slug' => 'action_hook' ),
	));
}

Fetch the User-Agent String and Save as User Meta

Some times a client will complain that their site doesn’t look right or something equally as vague. Inevitable we ask “What browser are you using?” but getting the answer can be tricky. So, let’s just automatically get their user-agent and save it where we can access it.

Granted, this isn’t perfect. The client could have just logged in from someone else’s computer, and it is possible to fake the user-agent… but I’m counting on this being rare.

Continue reading Fetch the User-Agent String and Save as User Meta

Swap Color Schemes When in the Network Admin

In WordPress 3.1, the network-wide options being moved to their own area in WordPress to make it easier on network administrators.

To take a just a bit further, I put together this script that will switch color schemes when you’re in the Network Admin.

Continue reading Swap Color Schemes When in the Network Admin

Confirm Email Address

If you’re running a WordPress network, and depending on how you’re using it, you may need to get users to confirm or update their email address.

In my situation, I build a lot of sites for clients, and during development I use an email address of my own so they don’t get bombarded with emails they don’t need. But I don’t always change it back when I’m done, or maybe there’s a typo. Or maybe it’s the client that has changed their email address.

Whatever the cause, sometimes these things just need to be double-checked and confirmed. So here’s a small plugin that can be dropped in your mu-plugins folder:

Continue reading Confirm Email Address

Remove WordPress Plugin Update Count From the Menu

My office has a big WordPress multisite installation, so we are careful about updating plugins. As a result, there are ofter a number of plugins begging to be updated. It was getting annoying to see that all the time, so this little snippet gets rid of the notice. Continue reading Remove WordPress Plugin Update Count From the Menu