Code Duplication    Length = 16-16 lines in 2 locations

src/Config/Config.php 1 location

@@ 105-120 (lines=16) @@
102
	 * @return void
103
	 * @action pollux/{static::ID}/init
104
	 */
105
	public function resetPage()
106
	{
107
		if( filter_input( INPUT_GET, 'page' ) !== $this->app->id
108
			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
109
		)return;
110
		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) {
111
			delete_option( static::id() );
112
			add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' );
113
		}
114
		else {
115
			add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ));
116
		}
117
		set_transient( 'settings_errors', get_settings_errors(), 30 );
118
		wp_safe_redirect( add_query_arg( 'settings-updated', 'true',  wp_get_referer() ));
119
		exit;
120
	}
121
}
122

src/Settings/Settings.php 1 location

@@ 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