Category Archives: WordPress

How to customise Jetpack’s Infinite Scroll footer – the proper way

Browsing the interwebs for info on how to change the footer that comes with the Infinite Scroll module in Jetpack I found, to my horror, several how-to’s that all involved hacking core plugin files. This is, obviously, not right. You’ll be modifying Jetpack files after each update (and these seem to be quite regular) untill the end of days… So here is the right way™ of doing it. Continue reading

WordPress 3.7 “Basie”

The Status 301 Network has just been upgraded successfully to the latest stable WordPress release: 3.7.1 “Basie”. Moreover, the admin theme MP6 has been added in preparation of the expected 3.8 release in December, providing a cleaner admin interface.

mp6 dashboard

Read more about new features in WordPress 3.7 “Basie” on the WordPress News blog.

Remove buttons from the WordPress Rich Text Editor toolbar

A simple task for someone up to his shoulders in WordPress code on a weekly basis, one would guess. And as the WordPress codex suggests, there is an easy filter available where you can use unset to remove the undesired buttons by name from an array.

The arrays for the different (advanced) toolbars can be found in class-wp-editor.php (just hit Ctrl+F and enter “mce_buttons_”) about half way down the page. In the following example, I try to remove buttons from the advanced toolbar which are defined by default as

array( 'formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' )

The WordPress Codex page on MCE Toolbar filters gave me (NOTE: It won’t anymore, I updated the codex page) this example:

function myplugin_tinymce_buttons($buttons) {
      //Remove the text color selector
      unset($buttons['forecolor']);

      return $buttons;
}
add_filter('mce_buttons_2','myplugin_tinymce_buttons')

But no. This simple example does not cut it. It simply had NO effect 🙁

After a long hard search, I found that unset() needs to reference an array value by its key while in the example the value ‘forecolor’ is used. So unset($buttons[‘forecolor’]) does not do anything while unset($buttons[3]) (3 is the key for the 4th value in the default array) would work fine. But it’s no fun like that and if the order of buttons would ever change, this solution would remove another button.

This example, using array_search() to get the appropriate key would solve that issue:

function myplugin_tinymce_buttons($buttons) {
	//Remove the text color selector
	if ( ( $key = array_search('forecolor',$buttons) ) !== false )
		unset($buttons[$key]);

	return $buttons;
}
add_filter('mce_buttons_2','myplugin_tinymce_buttons');

But here is a simpler example that will work, while also allowing other buttons to be removed at the same time. Just add their name — see the default array above — to the $remove array.

function myplugin_tinymce_buttons($buttons) {
	//Remove the format dropdown select and text color selector
	$remove = array('formatselect','forecolor');

	return array_diff($buttons,$remove);;
}
add_filter('mce_buttons_2','myplugin_tinymce_buttons');

By the way, if you need to add a new button or element, use for example array_unshift($buttons,’styleselect’); to place it at the start of the toolbar or array_push($buttons,’styleselect’); to place it at the end. In both cases, the second argument can also be an array to append multiple elements at the same time.

Have fun!

Goodbye Blogroll, Hello Link Manager

After the upgrade to WordPress 3.5, and having gone all Oh! and Ah! over the new (but expected) media interface, I continued with a client site I had started before the upgrade. And coincidence or not, this client was the first one that had ever asked for a blogroll on his site! Real surprise to find that Blogroll (Links) has gone. I had not even noticed the discussion about it and was unaware of the fact that it had finally been decided to loose it. Or at least to not show it by default for new sites.

I cannot say I’ll miss it much as it can be easily replaced by a custom menu or even a text widget. Or, as most clients seem to want, a separate page. But this time, the client wanted to have his trusted Blogroll! Luckily, the Blogroll is not really gone, it’s just not visible for new sites.

Here’s how you can make it appear again:

add_filter( 'pre_option_link_manager_enabled', '__return_true' );

This code could go into a themes.php or in a plugin. And luckily, there is Andrew Nacin who was so kind as to create a plugin all ready to go: Link Manager. Lightweight, no options, easy. I like it! Thanks Andrew 🙂