Skip to content

Commit

Permalink
Remove translations on update and flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Oct 1, 2024
1 parent 0aa7805 commit 160c6a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions inc/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,17 @@ function mollieWooCommerceFormatCurrencyValue($value, $currency)
return number_format($value, 2, '.', '');
}

function mollieUpdateCompleted( $upgrader_object, $options ) {
//whenever something gets updated they update the languages, we need to delete them
mollieDeleteWPTranslationFiles();
}


function mollieDeleteWPTranslationFiles()
{
if ( ! function_exists( 'WP_Filesystem' ) ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
}
WP_Filesystem();
global $wp_filesystem;
if (!$wp_filesystem) {
Expand Down
8 changes: 7 additions & 1 deletion src/Activation/ActivationModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ public function initDb()
*/
public function handleTranslations(): void
{
add_action('core_upgrade_preamble', 'mollieDeleteWPTranslationFiles');
add_action('upgrader_process_complete', 'mollieUpdateCompleted', 10, 2);
// we need to handle this version specifically, we can remove this on the next
$translationFlag = get_option('mollie_plugin_update_translation');
if ($translationFlag !== 'yes') {
mollieDeleteWPTranslationFiles();
update_option('mollie_plugin_update_translation', 'yes');
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Shared/SharedDataDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class SharedDataDictionary
'_transient_mollie-wc-giftcard_issuers_test',
'_transient_timeout_mollie-wc-giftcard_issuers_live',
'_transient_mollie-wc-giftcard_issuers_live',
'mollie_plugin_update_translation'
];
public const DB_VERSION_PARAM_NAME = 'mollie-db-version';
public const PLUGIN_VERSION_PARAM_NAME = 'mollie-plugin-version';
Expand Down

0 comments on commit 160c6a7

Please sign in to comment.