Call this functions in your My_Plugin folder/index.php file.
register_installation_hook("My_Plugin", function ($item_purchase_code) {//validate purchase code if you wishif (!validate_purchase_code($item_purchase_code)) {echo json_encode(array("success" => false, 'message' => "Invalid purchase code"));exit();}//run necessary sql queries$db = db_connect('default');$db_prefix = get_db_prefix();$db->query("SET sql_mode = ''");$db->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "plugin_table` (`id` int(11) NOT NULL AUTO_INCREMENT,`title` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,`deleted` tinyint(1) NOT NULL DEFAULT '0',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;");});
register_uninstallation_hook("My_Plugin", function () {//run something});
register_activation_hook("My_Plugin", function () {//run something});
register_deactivation_hook("My_Plugin", function () {//run something});
register_update_hook("My_Plugin", function () {//show necessary information to update this plugin in the modal});
register_data_insert_hook(function ($data) {//some data has been inserted/*the $data array has 3 itemsid => inserted idtable => associated table with db prefixtable_without_prefix => associated table without db prefixdata => inserted data array*/});
register_data_update_hook(function ($data) {//some data has been updated/*the $data array has 3 itemsid => updated idtable => associated table with db prefixtable_without_prefix => associated table without db prefix*/});
register_data_delete_hook(function ($data) {//some data has been deleted/*the $data array has 2 itemsid => deleted idtable => associated table with db prefixtable_without_prefix => associated table without db prefix*/});