| @@ 215-230 (lines=16) @@ | ||
| 212 | * @return void |
|
| 213 | * @action pollux/{static::ID}/init |
|
| 214 | */ |
|
| 215 | public function resetPage() |
|
| 216 | { |
|
| 217 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
|
| 218 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
|
| 219 | )return; |
|
| 220 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
|
| 221 | update_option( static::id(), $this->getDefaults() ); |
|
| 222 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
|
| 223 | } |
|
| 224 | else { |
|
| 225 | add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); |
|
| 226 | } |
|
| 227 | set_transient( 'settings_errors', get_settings_errors(), 30 ); |
|
| 228 | wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); |
|
| 229 | exit; |
|
| 230 | } |
|
| 231 | ||
| 232 | /** |
|
| 233 | * @param string $key |
|
| @@ 106-121 (lines=16) @@ | ||
| 103 | * @return void |
|
| 104 | * @action pollux/{static::ID}/init |
|
| 105 | */ |
|
| 106 | public function resetPage() |
|
| 107 | { |
|
| 108 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id |
|
| 109 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
|
| 110 | )return; |
|
| 111 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { |
|
| 112 | delete_option( static::id() ); |
|
| 113 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
|
| 114 | } |
|
| 115 | else { |
|
| 116 | add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); |
|
| 117 | } |
|
| 118 | set_transient( 'settings_errors', get_settings_errors(), 30 ); |
|
| 119 | wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); |
|
| 120 | exit; |
|
| 121 | } |
|
| 122 | } |
|
| 123 | ||