/**
  * Deactivate plugin action
  *
  * @return void
  */
 function deactivate()
 {
     try {
         w3_enable_maintenance_mode();
     } catch (Exception $ex) {
     }
     try {
         $e = w3_instance('W3_AdminEnvironment');
         $config = w3_instance('W3_Config');
         $e->fix_after_deactivation($config);
         w3_instance('W3_AdminLinks')->link_delete();
     } catch (SelfTestExceptions $exs) {
         $r = w3_parse_selftest_exceptions($exs);
         if (strlen($r['required_changes']) > 0) {
             $changes_style = 'border: 1px solid black; ' . 'background: white; ' . 'margin: 10px 30px 10px 30px; ' . 'padding: 10px;';
             $error = '<strong>W3 Total Cache Error:</strong> ' . 'Files and directories could not be automatically ' . 'removed to complete the deactivation. ' . '<br />Please execute commands manually:<br />' . '<div style="' . $changes_style . '">' . $r['required_changes'] . '</div>';
             // this is not shown since wp redirects from that page
             // not solved now
             echo '<div class="error"><p>' . $error . '</p></div>';
         }
     }
     try {
         w3_disable_maintenance_mode();
     } catch (Exception $ex) {
     }
 }
Example #2
0
 /**
  * Run deactivate on loaded plugins
  */
 public function deactivate()
 {
     w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
     $ftp_form = null;
     try {
         w3_enable_maintenance_mode();
     } catch (Exception $ex) {
     }
     $errors = array('errors' => array());
     try {
         if (!$this->_config->get_boolean('pgcache.enabled')) {
             $plugin = w3_instance('W3_Plugin_PgCache');
             $this->_loaded_plugins[] = $plugin;
         }
         foreach ($this->_loaded_plugins as $plugin) {
             $result = $plugin->deactivate();
             if ($result) {
                 $plugin_errors = isset($result['errors_short_form']) ? $result['errors_short_form'] : $result['errors'];
                 $errors['errors'] = array_merge($errors['errors'], $plugin_errors);
                 if (isset($result['ftp_form'])) {
                     $errors['ftp_form'] = $result['ftp_form'];
                 }
             }
         }
     } catch (Exception $ex) {
         $errors['errors'][] = $ex->getMessage();
     }
     $result = $this->delete_files_and_folders();
     try {
         w3_disable_maintenance_mode();
     } catch (Exception $ex) {
     }
     if ($result['errors']) {
         $errors['errors'] = array_merge($errors['errors'], $result['errors']);
         if (isset($result['ftp_form'])) {
             $errors['ftp_form'] = $result['ftp_form'];
         }
     }
     return $errors;
 }