Skip Navigation

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

Problem: The user was having issues with conditions of his menu in secondary language Solution: The plugin Conditional Menus presents some serious compatibility issues with WPML, the solution was pretty complexe and we have had to correct it in many steps: 1. https://wpml.org/forums/topic/bug-with-conditional-menus/#post-3138540 2. https://wpml.org/forums/topic/bug-with-conditional-menus/#post-3148567 3. https://wpml.org/forums/topic/bug-with-conditional-menus/#post-3164479 Check also https://wpml.org/forums/topic/bug-with-conditional-menus/page/2/#post-3173711

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 17 replies, has 5 voices.

Last updated by jasonJ-4 1 year, 6 months ago.

Assigned support staff: Jamal.

Author Posts
February 8, 2019 at 8:49 am #3173711

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello,

Thank you for your feedback. Copying the init.php from sandbox will implement the fix correctly on your files.
But did you add the condition to diable the menu ?
Check the sandbox, we have added a rule to disable the menu where we are in parent pages of both languages, then we add the condition to show the menu for the parent+child pages for both languages.

As you have removed the XML translation, you can ignore right now the string in WPML->String Translation, you can also select+delete them.

I think that the most important, after the last fix, is to have 2 conditions for the menu.
- First condition deactivate the Menu_one.
- Second condition activate Menu_two.

Could you refresh the staging server with the production data, this way i can assist you on the staging server step by step.

Let me know what you get.

Best regards,
Jamal
WPML Support

February 12, 2019 at 10:56 pm #3191205
laurenta-5

Hi Jamal,

I'm having the same issue. Do you know when the final fix will be deployed in WPML ?

Regards,
Laurent

New threads created by Jamal and linked to this one are listed below:

https://wpml.org/forums/topic/split-bug-with-conditional-menus/

April 1, 2019 at 12:07 pm #3507653

julieB-20

Hi Jamal

I have the same issue and tried replacing the code as suggested, but the result is entire site went blank.

I think the problem is that the wrong code is replaced.

You write to replace line 334-336 in the conditional-menus/init.php file, but since it's not working i suspect it might be different lines in my editor. Could you specify which lines of code should be replaced?

Best regards

May 30, 2019 at 4:07 am #3920303

jasonJ-4

Hi. I'm using conditional menus version 1.1.3 and the workaround code from this topic looks nothing like the init.php I have. The if statement looks like this and much more complex that what you have described. I'm afraid if I pasted in your solution it is much less complex and have adverse side affects. Here is the existing init.php code from version 1.1.3:

if (
	// Post single
	( $post_type === 'post' && is_single() && is_single( $posts ) )
	// Page view
	|| ( $post_type === 'page' && (
		( is_page() &&
			( is_page( $posts )
			// check for pages that have a Parent, the slug for these pages are stored differently.
			|| ( isset( $query_object->post_parent ) && $query_object->post_parent > 0 && in_array( str_replace( home_url(), '', get_permalink( $query_object->ID ) ), $posts ) )
		) )
		|| ( ! is_front_page() && is_home() &&  in_array( get_post_field( 'post_name', get_option( 'page_for_posts' ) ), $posts ) ) // check for Posts page
		|| ( class_exists( 'WooCommerce' ) && function_exists( 'is_shop' ) && in_array( get_post_field( 'post_name', wc_get_page_id( 'shop' ) ), $posts ) && is_shop() ) // check for WC Shop page
	) )
	// Custom Post Types single view check
	|| ( is_singular( $post_type ) && in_array( $query_object->post_name, $posts ) )
) {
	$visible = true;
	break;
}

The bug I'm seeing is when the language is changed in the dashboard the condition-menus get cleared. if i reset them and save, then change the language back to english, the conditional-menus are cleared again. It seems I can only have one set of conditional menus setup for 1 language only.