/** * Most of the actual deactivation work is done here. Called either as a response * to the user confirming the deactivation on `?page=versionpress/admin/deactivate.php` * or is called directly from vp_deactivate() if the confirmation screen was not necessary. */ function vp_admin_post_confirm_deactivation() { //nonce verification is performed according to 'deactivate-plugin_versionpress/versionpress.php' // as a standard deactivation token for which nonce is generated if (!defined('WP_CLI')) { vp_verify_nonce('deactivate-plugin_versionpress/versionpress.php'); vp_check_permissions(); } define('VP_DEACTIVATING', true); if (WpdbReplacer::isReplaced()) { WpdbReplacer::restoreOriginal(); } if (file_exists(VERSIONPRESS_ACTIVATION_FILE)) { FileSystem::remove(VERSIONPRESS_ACTIVATION_FILE); } $filesChangedByDeactivation = [["type" => "path", "path" => VP_VPDB_DIR . "/*"], ["type" => "path", "path" => ABSPATH . WPINC . "/wp-db.php"], ["type" => "path", "path" => ABSPATH . WPINC . "/wp-db.php.original"], ["type" => "path", "path" => ABSPATH . "/.gitattributes"]]; vp_force_action('versionpress', 'deactivate', null, [], $filesChangedByDeactivation); MergeDriverInstaller::uninstallMergeDriver(VP_PROJECT_ROOT, VERSIONPRESS_PLUGIN_DIR, VP_VPDB_DIR); deactivate_plugins("versionpress/versionpress.php", true); if (defined('WP_ADMIN')) { wp_safe_redirect(admin_url("plugins.php")); exit; } }
/** * @test */ public function gitAttributesRemovedCorrectlyAfterUninstall() { $this->installMergeDriver('auto'); MergeDriverInstaller::uninstallMergeDriver(self::$repositoryDir, __DIR__ . '/../..', self::$repositoryDir); $this->assertNotContains('vp-ini', file_get_contents(self::$repositoryDir . "/.git/config")); $this->assertFileNotExists(self::$repositoryDir . "/.gitattributes"); }