This thread is resolved. Here is a description of the problem and solution.
Problem:
After updating WPML to v4.9.0, you might encounter a redirect issue that affects the Bricks editor in the default language (Spanish) when the 'Use directory for default language' setting is enabled. Specifically, accessing a Spanish URL with the Bricks editor redirects to an incorrect URL with an extra '/en/' prefix, causing a 404 error.
Solution:
To resolve this issue, follow these steps:
1. Navigate to Bricks → Settings → Builder.
2. Set the language to 'Site Default'.
If the issue persists, you can apply a technical alternative by adding the following code to your theme's functions.php file:
add_action( 'after_setup_theme', function () {<br /> if ( ! defined( 'ICL_SITEPRESS_VERSION' ) || ! class_exists( '\Bricks\Theme' ) ) {<br /> return;<br /> }<br /><br /> $bricks = \Bricks\Theme::instance();<br /><br /> // 1. Prevent Bricks from switching language<br /> if ( ! empty( $bricks->wpml ) ) {<br /> remove_action( 'bricks/builder/switch_locale', [ $bricks->wpml, 'switch_builder_languge' ] );<br /> }<br /><br /> // 2. Instead switch UI locale<br /> add_action( 'bricks/builder/switch_locale', function ( $locale ) {<br /> if ( empty( $locale ) || empty( $_GET['bricks'] ) || $_GET['bricks'] !== 'run' ) {<br /> return;<br /> }<br /><br /> // prevent memory exhausion I got on my sandbox<br /> static $lock = false;<br /> if ( $lock ) {<br /> return;<br /> }<br /> $lock = true;<br /><br /> try {<br /> // Switch UI locale<br /> switch_to_locale( $locale );<br /> // Reload Bricks theme textdomain <br /> unload_textdomain( 'bricks' );<br /> load_theme_textdomain( 'bricks', get_template_directory() . '/languages' );<br /> } finally {<br /> $lock = false;<br /> }<br /><br /> }, 5, 1 );<br /><br />}, 20 );If this solution does not apply to your case or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 9 replies, has 0 voices.
Last updated by 2 weeks, 4 days ago.
Assisted by: Paola Mendiburu.
