-
-
Notifications
You must be signed in to change notification settings - Fork 6
Home
Dev Kabir edited this page Jul 12, 2023
·
4 revisions
This is a simple boilerplate for creating WordPress plugins.
-
Set up the project
Navigate to the plugins directory in your local WordPress installation and run the following command:
composer create-project devkabir/wordpress-plugin <your-plugin-name>
If you want to use the master branch for your project, run this command instead:
composer create-project devkabir/wordpress-plugin:dev-master <your-plugin-name>
Note: The master branch is still under development and may contain bugs.
-
Begin coding
To start coding, run this command:
code <your-plugin-name>
The project is structured as follows:
├───assets # For Frontend Developers
│ ├───admin # Admin template
│ │ └───src
│ │ ├───components # Smaller chunks of admin template.
│ │ │ └───data
│ │ ├───composable # Composition APIs for admin template.
│ │ └───pages # Pages of admin template.
│ └───website # Shortcodes and widgets for frontend
│ └───shortcodes # All shortcodes are located here.
│ ├───form # HTML and JS files for `form` shortcode
│ └───scss # SCSS styles for shortcodes
├───languages # i18n template for this plugin.
└───src # For Backend Developers
├───Admin # Code for admin-facing features, such as adding pages to the sidebar.
├───Ajax # All AJAX actions are located here. AJAX is used for handling frontend requests.
├───Api # All API handlers are located here. APIs are used for the admin template.
├───Helpers # Shared functions are located here as static methods of a namespace to avoid conflicts.
├───Traits # Reusable functions are located here in the form of traits.
└───Web # Code for frontend-facing features, such as loading shortcodes and widgets.
-
build.sh
- Creates a .zip file to test this plugin. -
composer.json
- Handles all PHP dependencies. -
deploy.sh
- Deploys the production build to github.com. -
plugin.php
- The main file for the plugin. -
post-install.php
- After creating the project, this file automatically replaces all dummy strings. -
readme.md
- Plugin details for the GitHub development repository. -
readme.txt
- Plugin details for wordpress.org.