WordPress Custom Plugin Installable code

I have created my own custom plugin and when i just paste it in my plugin folder its working fine. now i wanted to make it installable so if anyone try to install in their project so they can install it with the given plugin upload menu in admin panel.

Related posts

Leave a Reply

2 comments

  1. Its very simple process to make your plugin installable. Just register 3 hooks in your plugin :

    register_activation_hook(__FILE__, 'your_activation_function_name');
    register_deactivation_hook(__FILE__, 'your_deactivate_function_name');
    register_uninstall_hook(__FILE__, 'your_delete_function_name');
    

    In your_delete_function_name function, please add code to remove the db changes you made and also code to remove your plugin directory.

    Now just zip the folder of your custom plugin folder and its ready to be installed in any wordpress site. It worked for me as i am working in wordpress 4.6.