MultilingualPress compatibility

MultilingualPress is an excellent solution to configure your WordPress sites in multiple languages. The WordPress multisite base is used to configure a site for each language. So, the MultilingualPress plugin makes the connections between the different contents in an efficient and easy way. With much less server performance load than WPML or similar.

The problem we have is that Bricks and MultilingualPress currently don’t get along very well.
There is a problem with regenerating CSS files after saving changes in the editor of a page or post (or modifying a custom field). The bricks CSS is removed and the layout is broken.

To solve this, for now, you must have the CSS configured in inline mode. So everything works fine. But at the level of performance and optimization, it is better to have external CSS files.

I have configured a custom function for the functions.php of the child-theme, in which after 2 seconds of doing a “save_post”, the Bricks CSS of that post or page that has been updated is regenerated. This small action solves the problem that the brick design breaks.

It may not be the best way and could lead to problems. For this reason, I have added this compatibility to the Bricks “idea board”. But in the meantime, I leave you the code in case it can help someone.


function custom_schedule_css_regeneration_on_save_post( $post_id ) {
 if ( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) ) {
 return;
 }
 $timestamp = time() + 2;
 wp_schedule_single_event( $timestamp, 'custom_regenerate_bricks_css', array( $post_id ) );
}
add_action( 'save_post', 'custom_schedule_css_regeneration_on_save_post' );

function custom_regenerate_bricks_css( $post_id ) {

 if ( class_exists( '\Bricks\Assets_Files' ) && method_exists( '\Bricks\Assets_Files', 'generate_post_css_file' ) ) {
 $area = \Bricks\Templates::get_template_type( $post_id );
 $elements = \Bricks\Database::get_data( $post_id, $area );
 \Bricks\Assets_Files::generate_post_css_file( $post_id, $area, $elements );
 }
}
add_action( 'custom_regenerate_bricks_css', 'custom_regenerate_bricks_css', 10, 1 );


1 Like

Fantastic, I am just looking into buying MultilingualPress. This will be helpful.

Hi There,

Is this compatability somthing you are able to address directly as we were looking to do multilingual breakdance build but due to lack of good support for WPML or seemingly Multilingualpress we are moving to Bricks Builder.

MultilingualPress seems like the right way to do a multilingual site and I have read Sybres article at The SEO Framework that says the same thing essentially, as well as reaching out to him on support.

Do you have an idea when you might be able to implement a fix to solve this compatability issue?

Multilingualpress support said the following, so if you can reach out they might be able to aid in finding a solution

The issue with Bricks seems to be more related to how the Bricks builder itself functions and should ideally be resolved within that plugin. As far as I remember, the builder does not automatically regenerate its custom styles when a post is saved outside of its own editor (e.g., remotely via WP Editor, MLP metabox, or when using switch_to_blog() ). Therefore, it’s not strictly a compatibility problem between MLP and Bricks but rather an issue with how Bricks interacts with core WordPress functionality, including Multisite.

Unfortunately, this issue has not yet been addressed by the development team, and I’m unable to provide a specific solution at this time. Maintaining compatibility code for Bricks in MLP is not a priority for us, as we believe the underlying issue lies within Bricks itself.

However, it would be helpful if we could download the theme from the provided staging site and attach it to the issue. This would allow our developers to reproduce the problem locally and provide more accurate feedback.

Many thanks

Hi,

I don’t know if your comment is in response to my first post or if it is intended for the Bricks development team; in case it is for me, here is my response:

Regarding the compatibility between Bricks Builder and MultilingualPress, I have developed a snippet of code that resolves the issue of regenerating CSS files when saving changes in the editor of a page or post (or modifying a custom field). With this code snippet, the compatibility between Bricks Builder and MultilingualPress is perfect, as it effectively regenerates the Bricks CSS and prevents the layout from breaking.

However, it’s important to note that there will be no automatic synchronization between the templates or designs created with Bricks Builder. This means that any design changes will need to be managed manually for each language.

I hope this helps.

Best regards,