Skip to content

Instantly share code, notes, and snippets.

@bekarice
Created February 19, 2015 22:06
Show Gist options
  • Select an option

  • Save bekarice/1e6a0042abe4d798581a to your computer and use it in GitHub Desktop.

Select an option

Save bekarice/1e6a0042abe4d798581a to your computer and use it in GitHub Desktop.
Forces WPML language settings to stop breaking the WooCommerce REST API
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