diff --git a/admin/page-loader.php b/admin/page-loader.php index 0706502..65a57cb 100644 --- a/admin/page-loader.php +++ b/admin/page-loader.php @@ -166,6 +166,45 @@ public function admin_menu() } } + /** + * This is specially for WPML page + * + * Redirects the user to the default language version of the current URL if the 'lang' parameter is not set or is different from the default language. + * + * @return void + */ + public function redirect_wpml() { + $default_lang = apply_filters('wpml_default_language', NULL); + if ( empty( $default_lang ) ) return; + // Get the current URL + $current_url = $_SERVER['REQUEST_URI']; + + // Parse the URL to get its components + $parsed_url = parse_url($current_url); + + // Parse the query string into an associative array + $query_params = []; + if (isset($parsed_url['query'])) { + parse_str($parsed_url['query'], $query_params); + } + + // Check if the 'lang' parameter is set + if (!isset($query_params['lang']) || ( isset($query_params['lang'] ) && $query_params['lang'] != $default_lang ) ) { + // If not set, add the 'lang' parameter with 'en' as its value + $query_params['lang'] = $default_lang; + + // Build the new query string + $new_query_string = http_build_query($query_params); + + // Construct the new URL + $new_url = $parsed_url['path'] . '?' . $new_query_string; + + // Redirect to the new URL + wp_redirect($new_url); + exit; + } + return; + } public function admin_enqueue_scripts() { global $current_screen; diff --git a/admin/page/topbar.php b/admin/page/topbar.php index 7deab85..d600555 100644 --- a/admin/page/topbar.php +++ b/admin/page/topbar.php @@ -1,6 +1,6 @@ redirect_wpml(); /** * This following part actually * for our both version diff --git a/readme.txt b/readme.txt index a9a5895..1e43c3a 100644 --- a/readme.txt +++ b/readme.txt @@ -196,6 +196,9 @@ Yes, it work with variable, to learn click on this [tutorial link.](https://cod = Is it working on WooCommerce Cart/Checkout block? = Yes, it is. += Is it Compabile with WPML? = +Yes, it is. Min max step need to set only to main product. + = Can I enable ajax add to cart on single product? = Yes, use `add_filter('wcmmq_ajax_cart_single_page', '__return_true');` for enable ajax add to cart on single page. @@ -253,6 +256,11 @@ We’ll provide support via [support ticket](https://codeastrology.com/my-suppor == Changelog == += 6.4 = +* Fully Compabile with wpml. +* Fixed: Code Optimized +* Bug Fixed. + = 6.3 = * filter hook `wcmmq_zero_min_issue` optiomized * Fixed: Code Optimized