Shiba

Adventures in WordPress

  • — Home —
  • Dog
  • Art
  • Contact
  • WordPress Articles
    • WP Plugins
    • WP Programming
    • WP Admin Panels
    • WP Theme Design
    • WP How-To
    • WP Theme Images
You are here: Home / WordPress Plugin / WordPress Example Plugin

WordPress Example Plugin

Tweet

by ShibaShake 10 Comments

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.

How to Get Shiba Example Plugin.

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.

How to Get Shiba Example Plugin.

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

WordPress Plugin Credits

The issue of how to credit plugin developers can often be an emotionally charged topic, with strong opinions on both sides. Everybody agrees that plugin developers are awesome for the WordPress community, but many disagreements arise as to what are the proper methods for getting credit for their hard work. On the one hand, many plugin developers feel they should at least get a back-link for all of their time and effort, but many blog users do not want to clutter up their blog with multiple plugin [...]

WordPress Link Validator Plugin

This plugin searches for links in your WordPress posts and pages (regular links or image links), then validates them for you. It can process local links, relative links, and external links. [Most recent WordPress Link Validator updates] December, 2015 Tested on WordPress 4.4. No changes needed. August, 2015 Tested on WordPress 4.3. No changes needed. September 14th, 2014 - Release 1.6.2 Updated for WordPress 4.0. Updated nonce creation function for the background link validator [...]

Comments

  1. Deepak says

    October 30, 2015 at 10:58 am

    I was looking for this type of plugin from long time, finally i got it, thanks SHIBA

    Reply
  2. Nils says

    August 5, 2014 at 2:20 pm

    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?

    Regards
    Nils

    Reply
    • ShibaShake says

      August 6, 2014 at 8:15 am

      Do you mean a regular blog page or an admin page? What kind of modifications?

      Reply
  3. Jonay Pelluz says

    May 13, 2013 at 4:17 am

    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!

    Reply
  4. Michail Dimitriou says

    March 4, 2013 at 4:43 am

    Thanks for the example. I started to learn about wordpress. Really useful

    Reply
  5. Razib says

    August 3, 2012 at 2:56 am

    Thanks for sharing this sample plugin. Really very helpful.

    Reply
  6. krembo99 says

    April 17, 2012 at 3:26 am

    Absolutly great . And I agree that a simple working example of an options page would make it perfect ! thanks for this great plugin !

    Reply
  7. Bonco says

    October 31, 2011 at 5:29 am

    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.

    Reply
    • ShibaShake says

      November 8, 2011 at 11:13 am

      Thanks Bonco. That is a very good suggestion.

      I have put it on my to-do list and will add it on the next iteration of the plugin.

      Reply
  8. Croatia Istria says

    August 23, 2011 at 12:24 pm

    Thanks for this wordpress example plugin!

    Reply

Leave a Reply Cancel reply

Your email address will not be published.

Recent Posts

  • Screen-shot of mobile responsive Poll Daddy object, where text floats properly to the right of radio buttons.How to Make Poll Daddy Objects Mobile Responsive
  • Screen-shot of blog post with no page border (flowing design).Genesis Skins 1.5
  • Screen-shot of the media manager Create-Gallery screen, while doing a post search.Shiba Media Library 3.7
  • Screenshot of the Edit Gallery screen after we hit the Create Gallery button.How to Expand the WordPress Media Manager Interface
  • Blonde girl looking through and holding a circular picture frame.Shiba Gallery 4.3
  • Close-up of beautiful blonde holding a square picture frame.Google Authorship - Good or Bad for Search Traffic?
  • Shiba Widgets 2.0
  • Media Temple screenshot of editing my sub-domain DNS entry.Using CDN Cnames with w3tc and MultiSite
  • Shiba Skins WordPress ThemeShiba Skins WordPress Theme
  • How to add the Media Manager Menu to the Theme Preview InterfaceHow to Add the Media Manager Menu to the Theme Preview Interface

Recent Comments

  • WordPress Search Widget – How to Style It (56)
    • Nelson
      - Tanks master - Fine
    • TelFiRE
      - How do you style the "X" that shows up when you start typing?
  • Update custom inputs with the proper data using Javascript.Expand the WordPress Quick Edit Menu (58)
    • Mike G
      - This is exactly what is happening to me. It is updating the value in the database and in the column, but I have to refresh ...
    • PhoenixJP
      - Thanks for this tutorial. Does someone knows if this still work with wordpress 5.03 and 5.1.
    • Francine Carrel
      - This is a very long time away from your original comment, but did you ever work it out? I am stuck on the exact same thing ...
  • Custom meta-box with a set of radio-buttons.Add a Metabox to Your Custom Post Type Screen (27)
    • mike
      - Hi Shiba am a newbie to wordpress, I just installed a plugin with a custom post type, but has no option for discussion and ...
  • Write a Plugin for WordPress Multi-Site (45)
    • Andrew
      - Hi,action 'wpmu_new_blog' has been deprecated. Use ‘wp_insert_site’ instead.
  • Populate our Edit Gallery menu using a gallery shortcode.How to Add the WordPress 3.5 Media Manager Interface – Part 2 (29)
    • Janine
      - Still relevant in 2019.
  • WordPress Excerpt – How to Style It (36)
    • James
      - Great post. I really need some help. I have set border lines around my excerpts on my blog page/post page. The problem is ...
  • Add Custom Taxonomy Tags to Your WordPress Permalinks (123)
    • Darshan Saroya
      - Update permalinks. Go to settings > permalink and just save it.

Copyright © 2021 · Genesis Skins by ShibaShake · Terms of Service · Privacy Policy ·