Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client was unable to display the translated version of global sections in BeTheme using WPML.

Solution:
We recommended the following steps:
1- Open the "/wp-content/themes/betheme/functions/builder/class-mfn-builder-front.php" file
2- Replace the following snippet:

public function show_sections($mfn_items, $vbtoolsoff = false){

	if( !is_array($mfn_items) ) return;

	foreach ($mfn_items as $s => $section) {

		$section_class = [];

With

public function show_sections($mfn_items, $vbtoolsoff = false){

	if( !is_array($mfn_items) ) return;

	foreach ($mfn_items as $s => $section) {

		// WPML workaround for compsupp-7262
		if( class_exists('Sitepress') && ! empty($section['mfn_global_section_id'] ) ) {
			$section['mfn_global_section_id'] = apply_filters( 'wpml_object_id', $section['mfn_global_section_id'], get_post_type($section['mfn_global_section_id']) , TRUE  );
		}

		$section_class = [];

3- Open the "wp-content/themes/betheme/functions/post-types/class-mfn-post-type-template.php" file
4- Replace the following snippet (around line 21):

public function __construct(){

    if( !apply_filters('bebuilder_access', false) ){
        return false;
    }

    if( !current_user_can('editor') && !current_user_can('administrator') ){
        return false;
    }

    parent::__construct();

    // fires after WordPress has finished loading but before any headers are sent
    add_action('init', array($this, 'register'));

With

public function __construct(){

	// WPML Workaround for compsupp-7262 (Part 2)
	if ( ! class_exists('Sitepress') ) {

		if( !apply_filters('bebuilder_access', false) ){
			return false;
		}

		if( !current_user_can('editor') && !current_user_can('administrator') ){
			return false;
		}
	}

	parent::__construct();

	// fires after WordPress has finished loading but before any headers are sent
	add_action('init', array($this, 'register'));

If you're experiencing this issue, we recommend you try the steps above. However, please note that the solution might be irrelevant due to being outdated or not applicable to your case. If the problem persists, 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. Should you need further assistance, please open a new support ticket at our 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.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Osama Mersal 1 year, 1 month ago.

Assisted by: Osama Mersal.

Author Posts
March 13, 2024 at 10:47 am #15403057

konradB-6

I am trying to:
Show translated version of global sections.

Link to a page where the issue can be seen:
hidden link

I expected to see:
Translated Global Sections ie. FAQ, "od pomysłu do profilu", "Eksportujemy nasze produkty..".

Instead, I got:
Original version of this global sections

I have translated this global sections in template section betheme via wpml.
I tried this → https://wpml.org/errata/betheme-global-header-footer-translation-not-displaying-on-secondary-language/
Adding this code

	$section_global = mfn_template_part_ID('section');
    $section_global = apply_filters( 'wpml_object_id', $section_global , get_post_type($section_global) , TRUE  );

and

'section' => $section_global,

in mfn_global array but it's not working.

March 13, 2024 at 11:14 am #15403233

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

1) Please login to this sandbox site and install your theme. (hidden link)

After that, create a test global section and translate it to replicate the issue. If the issue is replicable, please let me know how to reproduce it.

2) It's unrelated to the issue, but according to your Debug.info, the WP memory limit needs to be increased. PHP memory is fine, but WordPress uses 40Mb as default. The minimum requirements for WPML are 128 MB. (Kindly check this page https://wpml.org/home/minimum-requirements/)

You can increase it by adding the following code in your wp-config.php file right before the /* That's all, stop editing! Happy publishing. */ line:

/* Memory Limit */
define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '256M');

Best regards,
Osama

March 13, 2024 at 2:25 pm #15404493

konradB-6

1. I changed BeBuilder data storage to Serialized readable format
2. I changed Custom field mfn-page-items from Don't translate to Translate
3. I created test page with two sections, first text and second with text, then saved second section as global section then delete section and add saved global section
4. Then i go to Betheme templates and added translate for english for global section

And as you see here global section is not shown for translated language
polish → hidden link
english → hidden link

For memory limit thanks 🙂

March 13, 2024 at 3:38 pm #15405178

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Thanks for replicating the issue. I'll consult our compatibility team and update you when I get their reply.

Thanks for your cooperation and patience

Best regards,
Osama

March 17, 2024 at 12:56 pm #15418355

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Thanks for your patience. Our comptability team has found the following workaround. Please check the following steps:

1- Edit the "/wp-content/themes/betheme/functions/builder/class-mfn-builder-front.php" file
2- Replace the following snippet: Line 361

public function show_sections($mfn_items, $vbtoolsoff = false){

	if( !is_array($mfn_items) ) return;

	foreach ($mfn_items as $s => $section) {

		$section_class = [];

With

public function show_sections($mfn_items, $vbtoolsoff = false){

	if( !is_array($mfn_items) ) return;

	foreach ($mfn_items as $s => $section) {

		// WPML workaround for compsupp-7262
		if( class_exists('Sitepress') && ! empty($section['mfn_global_section_id'] ) ) {
			$section['mfn_global_section_id'] = apply_filters( 'wpml_object_id', $section['mfn_global_section_id'], get_post_type($section['mfn_global_section_id']) , TRUE  );
		}

		$section_class = [];

3- Check the translated page

I've applied the above steps on the sandbox site. Please check if it works correctly. (hidden link)

Best regards,
Osama

March 18, 2024 at 9:11 am #15419729

konradB-6

Hi,
I checked it and it's working only for logged/admin users.
If you are normal user there is still only polish version shown.
Please check it in incognito hidden link

March 18, 2024 at 10:22 am #15420243

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Thanks for your update. I'll check with our compatibility team and update you as soon as I get an update.

Best regards,
Osama

March 19, 2024 at 4:37 pm #15427737

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Please try the following steps:

1- Open the "/wp-content/themes/betheme/functions/builder/class-mfn-builder-front.php" file
2- Replace the following snippet:

public function show_sections($mfn_items, $vbtoolsoff = false){

	if( !is_array($mfn_items) ) return;

	foreach ($mfn_items as $s => $section) {

		$section_class = [];

With

public function show_sections($mfn_items, $vbtoolsoff = false){

	if( !is_array($mfn_items) ) return;

	foreach ($mfn_items as $s => $section) {

		// WPML workaround for compsupp-7262
		if( class_exists('Sitepress') && ! empty($section['mfn_global_section_id'] ) ) {
			$section['mfn_global_section_id'] = apply_filters( 'wpml_object_id', $section['mfn_global_section_id'], get_post_type($section['mfn_global_section_id']) , TRUE  );
		}

		$section_class = [];

3- Open the "wp-content/themes/betheme/functions/post-types/class-mfn-post-type-template.php" file
4- Replace the following snippet (around line 21):

public function __construct(){

    if( !apply_filters('bebuilder_access', false) ){
        return false;
    }

    if( !current_user_can('editor') && !current_user_can('administrator') ){
        return false;
    }

    parent::__construct();

    // fires after WordPress has finished loading but before any headers are sent
    add_action('init', array($this, 'register'));

With

public function __construct(){

	// WPML Workaround for compsupp-7262 (Part 2)
	if ( ! class_exists('Sitepress') ) {

		if( !apply_filters('bebuilder_access', false) ){
			return false;
		}

		if( !current_user_can('editor') && !current_user_can('administrator') ){
			return false;
		}
	}

	parent::__construct();

	// fires after WordPress has finished loading but before any headers are sent
	add_action('init', array($this, 'register'));

Best regards,
Osama

March 20, 2024 at 2:32 pm #15432273

konradB-6

Thanks for workaround.
It's good to know for future users that you'll need first apply workaround and then making sections and then translation with wpml.
Otherwise CSS for sections will not regenerate and you'll need to update all sections firsthand and and update pages.