function MCW_plugin_init() { if (!function_exists('register_widget')) { return; } /******************************/ /*** deinstallation routine ***/ /******************************/ function MCW_deinstall() { global $mcw_prefix; global $mcw_widgetsoption; global $mcw_configoption; global $mcw_metaoption; global $mcw_backup_postfix; delete_option($mcw_prefix . $mcw_metaoption); //delete all productive data $all_widget_IDs = get_option($mcw_prefix . $mcw_widgetsoption); $max = count($all_widget_IDs); for ($i = 0; $i < $max; ++$i) { delete_option($mcw_prefix . 'w_' . $all_widget_IDs[$i]['name']); } delete_option($mcw_prefix . $mcw_widgetsoption); delete_option($mcw_prefix . $mcw_configoption); //delete all backup data $all_backup_widget_IDs = get_option($mcw_prefix . $mcw_widgetsoption . $mcw_backup_postfix); $max = count($all_backup_widget_IDs); for ($i = 0; $i < $max; ++$i) { delete_option($mcw_prefix . $mcw_backup_postfix . 'w_' . $all_backup_widget_IDs[$i]['name']); } delete_option($mcw_prefix . $mcw_widgetsoption . $mcw_backup_postfix); delete_option($mcw_prefix . $mcw_configoption . $mcw_backup_postfix); } /************************************/ /*** initialize widgets ***/ /************************************/ $myWidget_IDs_all = MCW_get_all_widget_IDs(); $maxindex = count($myWidget_IDs_all); // Register widgets if (!empty($myWidget_IDs_all)) { if (MCW_generaterequired() == true) { echo MCW_generate_class(); } //include_once( "my_custom_widget_classes.php" ); global $mcw_path; include_once $mcw_path["include_class"]; $tag = MCW_get_option('outfilter'); add_filter($tag, MCW_make_available_outside); } /*************************************************************************/ /*** single widget-implementation as it has to be according to WP 2.8 ***/ /*************************************************************************/ include_once "my_custom_widget_addon.php"; }
function MCW_restore_widget_backup() { global $mcw_prefix; global $mcw_widgetsoption; global $mcw_backup_postfix; //delete obsolete data $current_ID = MCW_get_all_widget_IDs(); $max = count($current_ID); for ($i = 0; $i < $max; ++$i) { delete_option($mcw_prefix . 'w_' . $current_ID[$i]['name']); } //restore backup data $backup_IDs = get_option($mcw_prefix . $mcw_widgetsoption . $mcw_backup_postfix); MCW_set_all_widget_IDs($backup_IDs); $max = count($backup_IDs); for ($i = 0; $i < $max; ++$i) { $backup_widget = get_option($mcw_prefix . $mcw_backup_postfix . 'w_' . $backup_IDs[$i]['name']); if (empty($backup_widget)) { MCW_swap_widgetdata($i); } else { update_option($mcw_prefix . 'w_' . $backup_IDs[$i]['name'], $backup_widget); } } $error_message = MCW_generate_class(); if ($error_message == '') { return $max; } else { return $error_message; } }