mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Handle the clear db AJAX request shoulr be outside of check.
This commit is contained in:
parent
2fd1a6f574
commit
6a9c76fa9e
3 changed files with 16 additions and 20 deletions
|
@ -23,21 +23,18 @@ document.addEventListener(
|
|||
body: JSON.stringify({
|
||||
nonce: clearDbConfig.nonce,
|
||||
})
|
||||
}).then(function (res) {
|
||||
}).then((res)=>{
|
||||
return res.json();
|
||||
}).then(function (data) {
|
||||
const resultMessage = document.querySelector(clearDbConfig.messageSelector);
|
||||
|
||||
}).then((data)=>{
|
||||
if (!data.success) {
|
||||
clearDbConfig.failureMessage.insertAfter(clearButton);
|
||||
setTimeout(()=> resultMessage.remove(),3000);
|
||||
jQuery(clearDbConfig.failureMessage).insertAfter(clearButton);
|
||||
setTimeout(()=> jQuery(clearDbConfig.messageSelector).remove(),3000);
|
||||
clearButton.removeAttribute('disabled');
|
||||
console.error(data);
|
||||
throw Error(data.data.message);
|
||||
}
|
||||
|
||||
clearDbConfig.successMessage.insertAfter(clearButton);
|
||||
setTimeout(()=> resultMessage.remove(),3000);
|
||||
jQuery(clearDbConfig.successMessage).insertAfter(clearButton);
|
||||
setTimeout(()=> jQuery(clearDbConfig.messageSelector).remove(),3000);
|
||||
clearButton.removeAttribute('disabled');
|
||||
});
|
||||
})
|
||||
|
|
|
@ -57,11 +57,11 @@ return array(
|
|||
'messageSelector' => '.clear-db-info-message',
|
||||
'ConfirmationMessage' => __( 'Are you sure? the operation will remove all plugin data.', 'woocommerce-paypal-payments' ),
|
||||
'successMessage' => sprintf(
|
||||
'<span class="success clear-db-info-message">%1$s</span>',
|
||||
'<div class="updated clear-db-info-message"><p><strong>%1$s</strong></p></div>',
|
||||
esc_html__( 'The plugin data is successfully cleared.', 'woocommerce-paypal-payments' )
|
||||
),
|
||||
'failureMessage' => sprintf(
|
||||
'<span class="error clear-db-info-message">%1$s</span>',
|
||||
'<div class="error clear-db-info-message"><p><strong>%1$s</strong></p></div>',
|
||||
esc_html__( 'Operation failed. Check WooCommerce logs for more details.', 'woocommerce-paypal-payments' )
|
||||
),
|
||||
),
|
||||
|
|
|
@ -40,15 +40,15 @@ class UninstallModule implements ModuleInterface {
|
|||
$page_id = $container->get( 'wcgateway.current-ppcp-settings-page-id' );
|
||||
if ( Settings::CONNECTION_TAB_ID === $page_id ) {
|
||||
$this->registerClearDatabaseAssets( $container->get( 'uninstall.clear-db-assets' ) );
|
||||
|
||||
$request_data = $container->get( 'button.request-data' );
|
||||
$clear_db = $container->get( 'uninstall.clear-db' );
|
||||
$clear_db_endpoint = $container->get( 'uninstall.clear-db-endpoint' );
|
||||
$option_names = $container->get( 'uninstall.ppcp-all-option-names' );
|
||||
$scheduled_action_names = $container->get( 'uninstall.ppcp-all-scheduled-action-names' );
|
||||
|
||||
$this->handleClearDbAjaxRequest( $request_data, $clear_db, $clear_db_endpoint, $option_names, $scheduled_action_names );
|
||||
}
|
||||
|
||||
$request_data = $container->get( 'button.request-data' );
|
||||
$clear_db = $container->get( 'uninstall.clear-db' );
|
||||
$clear_db_endpoint = $container->get( 'uninstall.clear-db-endpoint' );
|
||||
$option_names = $container->get( 'uninstall.ppcp-all-option-names' );
|
||||
$scheduled_action_names = $container->get( 'uninstall.ppcp-all-scheduled-action-names' );
|
||||
|
||||
$this->handleClearDbAjaxRequest( $request_data, $clear_db, $clear_db_endpoint, $option_names, $scheduled_action_names );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,6 @@ class UninstallModule implements ModuleInterface {
|
|||
try {
|
||||
// Validate nonce.
|
||||
$request_data->read_request( $nonce );
|
||||
|
||||
$clear_db->delete_options( $option_names );
|
||||
$clear_db->clear_scheduled_actions( $scheduled_action_names );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue