WordPress Example Plugin

The Shiba Example Plugin is an empty plugin to help you get started on writing a WordPress plugin.

The Shiba Example Plugin contains

  • Activation and deactivation hooks that run in both single and multisite configurations.
  • An example plugin sub-menu page.
  • Example settings within the sub-menu page that is based on the WordPress Settings API.
  • An uninstall.php file that runs when your plugin is uninstalled. Use this to clear out options (delete_option) or databases created by your plugin.
  • Example localization or language translation hooks. This enables others to easily add language translation capabilities to your plugin.
  • A plugin class wrapper which wraps around your plugin functions so that there will not be any function name conflicts with other plugins or themes in the user’s environment.

[Most recent WordPress Example Plugin updates]

December, 2015
Tested on WordPress 4.4. No changes needed.

August, 2015
Tested on WordPress 4.3. No changes needed.

April 17th, 2014 – Release 1.6

  • Changed plugin url and directory paths to use the plugins_url() and plugin_dir_path() functions instead of the corresponding WordPress constants.
  • Tested on WordPress 3.9.

Adding a Plugin Menu Page

There is a section in the shiba-ex-options.php file that adds a menu page to your WordPress Dashboard Settings menu.

// Add a new submenu
$this->page = $page =  add_options_page(	
	__('Shiba Example', 'shiba_example'), __('Shiba Example', 'shiba_example'), 
	'administrator', 'shiba_example', array($this,'shiba_ex_page') );

The function call add_options_page, adds the sub-menu called ‘Shiba Example’ to the Settings tab. Visiting the sub-menu will run the function add_shiba_example_page. If you want to add your plugin menu to a different WordPress tab, below are the other available options –

  • add_management_page – Adds a menu to the Tools tab. [tools.php]
  • add_options_page – Adds a menu to the Settings tab. [options-general.php]
  • add_theme_page – Adds a menu to the Appearance tab. [themes.php]
  • add_plugins_page – Adds a menu to the Plugins tab. [plugins.php]
  • add_users_page – Adds a menu to the Users tab. [users.php or profile.php]
  • add_dashboard_page – Adds a menu to the Dashboard tab (topmost). [index.php]
  • add_posts_page – Adds a menu to the Posts tab. [edit.php]
  • add_media_page – Adds a menu to the Media tab. [upload.php]
  • add_links_page – Adds a menu to the Links tab. [link-manager.php]
  • add_pages_page – Adds a menu to the Pages tab. [edit.php?post_type=page]
  • add_comments_page – Adds a menu to the Comments tab. [edit-comments.php]

Note – All of these functions call the add_submenu_page function.

You can also create your own top-level menu by following these steps from the WordPress Codex.

Adding Localization or Language Translation Capabilities

One of the best tutorials I have come across on localizing your plugin can be found on Urban Giraffe.

Here is the official tutorial from the WordPress Codex.

Future Additions

Please let me know if there are common plugin functions that I have missed, or if there are better ways to achieve some of the plugin functions described above.

WordPress Example Plugin Updates

Shiba Example 1.5

Aug 3rd, 2013

  • Tested on WordPress 3.6.
  • Upgraded example settings page to use metaboxes. This produces a more polished plugin interface.
  • Added more descriptive comments to the plugin.
  • Integrate settings page render and settings setup into a single object. This makes for a cleaner and more structured plugin.

Shiba Example 1.4

Jan 11th, 2013

  • Encapsulate settings page within a class wrapper.
  • Use a common network_propagate function for activate and deactivate.

Shiba Example 1.3

Sept 12th, 2012

  • Now using the WordPress Settings API to save plugin options.

Shiba Example 1.2

Aug 3rd, 2012

  • Updated for WordPress 3.4
  • Added example input options in plugin page.

Shiba Example 1.1

Jan 11th, 2011

  • Added add page variable.
  • Added activation and deactivation hooks.
  • Added class check.
  • Expanded for multi-site.

Related Articles


  1. Nils says

    Thank you for this example. It is very useful. Since I’m just starting with WordPress I’m not very familiar with all these options. More information on each part might be usefull.

    Is there an example how to modify the content of a page using the plugin?


  2. says

    Great!, It worked really well, I reduced the code because I was looking for something more simple and I think it would be great to have more comments on the code explaining the individual parts, but overall I like it. Thanks!

  3. says

    Thx for your example plugin and indeed I miss something. It would be nice to have a example form to save some simple vars for a plugin. Just to get started and understand how the workflow is. This is what I miss. But anyway your work abolutely saves me hours to get started.

Leave a Reply

Your email address will not be published.