2

I'm building my first plugin and it's very basic. I created my init class that is used for enqueue styles.. etc. It also has the register_activation_hook and register_deactivation_hook hooks but I don't know what to do with those!

My question is this.. Put yourself in my position, that you want to create a basic plugin that adds small features like related posts, maybe some small widgets... etc, and you don't want to do anything on activation/deactivation or uninstall.. Would you..

  • Remove those hooks?
  • Keep the hooks and leave the callback functions empty or return null...?
  • Do something else that any plugin should do when activate or deactivate or uninstall?

Thank you!

2

You don't have to use the register_activation_hook or register_deactivation_hook hook, they are optional. As their name suggests, they are hooks planned to run a task on plugin's activation/deactivation, such as updating the status of all users for some purpose.

So, if your plugin doesn't require such tasks, then simply don't use them. If you want to register new post types and taxonomies, you can use the init hook instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.