Chapter 4. Integrating in WordPress

WHAT'S IN THIS CHAPTER?

  • Creating menus and submenus

  • Creating widgets and dashboard widgets

  • Defining meta boxes for content

  • Designing and styling your plugin

Integrating your plugin in WordPress is a critical step in building a professional plugin. WordPress features many different ways to integrate your plugin including adding top-level and submenu items, creating widgets and dashboard widgets, and adding meta boxes to your content screens.

In this chapter you learn how to properly integrate your plugin into the various areas of WordPress. You also learn the proper design and styles available that your plugins can take advantage of to provide your users with a consistent user-interface experience.

ADDING MENUS AND SUBMENUS

Many plugins you create need some type of menu item, which generally links to your plugin's settings page where the user can configure your plugin options. WordPress features two methods for adding a plugin menu: a top-level menu or a submenu item.

Creating a Top-Level Menu

The first menu method for your plugin to explore in WordPress is a new top-level menu, which is added to the admin dashboard menu list. For example, Settings is a top-level menu. A top-level menu is common practice for any plugin that needs multiple option pages. To register a top-level menu, you use the add_menu_page() function.

<?php add_menu_page( page_title, menu_title, capability, menu_slug, function,
        icon_url, position ); ?>

The add_menu_page() function accepts ...

Get Professional WordPress® Plugin Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.