From 93de15f68045ac97333e2f11e922f31ac8566f8b Mon Sep 17 00:00:00 2001 From: Amirhossein Hosseinpour Date: Fri, 15 Jul 2022 22:40:23 +0430 Subject: [PATCH] fix #126 --- assets/css/settings.css | 7 +- includes/plugins/woocommerce.php | 140 +++++++++++++++++++++++-------- 2 files changed, 111 insertions(+), 36 deletions(-) diff --git a/assets/css/settings.css b/assets/css/settings.css index c373fa1..92674f6 100644 --- a/assets/css/settings.css +++ b/assets/css/settings.css @@ -1,3 +1,8 @@ +/** + * @Last modified by: amirhp-com + * @Last modified time: 2022/07/15 22:19:33 + */ + body { background: #fff; } @@ -143,7 +148,7 @@ div.notice { color: #797979; } -:not([dir="rtl"]) .nav-tab-wrapper > a.nav-tab-active::after { +[dir="ltr"] .nav-tab-wrapper > a.nav-tab-active::after { transform: scale(-1); right: 40px; left: auto; diff --git a/includes/plugins/woocommerce.php b/includes/plugins/woocommerce.php index 6e505a3..98ac327 100644 --- a/includes/plugins/woocommerce.php +++ b/includes/plugins/woocommerce.php @@ -1,4 +1,6 @@ fix_persian_characters($data[$field]); + } + } + return apply_filters( "wpp_woocommerce_checkout_modified_persian_fields", $data); + } + + /** + * replace Arabic characters with equivalent character in Persian + * + * @method fix_persian_characters + * @param string $string + * @return string filtered $string + * @version 1.0.0 + * @since 4.0.1 + */ + public static function fix_persian_characters($string) + { + $characters = [ + 'ك' => 'ک', + 'دِ' => 'د', + 'بِ' => 'ب', + 'زِ' => 'ز', + 'ذِ' => 'ذ', + 'شِ' => 'ش', + 'سِ' => 'س', + 'ى' => 'ی', + 'ي' => 'ی', + '١' => '۱', + '٢' => '۲', + '٣' => '۳', + '٤' => '۴', + '٥' => '۵', + '٦' => '۶', + '٧' => '۷', + '٨' => '۸', + '٩' => '۹', + '٠' => '۰', + ]; + $characters = apply_filters( "wpp_arabic_persian_characters_list", $characters); + return str_replace(array_keys($characters), array_values($characters), $string); + } + /** * Fix persian postal code & phone numbers in WooCommerce checkout * @@ -429,11 +500,10 @@ public function wpp_validate_postcode( $valid, $postcode, $country ) { * * @return false|void */ - function wpp_validate_phone_number( $data, $errors ) { + public function wpp_validate_phone_number( $data, $errors ) { if ( preg_match( '/^(09[0-9]{9})$/', $data['billing_phone'] ) ) { return false; } - $errors->add( 'validation', 'شماره تماس وارد شده، معتبر نیست.' ); } }