PluginProbe
Database Reset / 3.25
Database Reset v3.25
2.3.2 3.0 3.0.1 3.0.2 3.1 3.15 3.16 3.17 3.18 3.19 3.20 3.21 3.22 3.23 3.24 3.25 trunk 1.0 1.2 1.2.1 1.2.2 1.3 1.4 2.0 2.1 All 27 releases
← All changes | class-db-reset-admin.php +23 -5 3.183.25 View file →
@@ -18,9 +18,9 @@
18 18 {
19 19 $this->resetter = new DB_Resetter();
20 20 $this->version = $version;
21 21
22 - $this->set_request($_REQUEST);
22 + $this->set_request($_REQUEST); //phpcs:ignore
23 23 $this->set_view_variables();
24 24 }
25 25
26 26 private function set_request(array $request)
@@ -63,11 +63,27 @@
63 63
64 64 add_filter('plugin_action_links_' . plugin_basename(DB_RESET_FILE), array($this, 'plugin_action_links'));
65 65 add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2);
66 66 add_filter('admin_footer_text', array($this, 'admin_footer_text'));
67 + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
67 68 }
68 69
70 + public function admin_enqueue_scripts() {
71 + $current_screen = get_current_screen();
72 + if ($current_screen->id != 'plugins') {
73 + return;
74 + }
69 75
76 + wp_enqueue_script('db-reset', plugins_url('assets/js/database-reset-plugins.js', __FILE__), array('jquery'), $this->version, true);
77 +
78 + $vars = array();
79 + $vars['info_link'] = admin_url('plugin-install.php?tab=plugin-information&plugin=wp-reset&TB_iframe=true&width=600&height=800');
80 + $vars['install_link'] = wp_nonce_url(add_query_arg(array('action' => 'install-plugin', 'plugin' => 'wp-reset'), admin_url('update.php')), 'install-plugin_wp-reset');
81 +
82 + wp_localize_script('db-reset', 'db_reset', $vars);
83 + } // admin_enqueue
84 +
85 +
70 86 // additional powered by text in admin footer; only on plugin's page
71 87 static function admin_footer_text($text)
72 88 {
73 89 $current_screen = get_current_screen();
@@ -109,8 +125,10 @@
109 125
110 126 // auto download / install / activate WPR plugin
111 127 function install_wpr()
112 128 {
129 + check_ajax_referer('install_wpr');
130 +
113 131 if (false === current_user_can('administrator')) {
114 132 wp_die('Sorry, you have to be an admin to run this action.');
115 133 }
116 134
@@ -131,9 +149,9 @@
131 149 }
132 150 </style>';
133 151
134 152 echo '<div style="margin: 20px; color:#444;">';
135 - echo 'If things are not done in a minute <a target="_parent" href="' . admin_url('plugin-install.php?s=wp-reset&tab=search&type=term') . '">install the plugin manually via Plugins page</a><br><br>';
153 + echo 'If things are not done in a minute <a target="_parent" href="' . esc_url(admin_url('plugin-install.php?s=wp-reset&tab=search&type=term')) . '">install the plugin manually via Plugins page</a><br><br>';
136 154 echo 'Starting ...<br><br>';
137 155
138 156 wp_cache_flush();
139 157 $upgrader = new Plugin_Upgrader();
@@ -158,9 +176,9 @@
158 176 echo '<script>setTimeout(function() { top.location = "tools.php?page=wp-reset"; }, 1000);</script>';
159 177 echo '<br>If you are not redirected in a few seconds - <a href="tools.php?page=wp-reset" target="_parent">click here</a>.';
160 178 }
161 179 } else {
162 - echo 'Could not install WP Reset. You\'ll have to <a target="_parent" href="' . admin_url('plugin-install.php?s=wp-reset&tab=search&type=term') . '">download and install manually</a>.';
180 + echo 'Could not install WP Reset. You\'ll have to <a target="_parent" href="' . esc_url(admin_url('plugin-install.php?s=wp-reset&tab=search&type=term')) . '">download and install manually</a>.';
163 181 }
164 182
165 183 echo '</div>';
166 184 } // install_wpr
@@ -203,9 +221,9 @@
203 221
204 222 private function handle_after_reset()
205 223 {
206 224 if (empty($this->request['db-reset-reactivate-theme-data'])) {
207 - wp_redirect(admin_url());
225 + wp_safe_redirect(admin_url());
208 226 exit;
209 227 }
210 228
211 229 $this->notice_success = __('The selected tables were reset', 'wordpress-database-reset');
@@ -322,9 +340,9 @@
322 340 return array(
323 341 'confirmAlert' => __('Are you sure you want to continue? There is NO UNDO!', 'wordpress-database-reset'),
324 342 'selectTable' => __('Select Tables', 'wordpress-database-reset'),
325 343 'selectOneTable' => __('Please select at least one table to reset.', 'wordpress-database-reset'),
326 - 'wprInstallUrl' => add_query_arg(array('action' => 'install_wpr'), admin_url('admin.php')),
344 + 'wprInstallUrl' => add_query_arg(array('action' => 'install_wpr', '_wpnonce' => wp_create_nonce('install_wpr')), admin_url('admin.php')),
327 345 'wprDialogTitle' => '<img alt="WP Reset" title="WP Reset" src="' . plugins_url('assets/images/wp-reset-logo.png', DB_RESET_FILE) . '">',
328 346 );
329 347 }
330 348 }