public static function uninstallPlugin()
 {
     //Send admin alert
     if (wfConfig::get('alertOn_wordfenceDeactivated')) {
         $currentUser = wp_get_current_user();
         $username = $currentUser->user_login;
         wordfence::alert("Wordfence Deactivated", "A user with username \"{$username}\" deactivated Wordfence on your WordPress site.", wfUtils::getIP());
     }
     //Check if caching is enabled and if it is, disable it and fix the .htaccess file.
     $cacheType = wfConfig::get('cacheType', false);
     if ($cacheType == 'falcon') {
         wfCache::addHtaccessCode('remove');
         wfCache::updateBlockedIPs('remove');
         wfConfig::set('cacheType', false);
         //We currently don't clear the cache when plugin is disabled because it will take too long if done synchronously and won't work because plugin is disabled if done asynchronously.
         //wfCache::scheduleCacheClear();
     } else {
         if ($cacheType == 'php') {
             wfConfig::set('cacheType', false);
         }
     }
     //Used by MU code below
     update_option('wordfenceActivated', 0);
     wp_clear_scheduled_hook('wordfence_daily_cron');
     wp_clear_scheduled_hook('wordfence_hourly_cron');
     wp_clear_scheduled_hook('wordfence_daily_autoUpdate');
     //Remove old legacy cron job if it exists
     wp_clear_scheduled_hook('wordfence_scheduled_scan');
     //Remove all scheduled scans.
     self::unscheduleAllScans();
     // Remove cron for email summary
     wfActivityReport::clearCronJobs();
     // Remove the admin user list so it can be regenerated if Wordfence is reactivated.
     wfConfig::set_ser('adminUserList', false);
     if (!WFWAF_SUBDIRECTORY_INSTALL) {
         wfWAFConfig::set('wafDisabled', true);
     }
     if (wfConfig::get('deleteTablesOnDeact')) {
         $schema = new wfSchema();
         $schema->dropAll();
         wfConfig::updateTableExists();
         foreach (array('wordfence_version', 'wordfenceActivated') as $opt) {
             delete_option($opt);
         }
         if (!WFWAF_SUBDIRECTORY_INSTALL) {
             try {
                 if (WFWAF_AUTO_PREPEND) {
                     $helper = new wfWAFAutoPrependHelper();
                     if ($helper->uninstall()) {
                         wfWAF::getInstance()->uninstall();
                     }
                 } else {
                     wfWAF::getInstance()->uninstall();
                 }
             } catch (wfWAFStorageFileException $e) {
                 error_log($e->getMessage());
             }
         }
     }
 }
Example #2
0
 public static function uninstallPlugin()
 {
     //Check if caching is enabled and if it is, disable it and fix the .htaccess file.
     $cacheType = wfConfig::get('cacheType', false);
     if ($cacheType == 'falcon') {
         wfCache::addHtaccessCode('remove');
         wfCache::updateBlockedIPs('remove');
         wfConfig::set('cacheType', false);
         //We currently don't clear the cache when plugin is disabled because it will take too long if done synchronously and won't work because plugin is disabled if done asynchronously.
         //wfCache::scheduleCacheClear();
     } else {
         if ($cacheType == 'php') {
             wfConfig::set('cacheType', false);
         }
     }
     //Used by MU code below
     update_option('wordfenceActivated', 0);
     wp_clear_scheduled_hook('wordfence_daily_cron');
     wp_clear_scheduled_hook('wordfence_hourly_cron');
     wp_clear_scheduled_hook('wordfence_daily_autoUpdate');
     //Remove old legacy cron job if it exists
     wp_clear_scheduled_hook('wordfence_scheduled_scan');
     //Remove all scheduled scans.
     self::unscheduleAllScans();
     // Remove cron for email summary
     wfActivityReport::clearCronJobs();
     wfConfig::clearDiskCache();
     if (wfConfig::get('deleteTablesOnDeact')) {
         $schema = new wfSchema();
         $schema->dropAll();
         foreach (array('wordfence_version', 'wordfenceActivated') as $opt) {
             delete_option($opt);
         }
     }
 }