When I am writing a new WordPress plugin, I find myself spending several hours repeating the same basic structure to begin each project. Instead of continuing that tradition, I decided to commit a generic skeleton of the code and structure.
This will give you a very basic WordPress plugin that provides a custom post type and an admin form with a couple of inputs. It also performs basic loading of Javascript and CSS and other normal WordPress plugin bootstrap functions.
- Copy the source
foundation
folder into yourwp-content/plugins
directory - Rename the
foundation
folder to a name of your choice, appropriate to your plugin. - Open
foundation.php
and change the plugin information that appears in the comment at the top to something appropriate for your new plugin (don't change the uncommented code yet - that will come in a bit) - Rename the 6 source code files in a manner appropriate to your plugin. For example, if your plugin is called
Apple
:foundation.php
becomesapple.php
classes/Foundation.php
becomesclasses/Apple.php
classes/FoundationHelper.php
becomesclasses/AppleHelper.php
classes/FoundationViews.php
becomesclasses/AppleViews.php
css/foundation-admin.css
becomescss/apple-admin.css
js/foundation.js
becomesjs/apple.js
- Do a few case sensitive search and replaces against the source code files. Again, using
Apple
as an example:- Replace
Foundation
withApple
- Replace
foundation
withapple
- Replace
FOUNDATION
withAPPLE
- Replace
- (optional) Open
classes/Foundation.php
(or whatever you renamed that file) and modifyregisterPostTypes()
so that the labels and description make sense for your new plugin.
That's it.
This may not be useful to anyone but me. Regardless, it is available under the GNU LGPL v3, a copy of which is contained in the LICENSE file.