A starter template to build React-powered WordPress plugins.
-
MUI material
-
Tanstack/react query
-
@wordpress/api-fetch
-
Typescript
-
Production Build
-
REST API Integration
-
Clone the repository to /wp-content/plugins/:
git clone https://github.com/arukaraz/akz-wp-react-kit.git
Or download and upload the plugin files to /wp-content/plugins/akz-wp-react-kit.
-
Rename the folder name
akz-wp-react-kitto your plugin folder. -
Install dependencies
npm installYou must change the plugin folder and file names. Furthermore, adjust the constants, variables, classes, text domain, and functions inside the plugin to match your plugin’s name. For example, if your plugin is called my-cool-plugin, then:
Go to the .bin directory within the plugin folder and open the initial-rename.js file. Apply the following modifications:
your-amazing-plugin-nameyour_amazing_plugin_nameYOUR_AMAZING_PLUGIN_NAMEYOUR-AMAZING-PLUGIN-NAMEYour-Amazing-Plugin-NameYour_Amazing_Plugin_NameYourAmazingPluginName
With:
my-cool-pluginmy_cool_pluginMY_COOL_PLUGINMY-COOL-PLUGINMy-Cool-PluginMy_Cool_PluginMyCoolPlugin
Now Run npm run initial-rename
- Rename the folder from
your-amazing-plugin-nametomy-cool-plugin. - Rename all files from
your-amazing-plugin-nametomy-cool-plugin(PHP, JS, and CSS). - Change
your_amazing_plugin_nametomy_cool_plugin. - Change
your-amazing-plugin-nametomy-cool-plugin. - Change
Your_Amazing_Plugin_NametoMy_Cool_Plugin. - Change
YOUR_AMAZING_PLUGIN_NAMEtoMY_COOL_PLUGIN.
You can now safely enable the plugin. Turn it on from the Plugins section in the WordPress admin panel.
Navigate to the WordPress Dashboard => My Cool Plugin to see the default landing page and plugin settings.
Now that this is your own plugin, feel free to customize it using your preferred code editor and thoroughly test everything. You have the flexibility to add, edit, remove, or update any files, folders, or code within the plugin. However, it’s crucial to understand the changes you are making. Follow these steps to start development:
- Navigate to the plugin directory
/wp-content/plugins/my-cool-plugin, and open a terminal app. - Run the
npm run startcommand to initialize the React JS development server. This will automatically update the changes you made on the /src folder to the /build folder, where WP is taking the files from. - Run the
npm run deploycommand to create a ready-to-deploy folder. This folder contains all necessary files for deploying your plugin to a live WordPress site.
- GPLv2 or later