Remove Bulk Actions Dropdown

To remove the bulk actions dropdown menu, you simply need to remove all actions! Just hook in and replace the default actions array with an empty array.

add_filter( 'bulk_actions-' . 'edit-post', '__return_empty_array' );

In this case, only the bulk actions menu on the All Posts page will be removed. To use elsewhere, replace ‘edit-post’ with the screen ID.

Default All Posts to the Current User’s Posts

When clicking on All Posts in the main menu, Administrators and Editors will normall see all posts. Use this to change the default view to the user’s own posts. See comments to limit the change to users of a certain roll.

add_action( 'admin_menu', 'show_users_posts_by_default' );
function show_users_posts_by_default() {

	/*if current user is an 'administrator' do nothing*/
	//if ( current_user_can( 'add_users' ) ) return;

	/*if current user is an 'administrator' or 'editor' do nothing*/
	//if ( current_user_can( 'edit_others_pages' ) ) return;

	global $submenu, $user_ID;
	$submenu['edit.php'][5][2] = 'edit.php?author='. $user_ID;
}

Disable the Auto-Scroll/Internal Anchors in Read More Links

If you don’t like that the ‘read more’ links automatically scroll you down the page (to the beginning of what ever comes after the <–more--> tag), you can so a little pattern matching to remove the internal anchor.

add_filter( 'the_content_more_link', 'read_more_no_jump', 10, 2 );
function read_more_no_jump( $link, $text ) {
	$no_more = preg_replace( '/#more-([0-9]*)/', '', $link );
	return $no_more;
}

Force Default Editor Mode

Normally, WordPress will remember which editor mode you were in (Visual or HTML). So if you were using the HTML editor and you save a page, you’ll be returned to the HTML editor.

If you (or your clients) would benefit from always returning to particular mode, you can set that up

add_filter( 'wp_default_editor', 'force_default_editor' );
function force_default_editor() {
	//allowed: tinymce, html, test
	return 'tinymce';
}

*Functionality is there but quirky in pre-3.3

Change Protected Posts Prefix

If you’ve marked a post as “Protected” it is automatically prefixed with “Protected: ”

You may not like that. Here’s how you can change it:

add_filter('protected_title_format', 'change_protected_title_format');
function change_protected_title_format() {
	return 'Members Only: %s';
}

*If this seems oddly familiar, check out yesterday’s post.

Remove Buttons From Distraction-Free Writing

Want even fewer distractions in DFW? Remove some of the buttons

add_filter( 'wp_fullscreen_buttons', 'remove_fullscreen_buttons' );
function remove_fullscreen_buttons( $buttons ) {
	unset($buttons['bullist']);
	unset($buttons['numlist']);
	unset($buttons['1']);
	return $buttons;
}

Here are the buttons you have to work with:

$buttons = array(
	// format: title, onclick, show in both editors
	'bold' => array( 'title' => __('Bold (Ctrl + B)'), 'onclick' => 'fullscreen.b();', 'both' => false ),
	'italic' => array( 'title' => __('Italic (Ctrl + I)'), 'onclick' => 'fullscreen.i();', 'both' => false ),
	'0' => 'separator',
	'bullist' => array( 'title' => __('Unordered list (Alt + Shift + U)'), 'onclick' => 'fullscreen.ul();', 'both' => false ),
	'numlist' => array( 'title' => __('Ordered list (Alt + Shift + O)'), 'onclick' => 'fullscreen.ol();', 'both' => false ),
	'1' => 'separator',
	'blockquote' => array( 'title' => __('Blockquote (Alt+Shift+Q)'), 'onclick' => 'fullscreen.blockquote();', 'both' => false ),
	'image' => array( 'title' => __('Insert/edit image (Alt + Shift + M)'), 'onclick' => "fullscreen.medialib();", 'both' => true ),
	'2' => 'separator',
	'link' => array( 'title' => __('Insert/edit link (Alt + Shift + A)'), 'onclick' => 'fullscreen.link();', 'both' => true ),
	'unlink' => array( 'title' => __('Unlink (Alt + Shift + S)'), 'onclick' => 'fullscreen.unlink();', 'both' => false ),
	'3' => 'separator',
	'help' => array( 'title' => __('Help (Alt + Shift + H)'), 'onclick' => 'fullscreen.help();', 'both' => false )
);

Allow Non-Standard Tags in the Editor

If you find yourself needing to add non-standard tags to the WordPress editor, you may also find yourself feeling very frustrated. With just a little bit of code, you can tell the editor to accept extra tags

add_filter( 'tiny_mce_before_init', 'mce_extended_valid_elements', 10, 2);
function mce_extended_valid_elements( $mceInit, $editor_id ) {
	//allow only the basic tag
	//$mceInit['extended_valid_elements'] .= ',sometag';
	//allow the tag and a attribute
	$mceInit['extended_valid_elements'] .= ',sometag[someattribute]';
	//allow the tag and multiple attribute
	//$mceInit['extended_valid_elements'] .= ',sometag[someattribute|anotherattribute]';
	//allow the tag and any attribute
	//$mceInit['extended_valid_elements'] .= ',sometag[*]';
	return $mceInit;
}

Limit Spellchecker Languages

If you don’t want your spellchecker dropdown to be too big, you can limit the available languages. Cut it down to only a few, or even just one.

add_filter('mce_spellchecker_languages', 'limit_spellchecker_languages');
function limit_spellchecker_languages() {
	//original: +English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv
	return '+English=en';
}

Allow HTML in User Descriptions

By default, WordPress will remove any HTMl from the user bio field on the edit user/profile screen.

It’s very easy to stop WordPress from doing this

remove_filter( 'pre_user_description', 'wp_filter_kses' );

However, you probably don’t want to leave it at that, as users could then add any code (iframes, scripts, etc.) and it wouldn’t be removed.

add_filter( 'pre_user_description', 'wp_filter_post_kses' );