| @@ -104,8 +104,14 @@ | ||
| 104 | 104 | { |
| 105 | 105 | return sendwp_generate_hash() === $hash; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | + | |
| 109 | +function sendwp_get_hash() | |
| 110 | +{ | |
| 111 | + return sendwp_generate_hash(); | |
| 112 | +} | |
| 113 | + | |
| 108 | 114 | function sendwp_generate_hash() |
| 109 | 115 | { |
| 110 | 116 | $data = sendwp_get_client_name() . sendwp_get_client_secret(); |
| 111 | 117 | return hash('sha256', $data); |
| @@ -200,5 +206,27 @@ | ||
| 200 | 206 | |
| 201 | 207 | function sendwp_last_pulse_result() |
| 202 | 208 | { |
| 203 | 209 | return get_option('_transient_sendwp_pulse_monitor', 'unknown'); |
| 204 | -} | |
| 210 | +} | |
| 211 | + | |
| 212 | +function sendwp_reset_all_plugin_data() | |
| 213 | +{ | |
| 214 | + if (check_admin_referer('reset_sendwp_data' . sendwp_get_client_secret())) { | |
| 215 | + $options = [ | |
| 216 | + 'sendwp_client_secret', | |
| 217 | + ]; | |
| 218 | + | |
| 219 | + foreach ($options as $option) { | |
| 220 | + if (get_option($option, false) !== false) { | |
| 221 | + delete_option($option); | |
| 222 | + } | |
| 223 | + } | |
| 224 | + | |
| 225 | + sendwp_set_client_secret(sendwp_generate_secret()); | |
| 226 | + } | |
| 227 | + | |
| 228 | + wp_redirect(sendwp_get_client_redirect()); | |
| 229 | + | |
| 230 | + exit; | |
| 231 | +} | |
| 232 | +add_action( 'admin_post_sendwp_reset_plugin_data', 'sendwp_reset_all_plugin_data' ); | |