ubermenu_wpml_sync_excluded_menu_item_settings

Knowledgebase Docs » UberMenu 3
USEFUL? 0
UberMenu 3

Note that this filter requires WPML v4.5.1 or later and UberMenu v3.7.5 or later to function

During the WPML Menu Sync Process, WPML copies the UberMenu menu item settings from your source language to destination language.

By default, UberMenu will prevent WPML from overriding certain settings. For example, if you have Custom Content in your menu, this is likely language-specific. Therefore, UberMenu tells WPML to ignore your Custom Content menu item setting during the Menu Sync, so that your custom custom won’t get overridden.

This filter allows you to control exactly which fields are excluded from the WPML Menu Sync process.

By default the following fields are excluded:

[
    // General
    'custom_content',               // Custom Content
    'custom_url',                   // Custom URL
    'icon_title',                   // Icon Title
    'badge_content',                // Badge Content
    'submenu_footer_content',       // Submenu Footer Content
    'shiftnav_target',              // ShiftNav Toggle

    // Dynamic Posts
    'dp_post_parent',               // Post Parent
    'dp_exclude',                   // Exclude
    'dp_subcontent',                // Sub Content
    'dp_view_all_text',             // View All Text
    
    // Dynamic Terms
    'dt_parent',                    // Parent Term
    'dt_child_of',                  // Ancestor Term
    'dt_exclude',                   // Exclude Terms
    'dt_view_all_text',             // View All Text

    'empty_results_message',        // Empty Results Message
]

You can filter this array and add or remove any fields to customize the sync process to your needs.

add_filter( 'ubermenu_wpml_sync_excluded_menu_item_settings', 'um_wpml_sync_excluded_menu_item_settings', 10, 3 );
function um_wpml_sync_excluded_menu_item_settings( $excluded_settings, $item_id_from, $item_id_to ){

	// Don't exlude custom_content from menu sync
	$excluded_settings = array_diff( $excluded_settings, ['custom_content'] );

	// Exclude item_image from menu sync
	$excluded_settings[] = 'item_image';

	return $excluded_settings;
}

Note: the $item_id_from and $item_id_to arguments can be used if you need to target specific menu items for sync exclusions.