Torro Forms Plugin Boilerplate
This is a plugin boilerplate for a Torro Forms extension. It is highly encouraged to use this boilerplate when building any extension for Torro Forms.
To create your own plugin, download this repository. For the next steps, let's assume your plugin should be called
Torro Super Extension.
- Rename the directory to
- Rename the plugin main file to
gulpfile.jsand scroll to the bottom.
- Replace every value in the
replacementsobject with your new plugin name or plugin author data in the appropriate format. For example, replace
TORRO_SUPER_EXTENSIONand so on. Replace the plugin namespace vendor, plugin URL, author name, author email and author URL with your respective data.
- Save the changes.
npm installin the console.
gulp init-replacein the console.
gulpfile.jsagain and remove the entire bottom section that starts with
INITIAL SETUP TASK, save the file afterwards.
- Check the
package.jsonfiles. You might wanna update some details to your preferences.
- Check the top of
gulpfile.js, containing the
configobject. You might wanna update some details to your preferences.
gulp buildonce to compile everything.
Now you're good to go! One more thing: If you want to publish the plugin on wordpress.org, it's recommended to remove the
/languages directory, plus set the
false and remove the
pot task in
gulpfile.js. Then, remove the now unnecessary arguments from the
Extension::load_textdomain() method accordingly.
src/extension.php file to your needs. This is where your extension will get bootstrapped. You can instantiate the services your extension needs here, setup hooks (which will then be automatically invoked by the Torro Forms main plugin) and more.
All further classes and assets in the boilerplate is optional and simply sample code. Just bear in mind, you should stick to the directory structure used in the boilerplate - it is oriented after the Torro Forms base plugin.
Common Gulp Tasks
gulp sass: Compiles CSS/Sass
gulp pot: Refreshes POT file
gulp header-replace: Replaces the plugin header with latest data
gulp readme-replace: Replaces the header and description in the readme with latest data
gulp build: Runs all of the above tasks