CHAPTER 7 • Making the Most of WordPress Plugins 189
array(
'labels' => array(
'name' => 'Smashing Post Type',
'menu_name' => 'Smashing Posts'
),
'singular_label' => 'Smashing Post Type',
'public' => true,
'show_ui' => true,
'menu_position' => 5,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'show_in_menu' => true,
'supports' => array( 'title', 'editor', 'author', 'revisions',
'comments' )
)
);
}
?>
MUST-HAVE FUNCTIONALITY FOR PLUGINS
Strictly speaking, the only thing your plugin really must have is a main PHP file containing
the identifying header and whatever code is needed to get the job done. However, in reality,
you should probably take it a few steps further than that. After all, someone other than you
may have to work with your plugin, so it should be as simple and accessible as possible. This
means that you should go to great lengths to make the plugin blend in nicely with the
WordPress admin interface.
The same goes for whatever parts of the plugin will show to end users. Some plugins add
visual functionality, and that should work with as many themes as possible if you intend to
release the plugin. Naturally, if you’ve developed a plugin for use with a particular project
only, this won’t be an issue. The same goes for localization support; there’s no need for that if
there won’t be any language support other than the default one, is there?
Finally, I think every plugin should come with a license and some sort of instructions as to
how the plugin should be used. Readme files are nice and all, but it’s better still to build the
instructions into the actual plugin because a lot of users are reluctant (or just too impatient)
to read the attached readme files. You can also extend the Help tab in WordPress using
add_help_tab(), which you can read more about at http://codex.wordpress.
org/Function_Reference/add_help_tab.
PLUGIN SETTINGS
Sometimes you want to save things in the database. You’ve got the freedom of any PHP script
here really, which means that you can add full tables and so on to the database should you
want to. I won’t cover that.