How can you create an empty plugin which have basic options like activate, deactivate etc.?
Answer Posted / Yogesh Rani
To create an empty plugin in WordPress, first navigate to your wp-content/plugins directory and create a new folder with the desired name (e.g., my-plugin). Inside this folder, create two files: my-plugin.php and my-plugin.php-dist. The active plugin PHP file (my-plugin.php) should be empty for now. Next, add the following code to the bottom of your wp-config.php file to register the new plugin:nn```phpndefine('MY_PLUGIN', trailingslashit(WP_CONTENT_DIR) . 'plugins/my-plugin');nrequire_once MY_PLUGIN . 'my-plugin.php';```nnAfter registering the plugin, create a skeleton structure in my-plugin.php for basic activation and deactivation functions:nn```phpn<?phpnn/*nPlugin Name: My PluginnDescription: An empty WordPress plugin.nVersion: 1.0nAuthor: Your Namen*/nn// Activate Functionnregister_activation_hook(__FILE__, 'my_plugin_activate');nfunction my_plugin_activate() {n}nn// Deactivate Functionnregister_deactivation_hook(__FILE__, 'my_plugin_deactivate');nfunction my_plugin_deactivate() {n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers