How to change the custom section title using WooThemes Homepage Control

After finally releasing a beta version of Palette—a child theme for Canvas by WooThemes—I’ve decided to completely rewrite the code base and covert its multiple functionalities into more modular plugins that will allow the user to choose what functionality they need a la cart.

I’m pretty excited about this new plugin, and development is coming along well. I’m taking the opportunity to integrate the functionality from Homepage Control by WooThemes, which will allow drag and drop functionality of homepage elements.

Pretty sweet if you ask me.

As I was developing, however, I realized that my custom functions hooked into the Homepage Control “homepage” action hook did show up all beautiful like the stock WooThemes functions do.

The problem is that the Homepage Control plugin looks for the name of each function that’s hooked to the “homepage” action hook, and simply reformats the name of the function to look like a title. For WooThemes modules, the plugin removes the “woo_display_” prefix and just formats the actual title of the function.

It doesn’t do this for custom homepage sections, however, so we have to tell it which prefix to remove. Luckily, the WooNinjas thought of that, and included a filter for me to make my section titles all pretty.

Here’s how to do so yourself:

add_filter( 'hompage_control_prefix', 'palette_change_prefix_value');
/**
 * Change the function prefix to remove when formatting custom 
 * function titles.
 *
 * Calls a template file to display recent products in WooCommerce.
 *
 * @since  	1.0.0
 * @return 	new function value
 * @uses  	filter
 * @link 	http://pancakecreative.com/
 * @author 	Pancake Creative
 */
function palette_change_prefix_value() {
	return 'palette_display_';
}

Just paste this guy into your functions.php file (or include it in your plugin) and you’re all set. Be sure to change the “palette_display_” prefix to your custom prefix or it won’t work correctly.

Beautiful custom module names at the drop of a hat!