Created
February 19, 2015 22:06
-
-
Save bekarice/1e6a0042abe4d798581a to your computer and use it in GitHub Desktop.
Forces WPML language settings to stop breaking the WooCommerce REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function wpml_wc_api_home_url( $url, $path, $orig_scheme, $blog_id ) { | |
| global $sitepress; | |
| if ( isset( $sitepress ) && 0 === strpos( $path, 'wc-api/' ) ) { | |
| $url = $sitepress->convert_url( str_replace( $path, '', $url ), $sitepress->get_default_language() ); | |
| $url = untrailingslashit( $url ) . '/' . ltrim( $path, '/' ); | |
| } | |
| return $url; | |
| } | |
| add_filter( 'home_url', 'wpml_wc_api_home_url', 0, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment