-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3100 from woocommerce/PCP-4209-create-a-method-to…
…-reset-db-settings Create a method to reset DB settings (4209)
- Loading branch information
Showing
11 changed files
with
184 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
modules/ppcp-settings/resources/css/components/screens/_modals.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Modal for disconnecting the merchant from the current PayPal account. | ||
*/ | ||
.ppcp--modal-disconnect { | ||
.ppcp--toggle-danger { | ||
--wp-components-color-accent: #cc1818 | ||
} | ||
|
||
.ppcp--action-buttons { | ||
text-align: right; | ||
margin-top: 32px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Provides functionality for general settings-data management. | ||
* | ||
* @package WooCommerce\PayPalCommerce\Settings\Service | ||
*/ | ||
|
||
declare( strict_types = 1 ); | ||
|
||
namespace WooCommerce\PayPalCommerce\Settings\Service; | ||
|
||
use WooCommerce\PayPalCommerce\Settings\Data\AbstractDataModel; | ||
|
||
/** | ||
* Class SettingsDataManager | ||
* | ||
* Manages operations related to plugin settings, primarily focusing on reset functionality. | ||
* This service can be expanded in the future to include other settings management operations. | ||
*/ | ||
class SettingsDataManager { | ||
|
||
/** | ||
* Stores a list of all AbstractDataModel instances that are managed by | ||
* this service. | ||
* | ||
* @var AbstractDataModel[] | ||
*/ | ||
private array $models = array(); | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param array $data_models List of AbstractDataModel instances. | ||
*/ | ||
public function __construct( array $data_models ) { | ||
foreach ( $data_models as $data_model ) { | ||
if ( $data_model instanceof AbstractDataModel ) { | ||
$this->models[] = $data_model; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Completely purges all settings from the DB. | ||
* | ||
* @return void | ||
*/ | ||
public function reset_all_settings() : void { | ||
/** | ||
* Broadcast the settings-reset event to allow other modules to perform | ||
* cleanup tasks, if needed. | ||
*/ | ||
do_action( 'woocommerce_paypal_payments_reset_settings' ); | ||
|
||
foreach ( $this->models as $model ) { | ||
$model->purge(); | ||
} | ||
|
||
// Clear any caches. | ||
wp_cache_flush(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters