Skip to content

Commit

Permalink
Move clean db method to advanced tab
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Oct 31, 2024
1 parent 454ae11 commit d6e04c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
19 changes: 19 additions & 0 deletions src/Settings/Page/Section/Advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Advanced extends AbstractSection
{
public function config(): array
{
$this->cleanDbIfRequested();
$config = [
[
'id' => $this->settings->getSettingId('title'),
Expand Down Expand Up @@ -245,4 +246,22 @@ protected function content(): string
<?php
return ob_get_clean();
}

protected function cleanDbIfRequested()
{
if (
isset($_GET['cleanDB-mollie']) && wp_verify_nonce(
filter_input(INPUT_GET, 'nonce_mollie_cleanDb', FILTER_SANITIZE_SPECIAL_CHARS),
'nonce_mollie_cleanDb'
)
) {
$cleaner = $this->settings->cleanDb();
$cleaner->cleanAll();
//set default settings
foreach ($this->paymentMethods as $paymentMethod) {
$paymentMethod->getSettings();
}
}
}

}
18 changes: 0 additions & 18 deletions src/Settings/Page/Section/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ protected function content(): string
public function renderGateways(): string
{
$this->refreshIfRequested();
$this->cleanDbIfRequested();

$titleActivePaymentMethods = __(
'Currently Active Payment Methods',
Expand Down Expand Up @@ -194,23 +193,6 @@ protected function refreshIfRequested()
}
}

protected function cleanDbIfRequested()
{
if (
isset($_GET['cleanDB-mollie']) && wp_verify_nonce(
filter_input(INPUT_GET, 'nonce_mollie_cleanDb', FILTER_SANITIZE_SPECIAL_CHARS),
'nonce_mollie_cleanDb'
)
) {
$cleaner = $this->settings->cleanDb();
$cleaner->cleanAll();
//set default settings
foreach ($this->paymentMethods as $paymentMethod) {
$paymentMethod->getSettings();
}
}
}

protected function paymentGatewayButton(AbstractPaymentMethod $paymentMethod, $enabledInMollie): string
{
$documentationLink = $paymentMethod->getProperty('docs');
Expand Down

0 comments on commit d6e04c3

Please sign in to comment.