Download Template Plugin Code

 

This page provides a form to download template code for writing a WordPress plugin. However, you don’t need any of this to write a WordPress plugin. Especially a simple one. You can get along OK by following the standard directions on how to create a plugin.

So why bother? If you write a more complex plugin, or several plugins, you have to figure out how to manage things like actions that should only happen on the first install, actions to take when upgrading from version X to version Y, and creating some boiler plate code related to creating an administrative options page, short codes and more. You also want to exercise best practices. See more on the Design Tenets page.

This template code and supporting documentation is my cut at template code that provides a code pattern for managing complexity, boiler plate code, convenience functions, and best practices for being a “good plugin citizen.”

Generate code for your plugin and see the Getting Started page.

NOTE: this template does NOT include support for WordPress Multisite.

(Example: "My Cool Plugin")
(Max 150 characters)
GPL-3, BSD
(Put just a name or an HTML A tag with link to your site)
(Directory name under wp-content/plugins/)
(label for i18n)
(like "PREFIX_Plugin.php")
Download

 

  40 Responses to “Download Template Plugin Code”

  1. Dude, yes! This is awesome. Great documentation as well. Thank you! Donation – done!

  2. SO SICK. Much needed and even more appreciated! Thanks 😀

  3. This is amazing. Thank you!

  4. Great stuff man!!!! Thanks! You saved me a ton of time.

  5. Takes a lot to get bookmarked by me…YOU DA MAN!

  6. WOW! This is great – thank you so much 🙂

  7. Lol, I have no idea what I’m going to do if this page ever goes away… this is incredibly useful.

  8. Exactly info I needed for my web following project. Thanks.

  9. You should throw some adsense on this page. Great tool!

  10. Thanks, very handy! Any chance of an announce list to be notified when you add new features?

    If interested in suggestions, I’d find a few more input field types on settings pages useful. And in the generate form, maybe put a checkbox to include some commonly used snippets like defining a post type and custom taxonomy.

  11. Simple awesome. Glad to pay $10 for this. Thank you so much!

  12. Thanks for taking the time to do this, it’s bloody useful

  13. This is AWESOME. Thank you so much for the time you put into this. It works great!

  14. Why should anyone *have* to donate $10 to you for a license that is FREE, freely available and free for anyone to use. The BSD license is even more permissive than the ‘share-alike’ / ‘viral’ GNU GPL license so how on earth can you justify charging people for a license which is FREE is the most truest of sense?!

    I can understand getting paid for your hard work in coding this template etc. but then charge FOR THAT not for a license that anyone can use FOR FREE and can easily and readily gain a copy of the license’s text from a quick Google search!

    Furthermore I think you will find that WordPress is ITSELF distributed under the GNU GPL license and therefor ANY “derivative” works are REQUIRED to have the SAME license (or a compatible one, which typically means a more recent version of the same GPL license!) — in that respect I think that it is highly probable that (Strictly speaking) it would be ILLEGAL for anyone to distribute a plugin or theme for WordPress if it uses anything other than a GPL license!

    Don’t get me wrong, I REALLY appreciate what you’ve done and are trying to do with this plugin template / boiler plate but just don’t mislead people about what you’re REALLY charging them for and certainly don’t lead them ‘astray’ by offering a license which (AFAIK) is incompatible with the standard WordPress license…

    To quote from: http://wordpress.org/about/license/

    “…we feel strongly that plugins and themes are derivative work and thus inherit the GPL license. If you disagree, you might want to consider a non-GPL platform such as Serendipity (BSD license) or Habari (Apache license) instead.”

    Another useful link: http://codex.wordpress.org/License

    PLEASE STOP encouraging (and even CHARGING) people to BREAK THE LAW!!

    Kindest regards,

    Cheapskate McNobelson

    • You have this all wrong. I am charging for my software which is my intellectually property. I have the right to license you software that I wrote under the terms of any license I choose. If you would like to license it from me under the more restrictive terms of GPL (i.e. you won’t make money off it) then I will not charge you anything. If you would like to license it from me under terms of BSD (i.e. you can make money off it), then I charge $10 for that.

      Regarding the WP GPL license, note that my code, although intended to run on WordPress, does not include any WordPress code and therefore is not a derivative work nor does it infringe on its copyright. All the code is written my me and is my intellectual property. The fact that it only works with WordPress does not tie it to the WP GPL license.

      This is 100% legal and proper. Ask an intellectual property lawyer.

      • You are wrong, Open Source rules, which apply to GPL, make it unlawful to restrict what someone does with the code. It is actually unlawful to prevent commercial use of any FOSS code under either GPL OR BSD. What you cannot do under GPL is republish GPL-based code under a non-GPL license, but the same is not true of BSD. Has NOTHING to do with monetary exchanges.

        See Section 6: http://opensource.org/osd

        Example: It is perfectly legal for me to sell a modified Linux Kernel. It is illegal for me to relicense the Linux Kernel I modified as non-GPL.

        • Yes, I think you are right about not restricting commercial use and that monetary exchanges are not the point.

          I’ve been thinking about this issue some more in light of the recent Oracle vs. Google (overturned) decision in the Circuit Court. In that situation Oracle owns & licenses the Java programming language and its APIs. Google copied the APIs and made its own implementation of Java to work with Android phone. The lower court sided with Google but the Circuit Court overturned that and sided with Oracle.

          The plugin scenario is a bit different. I’m not taking WP APIs and writing my own variation of WP, I’m just calling existing APIs (which is not verbatim copying the API declaration. Remember: copyright cover the *expression* of an idea. Calling an API is a different expression than declaring it).

          But I’m not 100% sure now if some protection extends to calling “register_activation_hook” for example as an implication of this decision. I think the Circuit Court is referring this kind of question back to lower courts (if I understand correctly)

          Fortunately the WP people have chosen not to copyright their APIs, so the plugin should be in the clear to have its own copyright/license: “Automattic Doesn’t Claim Copyright On Their APIs”
          http://wptavern.com/automattic-doesnt-claim-copyright-on-their-apis

  15. Best template plugin for WordPress ever!

    You were third (in the UK) for a search of WordPress Template Plugin, which is also pretty good.

    Many many thanks! Once my new plugin is working, I will come back and donate!

  16. You say,

    “NOTE: this template does NOT include support for WordPress Multisite.”

    I have developed a plugin using this excellent template. I would like the plugin to multi-site compatible. How would you suggest that I proceed?

  17. Thank you Michael,

    I have done a little reading

    * “Professional WordPress” by Brad Williams et. al.
    * http://shibashake.com/wordpress-theme/write-a-plugin-for-wordpress-multi-site
    * http://www.wphub.com/tutorials/plugins-compatible-wordpress-multisite/
    * http://www.onextrapixel.com/2013/01/08/how-to-properly-code-your-plugin-for-a-wordpress-multisite/

    These are my early thoughts and will contain errors and omissions,

    Multisite (hereafter “Network”) changes some things relevant to your template

    * Plugins may be activated once for all present and _future_ blogs (Network activation) or activated for individual blogs

    * Plugin data can be stored in tables at the Network level or in tables as individual blogs

    * Network support additional features including
    ** superusers who manage a Network
    ** Network options
    *** Plugin authors must decide what are plugin options that are typically available two blog administrators in a back end administrator menu and what are network options that are only available to supers users in the network administrator menu.

    * Plugin code is called in the context of a blog with a $blog_id. This is important for reading and persisting data. For example, post data would be recalled from the current blog.

    The implications for your template can be viewed through the lens of the files

    * my-cool-plugin.php
    ** Comments to indicate that the author may set “Network: true” if the plugin is multisite compatible

    * MyCoolPlugin_Plugin.php
    ** Must optionally check for deployment within a Network and have a different behaviour

    * MyCoolPlugin_LifeCycle.php
    ** Lots of changes, needs to support Network Activation and/or activation of a single site within a Network

    * MyCoolPlugin_OptionsManager.php
    ** Must support Network Options

    At the moment it is true to say

    * “this template does not support multisite plugins”

    because there is not template code to support operation in a network.

    I am not sure it is true to say

    “this template is not multisite compatible”

    The later sentence implies that a plugin written using this template _must_ break. I think that this is not true. I have tested “Network activation” of plugin in a multisite network and it fails gracefully. That is to say that it simply returns with no message. When the plugin is activated on the site it works fine.

    If upon review and further testing you agree with my conclusion you may wish to change your communication to,

    “Multisite Compatibility
    A multisite network offers several capabilities to a plugin author such as network activation, network data storage and network options, that are not supported by this template. However a plugin written using this template should work correctly when activated within an individual site on the network.”

  18. Amazing tool, thanks

  19. Any update for supporting providers? I mean – wp_oembed_add_provider() ?

  20. msimpson – this site went down for a bit yesterday and I utterly panicked. I use this on a weekly basis, and it has become a huge part of my creation process.

    Do you have any plans to take this down at any point? Is this tool in version control, and would you consider making it open source?

    • I don’t plan to take it down. Every once in a while the hosting provider seems to have a problem. I should dump this on GitHub at some point.

  21. Great tool, need to use the wordpress css style the wrap or wrapper to make it look better.
    in my plugins i’m alway add a setting link in the WordPress plugins page
    Deactivate | Edit | Settings

  22. how can i create link to myu create plugin in wordpress?

  23. You code is a delight to read. So well done!

  24. Wonderful plugin generator! Strikes a good balance between functionality and cleanliness. Thanks a lot!

  25. Thank you … That’s all I can do at the moment!

  26. Github repo gone?

  27. faith in humanity… RESTORED!

    Thanks a lot man!

  28. Donated! Thanks a bunch for helping me get started with plugin development. 🙂

  29. Thanks for your amazing service, it’s really helpful for every developer. thaks again

  30. in the main php file plugin-name.php, on line 77 there is an add_action. The action name is plugins_loadedi, shouldn’t that be plugins_loaded??

  31. This is amazing, thanks so much – saved me a LOT of time.
    One question that’s driving me mad….

    I’m trying to populate the drop-down select options using a WP_Query.
    I have an array of IDs from the query and have tried to implode this array so that the string matches the format of your example options but the whole string shows as a single option instead of a new option for each comma in the string.

    Hope that makes sense! Any idea how I can get this to work?!
    Thanks!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>