Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove local languages piwoo 551 #951

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resources/
!vendor/mollie/mollie-api-php/Resources
vendor/**/test*
vendor/mollie/mollie-api-php/examples/
languages/*.po
languages/
bin/
*.lock
composer.json
Expand Down
1 change: 0 additions & 1 deletion .psalm/stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ function as_unschedule_action($string) {}
function mollieWooCommerceIsCheckoutContext() {}
function wcs_get_subscriptions($subs) {}
function mollieWooCommerceFormatCurrencyValue($value, $currency){}
function mollieDeleteWPTranslationFiles(){}
function mollieWooCommerceIsPayPalButtonEnabled($page){}
function mollieWooCommerceIsApplePayDirectEnabled($page){}
function mollieWooCommerceCheckIfNeedShipping($product){}
Expand Down
44 changes: 0 additions & 44 deletions inc/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,50 +190,6 @@ 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) {
return;
}
$remote_destination = $wp_filesystem->find_folder(WP_LANG_DIR);
if (!$wp_filesystem->exists($remote_destination)) {
return;
}
$languageExtensions = [
'de_DE',
'de_DE_formal',
'es_ES',
'fr_FR',
'it_IT',
'nl_BE',
'nl_NL',
'nl_NL_formal',
'en_GB',
'nl_BE_formal',
];
$translationExtensions = ['.mo', '.po', '.l10n.php'];
$destination = WP_LANG_DIR
. '/plugins/mollie-payments-for-woocommerce-';
foreach ($languageExtensions as $languageExtension) {
foreach ($translationExtensions as $translationExtension) {
$file = $destination . $languageExtension
. $translationExtension;
$wp_filesystem->delete($file, false);
}
}
}

function transformPhoneToNLFormat($phone)
{
$startsWith06 = preg_match('/^06/', $phone);
Expand Down
16 changes: 0 additions & 16 deletions mollie-payments-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@
define('M4W_PLUGIN_URL', plugin_dir_url(M4W_FILE));
}

/**
* Called when plugin is activated
*/
function mollie_wc_plugin_activation_hook()
{
require_once __DIR__ . '/inc/functions.php';

if (!mollie_wc_plugin_autoload()) {
return;
}

mollieDeleteWPTranslationFiles();
}


function mollie_wc_plugin_autoload()
{
Expand Down Expand Up @@ -174,5 +160,3 @@ function initialize()
}

add_action('plugins_loaded', __NAMESPACE__ . '\\initialize');

register_activation_hook(M4W_FILE, __NAMESPACE__ . '\mollie_wc_plugin_activation_hook');
15 changes: 0 additions & 15 deletions src/Activation/ActivationModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function run(ContainerInterface $container): bool
[$this, 'pluginInit']
);
$this->declareCompatibleWithHPOS();
$this->handleTranslations();
$this->mollieWcNoticeApiKeyMissing();
$this->appleValidationFileRewriteRules();
return true;
Expand Down Expand Up @@ -77,20 +76,6 @@ public function initDb()
}
}

/**
*
*/
public function handleTranslations(): void
{
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
Loading