How can you create an empty plugin which have basic options like activate, deactivate etc.?



How can you create an empty plugin which have basic options like activate, deactivate etc.?..

Answer / 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

More WordPress Interview Questions

How do I convert wordpress to html?

1 Answers  


Where are wordpress themes stored?

1 Answers  


What are minimum requirements to run WordPress?

1 Answers  


Can you downgrade wordpress version?

1 Answers  


How do I publish a wordpress update?

1 Answers  


What's the difference between categories and tags in wordpress?

1 Answers  


What is primary navigation?

1 Answers  


How do I hide my wordpress site from search engines?

1 Answers  


Tell me should I use print “$a dollars” or “{$a} dollars” command to print out the value of dollars in this case?

1 Answers  


Who is founder of WordPress?

1 Answers  


Explain me what is file structure in wordpress?

1 Answers  


Do I have to pay wordpress to use my own domain?

1 Answers  


Categories