Change which Meta Boxes are Shown or Hidden by Default

If you want to change what meta boxes are shown and hidden by default instead of trying to walk a client through the process of customizing their own screen, you can use this code as a starting point:

add_filter( 'default_hidden_meta_boxes', 'change_default_hidden', 10, 2 );
function change_default_hidden( $hidden, $screen ) {
    if ( 'page' == $screen->id ) {
        $hidden = array_flip($hidden);
        unset($hidden['authordiv']); //show author box
        $hidden = array_flip($hidden);
        $hidden[] = 'pageparentdiv'; //hide page attributes
    }
    return $hidden;
}

Swap Color Schemes When Switching Between Network and Site Admins

I wanted to find a way to make it just a little bit more obvious when I switched between the network and site admins. But I didn’t want to have to do a lot of actual customizing. So using built in styles, I found I could just swap the color schemes.

add_action( 'admin_print_styles', 'admin_color_swap', 99 );
function admin_color_swap() {
    if ( is_network_admin() ) {
        global $current_user;
        get_currentuserinfo();
        $selected = $current_user->admin_color;
        $swapped = array( 'fresh' => 'classic', 'classic' => 'fresh' );
        $new = $swapped[$selected];        
        echo '<link rel="stylesheet" type="text/css" href="/wp-admin/css/colors-'.$new.'.css" />';
    }
}

Force the HTML Uploader

If you need to force users to use the HTML uploader, you can do so with this

add_filter( 'flash_uploader', 'force_html_uploader' );
function force_html_uploader( $flash ) {
	remove_action('post-html-upload-ui', 'media_upload_html_bypass' );
	return false;
}

The remove_action() portion removes the “You are using the Browser uploader” text. The rest is what forces the flash setting to be false.

List Category ID in Quick Actions

One thing I’ve found frustrating is that there doesn’t seem to be an easy way of getting a category (or other term) ID. This little snippet will add it to the “quick actions” that appear when you mouseover a term’s row.

add_filter( "tag_row_actions", 'add_cat_id_to_quick_edit', 10, 2 );
function add_cat_id_to_quick_edit( $actions, $tag ) {
	$actions['cat_id'] = 'ID: '.$tag->term_id;
	return $actions;
}

Remove the Media Library Tab

I’ll leave the ‘why’ to you, but here’s the ‘how’

add_filter( 'media_upload_tabs', 'no_media_library_tab' );
function no_media_library_tab( $tabs ) {
    unset($tabs['library']);
    return $tabs;
}

Okay, one possible reason would be that you want to restrict users from accessing media that’s been attached to another post.

Add Copy to the Add New Tag (or other Taxonomy) Page

Maybe you need to add some extra text to the page to explain to a user why they should take a minute to spellcheck their new category or tag. Or perhaps you want to want to encourage them to check if a certain category already exists as a plural or singular from. You can add this extra copy in at least 2 places on the various taxonomy admin pages.

add_action( 'after-' . 'category' . '-table', 'copy_below_table' );
function copy_below_table( $taxonomy ) {
    echo '<p>Lorem ipsum</p>';
}

add_action( 'category' . '_pre_add_form', 'copy_above_form' );
function copy_above_form( $taxonomy ) {
    echo '<p>Dolor sit amet</p>';
}