1: <?php
2:
3: 4: 5:
6: class Quform_Admin_Page_Tools_Uninstall extends Quform_Admin_Page_Tools
7: {
8: 9: 10:
11: protected $options;
12:
13: 14: 15:
16: protected $permissions;
17:
18: 19: 20:
21: protected $uploader;
22:
23: 24: 25:
26: protected $session;
27:
28: 29: 30:
31: protected $upgrader;
32:
33: 34: 35: 36: 37: 38: 39: 40: 41:
42: public function __construct(
43: Quform_ViewFactory $viewFactory,
44: Quform_Repository $repository,
45: Quform_Options $options,
46: Quform_Permissions $permissions,
47: Quform_Uploader $uploader,
48: Quform_Session $session,
49: Quform_Upgrader $upgrader
50: ) {
51: parent::__construct($viewFactory, $repository);
52:
53: $this->options = $options;
54: $this->permissions = $permissions;
55: $this->uploader = $uploader;
56: $this->session = $session;
57: $this->upgrader = $upgrader;
58: }
59:
60: public function init()
61: {
62: $this->template = QUFORM_TEMPLATE_PATH . '/admin/tools/uninstall.php';
63: }
64:
65: 66: 67: 68: 69:
70: protected function getAdminTitle()
71: {
72: return __('Uninstall', 'quform');
73: }
74:
75: 76: 77: 78: 79: 80: 81:
82: public function getNavHtml(array $currentForm = null, array $extra = array())
83: {
84: $extra[40] = sprintf(
85: '<div class="qfb-nav-item qfb-nav-page-info"><i class="qfb-nav-page-icon qfb-icon-trash-o"></i><span class="qfb-nav-page-title">%s</span></div>',
86: esc_html__('Uninstall', 'quform')
87: );
88:
89: return parent::getNavHtml($currentForm, $extra);
90: }
91:
92: 93: 94:
95: public function process()
96: {
97: if ( ! current_user_can('activate_plugins')) {
98: wp_die(__( 'You do not have sufficient permissions to access this page.', 'quform'), 403);
99: }
100:
101: if (Quform::isPostRequest()) {
102: if ( ! isset($_POST['qfb_uninstall_confirm']) || $_POST['qfb_uninstall_confirm'] != 1) {
103: $this->addMessage('error', __('You must confirm to continue.', 'quform'));
104: return;
105: }
106:
107: if ( ! check_ajax_referer('quform_uninstall', false, false)) {
108: $this->addMessage('error', __('Nonce check failed.', 'quform'));
109: return;
110: }
111:
112: deactivate_plugins(QUFORM_BASENAME);
113:
114: $this->repository->uninstall();
115: $this->options->uninstall();
116: $this->permissions->uninstall();
117: $this->uploader->uninstall();
118: $this->session->uninstall();
119: $this->upgrader->uninstall();
120:
121: do_action('quform_uninstall');
122:
123: wp_safe_redirect(self_admin_url('plugins.php?deactivate=true'));
124: exit;
125: }
126: }
127: }
128: