Call this functions in your My_Plugin folder/index.php file.
- Register installation hook. When the plugin is about to install, this function will be triggered. Execute required sql queries or purchase code validation here.
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. When the plugin is about to uninstall, this function will be triggered.
register_uninstallation_hook("My_Plugin", function () {//run something});
- Register activation hook. When the plugin is about to activate, this function will be triggered.
register_activation_hook("My_Plugin", function () {//run something});
- Register deactivation hook. When the plugin is about to deactivate, this function will be triggered.
register_deactivation_hook("My_Plugin", function () {//run something});
- Register update hook. Provide information to update your plugin. Please note that, if your updates has any version comparability, check that while updating.
register_update_hook("My_Plugin", function () {//show necessary information to update this plugin in the modal});
- Register data insert hook.
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.
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.
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*/});