Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #################### update function ############################
- function sb_update_plugin(){ //runs when all plugins are loaded (needs to be deleted after register_update_hook is avaiable)
- global $wpdb, $sb_ip_log;
- if(sb_get_plugin_version() != get_option('sb_plugin_version') OR get_option('sb_plugin_version') == FALSE){
- add_action('admin_notices', 'sb_activation_notice'); //show activation message
- sb_create_db_table(); //update the plugin table to a desired structure
- #### now comes everything what must be changed in the new version
- if(get_option('sb_plugin_version') == '1.3'){ //upgrade to v1.4:
- add_option('sb_automatic_ip_address_duplication', '0', '', 'yes');
- add_option('sb_automatic_ip_address_duplication_recurrence', 'twicedaily', '', 'yes');
- add_option('sb_spam_comment_automatic_elimination', '1', '', 'yes');
- add_option('sb_automatic_ip_address_duplication_last_cron_run_time', '', '', 'yes');
- //renaming options and values -- v1.5 - zpetna kompatibilita
- add_option('sb_access_restrictions', '1', '', 'yes'); //adding new option
- delete_option('sb_detection_of_spammers_cookies');
- add_option('sb_detection_of_spammers_method', '1', '', 'yes');
- delete_option('sb_detection_of_spammers_time');
- add_option('sb_detection_of_spammers_time', '2592000', '', 'yes');
- }
- if(get_option('sb_plugin_version') == '1.4'){ //upgrade to v1.5
- add_option('sb_access_restrictions', '1', '', 'yes'); //adding new option
- //renaming options and values
- delete_option('sb_detection_of_spammers_cookies');
- add_option('sb_detection_of_spammers_method', '1', '', 'yes');
- delete_option('sb_detection_of_spammers_time');
- add_option('sb_detection_of_spammers_time', '2592000', '', 'yes');
- //add new column hits to sb_ip_log table
- $wpdb->query("ALTER TABLE $sb_ip_log ADD hits INT;");
- //add 1 to all rows
- $wpdb->query("UPDATE $sb_ip_log SET hits = '1';");
- }
- #### -/changes
- update_option('sb_plugin_version', sb_get_plugin_version(), '', 'yes'); //update plugin version in DB
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment